@inpageedit/core 0.16.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/InPageEdit.js +1 -1
  2. package/dist/{PluginImagesUsed-DnPDXczO.js → PluginImagesUsed-CD7t5kqv.js} +2 -2
  3. package/dist/{PluginImagesUsed-DnPDXczO.js.map → PluginImagesUsed-CD7t5kqv.js.map} +1 -1
  4. package/dist/{PluginPrefSync-CDTFyM8g.js → PluginPrefSync-DgKVDgiK.js} +2 -2
  5. package/dist/{PluginPrefSync-CDTFyM8g.js.map → PluginPrefSync-DgKVDgiK.js.map} +1 -1
  6. package/dist/{PluginStoreApp-Bng4DFBZ.js → PluginStoreApp-BwiAYQMA.js} +2 -2
  7. package/dist/{PluginStoreApp-Bng4DFBZ.js.map → PluginStoreApp-BwiAYQMA.js.map} +1 -1
  8. package/dist/{PluginTemplatesUsed-oM_VzfbH.js → PluginTemplatesUsed-CmYn48Wd.js} +2 -2
  9. package/dist/{PluginTemplatesUsed-oM_VzfbH.js.map → PluginTemplatesUsed-CmYn48Wd.js.map} +1 -1
  10. package/dist/core.js +2 -2
  11. package/dist/{index-BcTomMXW.js → index-5DLUhCA3.js} +3 -3
  12. package/dist/{index-BcTomMXW.js.map → index-5DLUhCA3.js.map} +1 -1
  13. package/dist/{index-CkSHCMRN.js → index-B5UcAL5E.js} +2 -2
  14. package/dist/{index-CkSHCMRN.js.map → index-B5UcAL5E.js.map} +1 -1
  15. package/dist/{index-Bn6y0Eln.js → index-BMd6Bo6r.js} +101 -113
  16. package/dist/{index-Bn6y0Eln.js.map → index-BMd6Bo6r.js.map} +1 -1
  17. package/dist/{index-BBUv7Lv6.js → index-BTLjDVvD.js} +2 -2
  18. package/dist/{index-BBUv7Lv6.js.map → index-BTLjDVvD.js.map} +1 -1
  19. package/dist/{index-D7rUF8vA.js → index-BfW7ObKf.js} +534 -468
  20. package/dist/index-BfW7ObKf.js.map +1 -0
  21. package/dist/{index-mf_pX14E.js → index-BvHXETfl.js} +2 -2
  22. package/dist/{index-mf_pX14E.js.map → index-BvHXETfl.js.map} +1 -1
  23. package/dist/{index-BllIuJSJ.js → index-C2_G8gLW.js} +3 -3
  24. package/dist/{index-BllIuJSJ.js.map → index-C2_G8gLW.js.map} +1 -1
  25. package/dist/{index-42B3CrSO.js → index-C4ncbyR6.js} +2 -2
  26. package/dist/{index-42B3CrSO.js.map → index-C4ncbyR6.js.map} +1 -1
  27. package/dist/{index-1sZXko-X.js → index-CZ56EKIK.js} +2 -2
  28. package/dist/{index-1sZXko-X.js.map → index-CZ56EKIK.js.map} +1 -1
  29. package/dist/{index-DlCbsA25.js → index-Cjyf3z1w.js} +3 -3
  30. package/dist/{index-DlCbsA25.js.map → index-Cjyf3z1w.js.map} +1 -1
  31. package/dist/{index-TG_MTC9y.js → index-Dfp9Vp36.js} +2 -2
  32. package/dist/{index-TG_MTC9y.js.map → index-Dfp9Vp36.js.map} +1 -1
  33. package/dist/{index-CN7r2e0P.js → index-s7aFr-gn.js} +2 -2
  34. package/dist/{index-CN7r2e0P.js.map → index-s7aFr-gn.js.map} +1 -1
  35. package/dist/{index-CMmEZcB1.js → index-siZBRSp0.js} +2 -2
  36. package/dist/{index-CMmEZcB1.js.map → index-siZBRSp0.js.map} +1 -1
  37. package/dist/index.d.ts +74 -38
  38. package/dist/index.js +2 -2
  39. package/dist/plugins/index.js +12 -12
  40. package/dist/services/index.js +14 -12
  41. package/dist/style.css +1 -1
  42. package/lib/index.umd.js +15 -15
  43. package/lib/index.umd.js.map +1 -1
  44. package/lib/style.css +1 -1
  45. package/package.json +1 -1
  46. package/dist/index-D7rUF8vA.js.map +0 -1
package/lib/index.umd.js CHANGED
@@ -1,7 +1,7 @@
1
- (function(Y,pe){typeof exports=="object"&&typeof module<"u"?pe(exports):typeof define=="function"&&define.amd?define(["exports"],pe):(Y=typeof globalThis<"u"?globalThis:Y||self,pe(Y.InPageEditBundle={}))})(this,(function(Y){"use strict";var O0=Object.defineProperty;var Uf=Y=>{throw TypeError(Y)};var L0=(Y,pe,W)=>pe in Y?O0(Y,pe,{enumerable:!0,configurable:!0,writable:!0,value:W}):Y[pe]=W;var j=(Y,pe,W)=>L0(Y,typeof pe!="symbol"?pe+"":pe,W),Fa=(Y,pe,W)=>pe.has(Y)||Uf("Cannot "+W);var ce=(Y,pe,W)=>(Fa(Y,pe,"read from private field"),W?W.call(Y):pe.get(Y)),Ni=(Y,pe,W)=>pe.has(Y)?Uf("Cannot add the same private member more than once"):pe instanceof WeakSet?pe.add(Y):pe.set(Y,W),je=(Y,pe,W,Xr)=>(Fa(Y,pe,"write to private field"),Xr?Xr.call(Y,W):pe.set(Y,W),W),wt=(Y,pe,W)=>(Fa(Y,pe,"access private method"),W);var yt,er,Ti,tr,ir,rr,nr,Le,ut,dt,qa,qf,Bf,or,Hf,zf,bt,vt,Wf,Kf,Vf,Gf,Qf,Qr,$t,Oi;var pe=Object.defineProperty,W=(t,e)=>pe(t,"name",{value:e,configurable:!0});function Xr(){}W(Xr,"noop");function Ie(t){return t==null}W(Ie,"isNullable");function Yf(t){return!Ie(t)}W(Yf,"isNonNullable");function Jr(t){return t&&typeof t=="object"&&!Array.isArray(t)}W(Jr,"isPlainObject");function Ba(t,e){return Object.fromEntries(Object.entries(t).filter(([i,r])=>e(i,r)))}W(Ba,"filterKeys");function Kt(t,e){return Object.fromEntries(Object.entries(t).map(([i,r])=>[i,e(r,i)]))}W(Kt,"mapValues");function Ha(t,e,i){if(!e)return{...t};const r={};for(const n of e)(i||t[n]!==void 0)&&(r[n]=t[n]);return r}W(Ha,"pick");function Xf(t,e){if(!e)return{...t};const i={...t};for(const r of e)Reflect.deleteProperty(i,r);return i}W(Xf,"omit");function Be(t,e,i){return Object.defineProperty(t,e,{writable:!0,value:i,enumerable:!1})}W(Be,"defineProperty");function Jf(t,e){return e.every(i=>t.includes(i))}W(Jf,"contain");function Zf(t,e){return t.filter(i=>e.includes(i))}W(Zf,"intersection");function eh(t,e){return t.filter(i=>!e.includes(i))}W(eh,"difference");function th(t,e){return Array.from(new Set([...t,...e]))}W(th,"union");function ih(t){return[...new Set(t)]}W(ih,"deduplicate");function oi(t,e){const i=t?.indexOf(e);return i>=0?(t.splice(i,1),!0):!1}W(oi,"remove");function rh(t){return Array.isArray(t)?t:Ie(t)?[]:[t]}W(rh,"makeArray");function ai(t,e){return arguments.length===1?i=>ai(t,i):t in globalThis&&e instanceof globalThis[t]||Object.prototype.toString.call(e).slice(8,-1)===t}W(ai,"is");function lr(t){return ai("ArrayBuffer",t)||ai("SharedArrayBuffer",t)}W(lr,"isArrayBufferLike");function za(t){return lr(t)||ArrayBuffer.isView(t)}W(za,"isArrayBufferSource");var Ct;(t=>{t.is=lr,t.isSource=za;function e(o){return ArrayBuffer.isView(o)?o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength):o}t.fromSource=e,W(e,"fromSource");function i(o){if(typeof Buffer<"u")return Buffer.from(o).toString("base64");let a="";const c=new Uint8Array(o);for(let l=0;l<c.byteLength;l++)a+=String.fromCharCode(c[l]);return btoa(a)}t.toBase64=i,W(i,"toBase64");function r(o){return typeof Buffer<"u"?e(Buffer.from(o,"base64")):Uint8Array.from(atob(o),a=>a.charCodeAt(0))}t.fromBase64=r,W(r,"fromBase64");function n(o){return typeof Buffer<"u"?Buffer.from(o).toString("hex"):Array.from(new Uint8Array(o),a=>a.toString(16).padStart(2,"0")).join("")}t.toHex=n,W(n,"toHex");function s(o){if(typeof Buffer<"u")return e(Buffer.from(o,"hex"));const a=o.length%2===0?o:o.slice(0,o.length-1),c=[];for(let l=0;l<a.length;l+=2)c.push(parseInt(`${a[l]}${a[l+1]}`,16));return Uint8Array.from(c).buffer}t.fromHex=s,W(s,"fromHex")})(Ct||(Ct={})),Ct.fromBase64,Ct.toBase64,Ct.fromHex,Ct.toHex;function Zr(t,e=new Map){if(!t||typeof t!="object")return t;if(ai("Date",t))return new Date(t.valueOf());if(ai("RegExp",t))return new RegExp(t.source,t.flags);if(lr(t))return t.slice(0);if(ArrayBuffer.isView(t))return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);const i=e.get(t);if(i)return i;if(Array.isArray(t)){const n=[];return e.set(t,n),t.forEach((s,o)=>{n[o]=Reflect.apply(Zr,null,[s,e])}),n}const r=Object.create(Object.getPrototypeOf(t));e.set(t,r);for(const n of Reflect.ownKeys(t)){const s={...Reflect.getOwnPropertyDescriptor(t,n)};"value"in s&&(s.value=Reflect.apply(Zr,null,[s.value,e])),Reflect.defineProperty(r,n,s)}return r}W(Zr,"clone");function mi(t,e,i){if(t===e||!i&&Ie(t)&&Ie(e))return!0;if(typeof t!=typeof e||typeof t!="object"||!t||!e)return!1;function r(n,s){return n(t)?n(e)?s(t,e):!1:n(e)?!1:void 0}return W(r,"check"),r(Array.isArray,(n,s)=>n.length===s.length&&n.every((o,a)=>mi(o,s[a])))??r(ai("Date"),(n,s)=>n.valueOf()===s.valueOf())??r(ai("RegExp"),(n,s)=>n.source===s.source&&n.flags===s.flags)??r(lr,(n,s)=>{if(n.byteLength!==s.byteLength)return!1;const o=new Uint8Array(n),a=new Uint8Array(s);for(let c=0;c<o.length;c++)if(o[c]!==a[c])return!1;return!0})??Object.keys({...t,...e}).every(n=>mi(t[n],e[n],i))}W(mi,"deepEqual");function nh(t){return t.charAt(0).toUpperCase()+t.slice(1)}W(nh,"capitalize");function sh(t){return t.charAt(0).toLowerCase()+t.slice(1)}W(sh,"uncapitalize");function oh(t){return t.replace(/[_-][a-z]/g,e=>e.slice(1).toUpperCase())}W(oh,"camelCase");function ws(t,e,i){const r=[];let n=0;for(let s=0;s<t.length;s++){const o=t.charCodeAt(s);if(o>=65&&o<=90){if(n===1){const a=t.charCodeAt(s+1);a>=97&&a<=122&&r.push(i),r.push(o+32)}else n!==0&&r.push(i),r.push(o+32);n=1}else o>=97&&o<=122?(r.push(o),n=2):e.includes(o)?(n!==0&&r.push(i),n=0):r.push(o)}return String.fromCharCode(...r)}W(ws,"tokenize");function ah(t){return ws(t,[45,95],45)}W(ah,"paramCase");function lh(t){return ws(t,[45,95],95)}W(lh,"snakeCase");function ch(t){return typeof t!="string"?`[${t.toString()}]`:/^[a-z_$][\w$]*$/i.test(t)?`.${t}`:`[${JSON.stringify(t)}]`}W(ch,"formatProperty");function Wa(t){return t.replace(/\/$/,"")}W(Wa,"trimSlash");function uh(t){return t.startsWith("/")||(t="/"+t),Wa(t)}W(uh,"sanitize");var Ka;(t=>{t.millisecond=1,t.second=1e3,t.minute=t.second*60,t.hour=t.minute*60,t.day=t.hour*24,t.week=t.day*7;let e=new Date().getTimezoneOffset();function i(p){e=p}t.setTimezoneOffset=i,W(i,"setTimezoneOffset");function r(){return e}t.getTimezoneOffset=r,W(r,"getTimezoneOffset");function n(p=new Date,h){return typeof p=="number"&&(p=new Date(p)),h===void 0&&(h=e),Math.floor((p.valueOf()/t.minute-h)/1440)}t.getDateNumber=n,W(n,"getDateNumber");function s(p,h){const _=new Date(p*t.day);return h===void 0&&(h=e),new Date(+_+h*t.minute)}t.fromDateNumber=s,W(s,"fromDateNumber");const o=/\d+(?:\.\d+)?/.source,a=new RegExp(`^${["w(?:eek(?:s)?)?","d(?:ay(?:s)?)?","h(?:our(?:s)?)?","m(?:in(?:ute)?(?:s)?)?","s(?:ec(?:ond)?(?:s)?)?"].map(p=>`(${o}${p})?`).join("")}$`);function c(p){const h=a.exec(p);return h?(parseFloat(h[1])*t.week||0)+(parseFloat(h[2])*t.day||0)+(parseFloat(h[3])*t.hour||0)+(parseFloat(h[4])*t.minute||0)+(parseFloat(h[5])*t.second||0):0}t.parseTime=c,W(c,"parseTime");function l(p){const h=c(p);return h?p=Date.now()+h:/^\d{1,2}(:\d{1,2}){1,2}$/.test(p)?p=`${new Date().toLocaleDateString()}-${p}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(p)&&(p=`${new Date().getFullYear()}-${p}`),p?new Date(p):new Date}t.parseDate=l,W(l,"parseDate");function u(p){const h=Math.abs(p);return h>=t.day-t.hour/2?Math.round(p/t.day)+"d":h>=t.hour-t.minute/2?Math.round(p/t.hour)+"h":h>=t.minute-t.second/2?Math.round(p/t.minute)+"m":h>=t.second?Math.round(p/t.second)+"s":p+"ms"}t.format=u,W(u,"format");function d(p,h=2){return p.toString().padStart(h,"0")}t.toDigits=d,W(d,"toDigits");function y(p,h=new Date){return p.replace("yyyy",h.getFullYear().toString()).replace("yy",h.getFullYear().toString().slice(2)).replace("MM",d(h.getMonth()+1)).replace("dd",d(h.getDate())).replace("hh",d(h.getHours())).replace("mm",d(h.getMinutes())).replace("ss",d(h.getSeconds())).replace("SSS",d(h.getMilliseconds(),3))}t.template=y,W(y,"template")})(Ka||(Ka={}));var dh=Object.defineProperty,X=(t,e)=>dh(t,"name",{value:e,configurable:!0}),U={shadow:Symbol.for("cordis.shadow"),receiver:Symbol.for("cordis.receiver"),original:Symbol.for("cordis.original"),store:Symbol.for("cordis.store"),events:Symbol.for("cordis.events"),static:Symbol.for("cordis.static"),filter:Symbol.for("cordis.filter"),expose:Symbol.for("cordis.expose"),isolate:Symbol.for("cordis.isolate"),internal:Symbol.for("cordis.internal"),intercept:Symbol.for("cordis.intercept"),setup:Symbol.for("cordis.setup"),invoke:Symbol.for("cordis.invoke"),extend:Symbol.for("cordis.extend"),tracker:Symbol.for("cordis.tracker"),provide:Symbol.for("cordis.provide"),immediate:Symbol.for("cordis.immediate")},fh=function*(){}.constructor,Va=async function*(){}.constructor;function _s(t){return!(!t.prototype||t instanceof fh||Va!==Function&&t instanceof Va)}X(_s,"isConstructor");function cr(t,e){const i=t.Config||t.schema;return i&&t.schema!==!1&&(e=i(e)),e??{}}X(cr,"resolveConfig");function Ga(t){return[Map,Set,Date,Promise].some(e=>t instanceof e)}X(Ga,"isUnproxyable");function xs(t,e){if(t===Object.prototype)return e;const i=Object.create(xs(Object.getPrototypeOf(t),e));for(const r of Reflect.ownKeys(t))Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r));return i}X(xs,"joinPrototype");function ks(t){return t&&(typeof t=="object"||typeof t=="function")}X(ks,"isObject");function It(t,e,i){if(!ks(e))return e;if(Object.hasOwn(e,U.shadow))return Object.getPrototypeOf(e);const r=e[U.tracker];return r?tn(t,e,r,i):e}X(It,"getTraceable");function ur(t,e){return e?new Proxy(t,{get:X((i,r,n)=>r in e&&r!=="constructor"?Reflect.get(e,r,n):Reflect.get(i,r,n),"get"),set:X((i,r,n,s)=>r in e&&r!=="constructor"?Reflect.set(e,r,n,s):Reflect.set(i,r,n,s),"set")}):t}X(ur,"withProps");function en(t,e,i){return ur(t,Object.defineProperty(Object.create(null),e,{value:i,writable:!1}))}X(en,"withProp");function Ss(t,e,i,r){if(!i)return r;const n=Reflect.getOwnPropertyDescriptor(e,i)?.value;return n?en(r,i,t.extend({[U.shadow]:n})):r}X(Ss,"createShadow");function Qa(t,e,i,r){return new Proxy(e,{apply:X((n,s,o)=>(s===i&&(s=r),o=o.map(a=>typeof a!="function"||a[U.original]?a:new Proxy(a,{get:X((c,l,u)=>{if(l===U.original)return c;const d=Reflect.get(c,l,u);return l==="toString"&&d===Function.prototype.toString?function(...y){return Reflect.apply(d,this===u?c:this,y)}:d},"get"),apply:X((c,l,u)=>Reflect.apply(c,It(t,l),u.map(d=>It(t,d))),"apply"),construct:X((c,l,u)=>Reflect.construct(c,l.map(d=>It(t,d)),u),"construct")})),It(t,Reflect.apply(n,s,o))),"apply")})}X(Qa,"createShadowMethod");function tn(t,e,i,r){t[U.shadow]&&(t=Object.getPrototypeOf(t));const n=new Proxy(e,{get:X((s,o,a)=>{if(o===U.original)return s;if(o===i.property)return t;if(typeof o=="symbol")return Reflect.get(s,o,a);if(i.associate&&t[U.internal][`${i.associate}.${o}`])return Reflect.get(t,`${i.associate}.${o}`,en(t,U.receiver,a));const c=Ss(t,s,i.property,a),l=Reflect.get(s,o,c),u=l?.[U.tracker];return u?tn(t,l,u):!r&&typeof l=="function"?Qa(t,l,a,c):l},"get"),set:X((s,o,a,c)=>{if(o===U.original||o===i.property)return!1;if(typeof o=="symbol")return Reflect.set(s,o,a,c);if(i.associate&&t[U.internal][`${i.associate}.${o}`])return Reflect.set(t,`${i.associate}.${o}`,a,en(t,U.receiver,c));const l=Ss(t,s,i.property,c);return Reflect.set(s,o,a,l)},"set"),apply:X((s,o,a)=>Es(n,s,o,a),"apply")});return n}X(tn,"createTraceable");function Es(t,e,i,r){return e[U.invoke]?e[U.invoke].apply(t,r):Reflect.apply(e,i,r)}X(Es,"applyTraceable");function $s(t,e,i){const r=X(function(...n){const s=tn(r.ctx,r,i);return Es(s,r,this,n)},"self");return Be(r,"name",t),Object.setPrototypeOf(r,e)}X($s,"createCallable");var hh=(yt=class{constructor(e){this.ctx=e,Be(this,U.tracker,{associate:"reflect",property:"ctx"}),this._mixin("reflect",["get","set","provide","accessor","mixin","alias"]),this._mixin("scope",["config","runtime","effect","collect","accept","decline"]),this._mixin("registry",["using","inject","plugin"]),this._mixin("lifecycle",["on","once","parallel","emit","serial","bail","start","stop"])}static resolveInject(e,i){let r=e[U.internal][i];for(;r?.type==="alias";)i=r.name,r=e[U.internal][i];return[i,r]}static checkInject(e,i,r){if(e=e[U.shadow]??e,["prototype","then","registry","lifecycle"].includes(i)||i[0]==="$"||i[0]==="_"||!e.runtime.plugin||e.bail(e,"internal/inject",i))return;const n=r.stack.split(`
1
+ (function(Y,pe){typeof exports=="object"&&typeof module<"u"?pe(exports):typeof define=="function"&&define.amd?define(["exports"],pe):(Y=typeof globalThis<"u"?globalThis:Y||self,pe(Y.InPageEditBundle={}))})(this,(function(Y){"use strict";var D0=Object.defineProperty;var qf=Y=>{throw TypeError(Y)};var j0=(Y,pe,W)=>pe in Y?D0(Y,pe,{enumerable:!0,configurable:!0,writable:!0,value:W}):Y[pe]=W;var j=(Y,pe,W)=>j0(Y,typeof pe!="symbol"?pe+"":pe,W),qa=(Y,pe,W)=>pe.has(Y)||qf("Cannot "+W);var ce=(Y,pe,W)=>(qa(Y,pe,"read from private field"),W?W.call(Y):pe.get(Y)),Ni=(Y,pe,W)=>pe.has(Y)?qf("Cannot add the same private member more than once"):pe instanceof WeakSet?pe.add(Y):pe.set(Y,W),je=(Y,pe,W,Xr)=>(qa(Y,pe,"write to private field"),Xr?Xr.call(Y,W):pe.set(Y,W),W),wt=(Y,pe,W)=>(qa(Y,pe,"access private method"),W);var yt,er,Ti,tr,ir,rr,nr,Le,ut,dt,Ba,Hf,zf,or,Wf,Kf,bt,vt,Vf,Gf,Qf,Yf,Xf,Qr,$t,Oi;var pe=Object.defineProperty,W=(t,e)=>pe(t,"name",{value:e,configurable:!0});function Xr(){}W(Xr,"noop");function Ie(t){return t==null}W(Ie,"isNullable");function Jf(t){return!Ie(t)}W(Jf,"isNonNullable");function Jr(t){return t&&typeof t=="object"&&!Array.isArray(t)}W(Jr,"isPlainObject");function Ha(t,e){return Object.fromEntries(Object.entries(t).filter(([i,r])=>e(i,r)))}W(Ha,"filterKeys");function Kt(t,e){return Object.fromEntries(Object.entries(t).map(([i,r])=>[i,e(r,i)]))}W(Kt,"mapValues");function za(t,e,i){if(!e)return{...t};const r={};for(const n of e)(i||t[n]!==void 0)&&(r[n]=t[n]);return r}W(za,"pick");function Zf(t,e){if(!e)return{...t};const i={...t};for(const r of e)Reflect.deleteProperty(i,r);return i}W(Zf,"omit");function Be(t,e,i){return Object.defineProperty(t,e,{writable:!0,value:i,enumerable:!1})}W(Be,"defineProperty");function eh(t,e){return e.every(i=>t.includes(i))}W(eh,"contain");function th(t,e){return t.filter(i=>e.includes(i))}W(th,"intersection");function ih(t,e){return t.filter(i=>!e.includes(i))}W(ih,"difference");function rh(t,e){return Array.from(new Set([...t,...e]))}W(rh,"union");function nh(t){return[...new Set(t)]}W(nh,"deduplicate");function oi(t,e){const i=t?.indexOf(e);return i>=0?(t.splice(i,1),!0):!1}W(oi,"remove");function sh(t){return Array.isArray(t)?t:Ie(t)?[]:[t]}W(sh,"makeArray");function ai(t,e){return arguments.length===1?i=>ai(t,i):t in globalThis&&e instanceof globalThis[t]||Object.prototype.toString.call(e).slice(8,-1)===t}W(ai,"is");function lr(t){return ai("ArrayBuffer",t)||ai("SharedArrayBuffer",t)}W(lr,"isArrayBufferLike");function Wa(t){return lr(t)||ArrayBuffer.isView(t)}W(Wa,"isArrayBufferSource");var Ct;(t=>{t.is=lr,t.isSource=Wa;function e(o){return ArrayBuffer.isView(o)?o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength):o}t.fromSource=e,W(e,"fromSource");function i(o){if(typeof Buffer<"u")return Buffer.from(o).toString("base64");let a="";const c=new Uint8Array(o);for(let l=0;l<c.byteLength;l++)a+=String.fromCharCode(c[l]);return btoa(a)}t.toBase64=i,W(i,"toBase64");function r(o){return typeof Buffer<"u"?e(Buffer.from(o,"base64")):Uint8Array.from(atob(o),a=>a.charCodeAt(0))}t.fromBase64=r,W(r,"fromBase64");function n(o){return typeof Buffer<"u"?Buffer.from(o).toString("hex"):Array.from(new Uint8Array(o),a=>a.toString(16).padStart(2,"0")).join("")}t.toHex=n,W(n,"toHex");function s(o){if(typeof Buffer<"u")return e(Buffer.from(o,"hex"));const a=o.length%2===0?o:o.slice(0,o.length-1),c=[];for(let l=0;l<a.length;l+=2)c.push(parseInt(`${a[l]}${a[l+1]}`,16));return Uint8Array.from(c).buffer}t.fromHex=s,W(s,"fromHex")})(Ct||(Ct={})),Ct.fromBase64,Ct.toBase64,Ct.fromHex,Ct.toHex;function Zr(t,e=new Map){if(!t||typeof t!="object")return t;if(ai("Date",t))return new Date(t.valueOf());if(ai("RegExp",t))return new RegExp(t.source,t.flags);if(lr(t))return t.slice(0);if(ArrayBuffer.isView(t))return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);const i=e.get(t);if(i)return i;if(Array.isArray(t)){const n=[];return e.set(t,n),t.forEach((s,o)=>{n[o]=Reflect.apply(Zr,null,[s,e])}),n}const r=Object.create(Object.getPrototypeOf(t));e.set(t,r);for(const n of Reflect.ownKeys(t)){const s={...Reflect.getOwnPropertyDescriptor(t,n)};"value"in s&&(s.value=Reflect.apply(Zr,null,[s.value,e])),Reflect.defineProperty(r,n,s)}return r}W(Zr,"clone");function mi(t,e,i){if(t===e||!i&&Ie(t)&&Ie(e))return!0;if(typeof t!=typeof e||typeof t!="object"||!t||!e)return!1;function r(n,s){return n(t)?n(e)?s(t,e):!1:n(e)?!1:void 0}return W(r,"check"),r(Array.isArray,(n,s)=>n.length===s.length&&n.every((o,a)=>mi(o,s[a])))??r(ai("Date"),(n,s)=>n.valueOf()===s.valueOf())??r(ai("RegExp"),(n,s)=>n.source===s.source&&n.flags===s.flags)??r(lr,(n,s)=>{if(n.byteLength!==s.byteLength)return!1;const o=new Uint8Array(n),a=new Uint8Array(s);for(let c=0;c<o.length;c++)if(o[c]!==a[c])return!1;return!0})??Object.keys({...t,...e}).every(n=>mi(t[n],e[n],i))}W(mi,"deepEqual");function oh(t){return t.charAt(0).toUpperCase()+t.slice(1)}W(oh,"capitalize");function ah(t){return t.charAt(0).toLowerCase()+t.slice(1)}W(ah,"uncapitalize");function lh(t){return t.replace(/[_-][a-z]/g,e=>e.slice(1).toUpperCase())}W(lh,"camelCase");function ws(t,e,i){const r=[];let n=0;for(let s=0;s<t.length;s++){const o=t.charCodeAt(s);if(o>=65&&o<=90){if(n===1){const a=t.charCodeAt(s+1);a>=97&&a<=122&&r.push(i),r.push(o+32)}else n!==0&&r.push(i),r.push(o+32);n=1}else o>=97&&o<=122?(r.push(o),n=2):e.includes(o)?(n!==0&&r.push(i),n=0):r.push(o)}return String.fromCharCode(...r)}W(ws,"tokenize");function ch(t){return ws(t,[45,95],45)}W(ch,"paramCase");function uh(t){return ws(t,[45,95],95)}W(uh,"snakeCase");function dh(t){return typeof t!="string"?`[${t.toString()}]`:/^[a-z_$][\w$]*$/i.test(t)?`.${t}`:`[${JSON.stringify(t)}]`}W(dh,"formatProperty");function Ka(t){return t.replace(/\/$/,"")}W(Ka,"trimSlash");function fh(t){return t.startsWith("/")||(t="/"+t),Ka(t)}W(fh,"sanitize");var Va;(t=>{t.millisecond=1,t.second=1e3,t.minute=t.second*60,t.hour=t.minute*60,t.day=t.hour*24,t.week=t.day*7;let e=new Date().getTimezoneOffset();function i(p){e=p}t.setTimezoneOffset=i,W(i,"setTimezoneOffset");function r(){return e}t.getTimezoneOffset=r,W(r,"getTimezoneOffset");function n(p=new Date,h){return typeof p=="number"&&(p=new Date(p)),h===void 0&&(h=e),Math.floor((p.valueOf()/t.minute-h)/1440)}t.getDateNumber=n,W(n,"getDateNumber");function s(p,h){const _=new Date(p*t.day);return h===void 0&&(h=e),new Date(+_+h*t.minute)}t.fromDateNumber=s,W(s,"fromDateNumber");const o=/\d+(?:\.\d+)?/.source,a=new RegExp(`^${["w(?:eek(?:s)?)?","d(?:ay(?:s)?)?","h(?:our(?:s)?)?","m(?:in(?:ute)?(?:s)?)?","s(?:ec(?:ond)?(?:s)?)?"].map(p=>`(${o}${p})?`).join("")}$`);function c(p){const h=a.exec(p);return h?(parseFloat(h[1])*t.week||0)+(parseFloat(h[2])*t.day||0)+(parseFloat(h[3])*t.hour||0)+(parseFloat(h[4])*t.minute||0)+(parseFloat(h[5])*t.second||0):0}t.parseTime=c,W(c,"parseTime");function l(p){const h=c(p);return h?p=Date.now()+h:/^\d{1,2}(:\d{1,2}){1,2}$/.test(p)?p=`${new Date().toLocaleDateString()}-${p}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(p)&&(p=`${new Date().getFullYear()}-${p}`),p?new Date(p):new Date}t.parseDate=l,W(l,"parseDate");function u(p){const h=Math.abs(p);return h>=t.day-t.hour/2?Math.round(p/t.day)+"d":h>=t.hour-t.minute/2?Math.round(p/t.hour)+"h":h>=t.minute-t.second/2?Math.round(p/t.minute)+"m":h>=t.second?Math.round(p/t.second)+"s":p+"ms"}t.format=u,W(u,"format");function d(p,h=2){return p.toString().padStart(h,"0")}t.toDigits=d,W(d,"toDigits");function y(p,h=new Date){return p.replace("yyyy",h.getFullYear().toString()).replace("yy",h.getFullYear().toString().slice(2)).replace("MM",d(h.getMonth()+1)).replace("dd",d(h.getDate())).replace("hh",d(h.getHours())).replace("mm",d(h.getMinutes())).replace("ss",d(h.getSeconds())).replace("SSS",d(h.getMilliseconds(),3))}t.template=y,W(y,"template")})(Va||(Va={}));var hh=Object.defineProperty,X=(t,e)=>hh(t,"name",{value:e,configurable:!0}),U={shadow:Symbol.for("cordis.shadow"),receiver:Symbol.for("cordis.receiver"),original:Symbol.for("cordis.original"),store:Symbol.for("cordis.store"),events:Symbol.for("cordis.events"),static:Symbol.for("cordis.static"),filter:Symbol.for("cordis.filter"),expose:Symbol.for("cordis.expose"),isolate:Symbol.for("cordis.isolate"),internal:Symbol.for("cordis.internal"),intercept:Symbol.for("cordis.intercept"),setup:Symbol.for("cordis.setup"),invoke:Symbol.for("cordis.invoke"),extend:Symbol.for("cordis.extend"),tracker:Symbol.for("cordis.tracker"),provide:Symbol.for("cordis.provide"),immediate:Symbol.for("cordis.immediate")},ph=function*(){}.constructor,Ga=async function*(){}.constructor;function _s(t){return!(!t.prototype||t instanceof ph||Ga!==Function&&t instanceof Ga)}X(_s,"isConstructor");function cr(t,e){const i=t.Config||t.schema;return i&&t.schema!==!1&&(e=i(e)),e??{}}X(cr,"resolveConfig");function Qa(t){return[Map,Set,Date,Promise].some(e=>t instanceof e)}X(Qa,"isUnproxyable");function xs(t,e){if(t===Object.prototype)return e;const i=Object.create(xs(Object.getPrototypeOf(t),e));for(const r of Reflect.ownKeys(t))Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r));return i}X(xs,"joinPrototype");function ks(t){return t&&(typeof t=="object"||typeof t=="function")}X(ks,"isObject");function It(t,e,i){if(!ks(e))return e;if(Object.hasOwn(e,U.shadow))return Object.getPrototypeOf(e);const r=e[U.tracker];return r?tn(t,e,r,i):e}X(It,"getTraceable");function ur(t,e){return e?new Proxy(t,{get:X((i,r,n)=>r in e&&r!=="constructor"?Reflect.get(e,r,n):Reflect.get(i,r,n),"get"),set:X((i,r,n,s)=>r in e&&r!=="constructor"?Reflect.set(e,r,n,s):Reflect.set(i,r,n,s),"set")}):t}X(ur,"withProps");function en(t,e,i){return ur(t,Object.defineProperty(Object.create(null),e,{value:i,writable:!1}))}X(en,"withProp");function Ss(t,e,i,r){if(!i)return r;const n=Reflect.getOwnPropertyDescriptor(e,i)?.value;return n?en(r,i,t.extend({[U.shadow]:n})):r}X(Ss,"createShadow");function Ya(t,e,i,r){return new Proxy(e,{apply:X((n,s,o)=>(s===i&&(s=r),o=o.map(a=>typeof a!="function"||a[U.original]?a:new Proxy(a,{get:X((c,l,u)=>{if(l===U.original)return c;const d=Reflect.get(c,l,u);return l==="toString"&&d===Function.prototype.toString?function(...y){return Reflect.apply(d,this===u?c:this,y)}:d},"get"),apply:X((c,l,u)=>Reflect.apply(c,It(t,l),u.map(d=>It(t,d))),"apply"),construct:X((c,l,u)=>Reflect.construct(c,l.map(d=>It(t,d)),u),"construct")})),It(t,Reflect.apply(n,s,o))),"apply")})}X(Ya,"createShadowMethod");function tn(t,e,i,r){t[U.shadow]&&(t=Object.getPrototypeOf(t));const n=new Proxy(e,{get:X((s,o,a)=>{if(o===U.original)return s;if(o===i.property)return t;if(typeof o=="symbol")return Reflect.get(s,o,a);if(i.associate&&t[U.internal][`${i.associate}.${o}`])return Reflect.get(t,`${i.associate}.${o}`,en(t,U.receiver,a));const c=Ss(t,s,i.property,a),l=Reflect.get(s,o,c),u=l?.[U.tracker];return u?tn(t,l,u):!r&&typeof l=="function"?Ya(t,l,a,c):l},"get"),set:X((s,o,a,c)=>{if(o===U.original||o===i.property)return!1;if(typeof o=="symbol")return Reflect.set(s,o,a,c);if(i.associate&&t[U.internal][`${i.associate}.${o}`])return Reflect.set(t,`${i.associate}.${o}`,a,en(t,U.receiver,c));const l=Ss(t,s,i.property,c);return Reflect.set(s,o,a,l)},"set"),apply:X((s,o,a)=>Es(n,s,o,a),"apply")});return n}X(tn,"createTraceable");function Es(t,e,i,r){return e[U.invoke]?e[U.invoke].apply(t,r):Reflect.apply(e,i,r)}X(Es,"applyTraceable");function $s(t,e,i){const r=X(function(...n){const s=tn(r.ctx,r,i);return Es(s,r,this,n)},"self");return Be(r,"name",t),Object.setPrototypeOf(r,e)}X($s,"createCallable");var gh=(yt=class{constructor(e){this.ctx=e,Be(this,U.tracker,{associate:"reflect",property:"ctx"}),this._mixin("reflect",["get","set","provide","accessor","mixin","alias"]),this._mixin("scope",["config","runtime","effect","collect","accept","decline"]),this._mixin("registry",["using","inject","plugin"]),this._mixin("lifecycle",["on","once","parallel","emit","serial","bail","start","stop"])}static resolveInject(e,i){let r=e[U.internal][i];for(;r?.type==="alias";)i=r.name,r=e[U.internal][i];return[i,r]}static checkInject(e,i,r){if(e=e[U.shadow]??e,["prototype","then","registry","lifecycle"].includes(i)||i[0]==="$"||i[0]==="_"||!e.runtime.plugin||e.bail(e,"internal/inject",i))return;const n=r.stack.split(`
2
2
  `);n.splice(1,1),r.stack=n.join(`
3
- `),e.emit(e,"internal/warning",r)}get(e){if(this.ctx[U.internal][e]?.type!=="service")return;const r=this.ctx[U.isolate][e],n=this.ctx[U.store][r]?.value;return It(this.ctx,n)}set(e,i){this.provide(e);const r=this.ctx[U.isolate][e],n=this.ctx[U.store][r]?.value;i??(i=void 0);let s=X(()=>{},"dispose");if(n===i)return s;if(!Ie(i)&&!Ie(n))throw new Error(`service ${e} has been registered`);const o=this.ctx;Ie(i)||(s=o.effect(()=>()=>{o.set(e,void 0)})),Ga(i)&&o.emit(o,"internal/warning",new Error(`service ${e} is an unproxyable object, which may lead to unexpected behavior`));const a=Object.create(o);return a[U.filter]=c=>o[U.isolate][e]===c[U.isolate][e],o.emit(a,"internal/before-service",e,i),o[U.store][r]={value:i,source:o},o.emit(a,"internal/service",e,n),s}provide(e,i,r){const n=this.ctx.root[U.internal];if(e in n)return;const s=Symbol(e);n[e]={type:"service",builtin:r},this.ctx.root[U.isolate][e]=s,ks(i)&&(this.ctx[U.store][s]={value:i,source:null},Be(i,U.tracker,{associate:e,property:"ctx"}))}_accessor(e,i){const r=this.ctx.root[U.internal];return e in r?()=>{}:(r[e]={type:"accessor",...i},()=>delete this.ctx.root[U.isolate][e])}accessor(e,i){this.ctx.scope.effect(()=>this._accessor(e,i))}alias(e,i){const r=this.ctx.root[U.internal];if(!(e in r))for(const n of i)r[n]||(r[n]={type:"alias",name:e})}_mixin(e,i){const r=Array.isArray(i)?i.map(o=>[o,o]):Object.entries(i),n=typeof e=="string"?o=>o[e]:()=>e,s=r.map(([o,a])=>this._accessor(a,{get(c){const l=n(this);if(Ie(l))return l;const u=c?ur(c,l):l,d=Reflect.get(l,o,u);return typeof d!="function"?d:d.bind(u??l)},set(c,l){const u=n(this),d=l?ur(l,u):u;return Reflect.set(u,o,c,d)}}));return()=>s.forEach(o=>o())}mixin(e,i){this.ctx.scope.effect(()=>this._mixin(e,i))}trace(e){return It(this.ctx,e)}bind(e){return new Proxy(e,{apply:X((i,r,n)=>i.apply(this.trace(r),n.map(s=>this.trace(s))),"apply")})}},X(yt,"ReflectService"),j(yt,"handler",{get:X((e,i,r)=>{if(typeof i!="string")return Reflect.get(e,i,r);if(Reflect.has(e,i))return It(r,Reflect.get(e,i,r),!0);const[n,s]=yt.resolveInject(e,i),o=new Error(`property ${n} is not registered, declare it as \`inject\` to suppress this warning`);return s?s.type==="accessor"?s.get.call(r,r[U.receiver]):(s.builtin||yt.checkInject(r,n,o),r.reflect.get(n)):(yt.checkInject(r,n,o),Reflect.get(e,n,r))},"get"),set:X((e,i,r,n)=>{if(typeof i!="string")return Reflect.set(e,i,r,n);const[s,o]=yt.resolveInject(e,i);return o?o.type==="accessor"?o.set?o.set.call(n,r,n[U.receiver]):!1:(n.reflect.set(s,r),!0):Reflect.set(e,s,r,n)},"set"),has:X((e,i)=>{if(typeof i!="string")return Reflect.has(e,i);if(Reflect.has(e,i))return!0;const[,r]=yt.resolveInject(e,i);return!!r},"has")}),yt),Ps=hh;function Cs(t){return t!==null&&t!==!1&&t!==void 0}X(Cs,"isBailed");var ph=(er=class{constructor(e){j(this,"isActive",!1);j(this,"_tasks",new Set);j(this,"_hooks",{});this.ctx=e,Be(this,U.tracker,{associate:"lifecycle",property:"ctx"}),Be(this.on("internal/listener",function(r,n,s){const o=s.prepend?"unshift":"push";if(r==="ready")return this.lifecycle.isActive?(this.scope.ensure(async()=>n()),()=>!1):void 0;if(r==="dispose")return this.scope.disposables[o](n),Be(n,"name","event <dispose>"),()=>oi(this.scope.disposables,n);if(r==="fork")return this.scope.runtime.forkables[o](n),this.scope.collect("event <fork>",()=>oi(this.scope.runtime.forkables,n))}),Ze.static,e.scope);for(const r of["info","error","warning"])Be(this.on(`internal/${r}`,(n,...s)=>{this._hooks[`internal/${r}`].length>1}),Ze.static,e.scope);Be(this.on("internal/before-service",function(r){for(const n of this.registry.values()){if(!n.inject[r]?.required)continue;const s=n.isReusable?n.children:[n];for(const o of s)this[U.filter](o.ctx)&&(o.updateStatus(),o.reset())}},{global:!0}),Ze.static,e.scope),Be(this.on("internal/service",function(r){for(const n of this.registry.values()){if(!n.inject[r]?.required)continue;const s=n.isReusable?n.children:[n];for(const o of s)this[U.filter](o.ctx)&&o.start()}},{global:!0}),Ze.static,e.scope);const i=X((r,n)=>{if(!r.runtime.plugin)return!1;for(const s in r.runtime.inject)if(n===Ps.resolveInject(r.ctx,s)[0])return!0;return i(r.parent.scope,n)},"checkInject");Be(this.on("internal/inject",function(r){return i(this.scope,r)},{global:!0}),Ze.static,e.scope)}async flush(){for(;this._tasks.size;)await Promise.all(Array.from(this._tasks))}filterHooks(e,i){return i=It(this.ctx,i),e.slice().filter(r=>{const n=i?.[Ze.filter];return r.global||!n||n.call(i,r.ctx)})}*dispatch(e,i){const r=typeof i[0]=="object"||typeof i[0]=="function"?i.shift():null,n=i.shift();n!=="internal/event"&&this.emit("internal/event",e,n,i,r);for(const s of this.filterHooks(this._hooks[n]||[],r))yield s.callback.apply(r,i)}async parallel(...e){await Promise.all(this.dispatch("emit",e))}emit(...e){Array.from(this.dispatch("emit",e))}async serial(...e){for await(const i of this.dispatch("serial",e))if(Cs(i))return i}bail(...e){for(const i of this.dispatch("bail",e))if(Cs(i))return i}register(e,i,r,n){const s=n.prepend?"unshift":"push";return i[s]({ctx:this.ctx,callback:r,...n}),this.ctx.state.collect(e,()=>this.unregister(i,r))}unregister(e,i){const r=e.findIndex(n=>n.callback===i);if(r>=0)return e.splice(r,1),!0}on(e,i,r){var a;typeof r!="object"&&(r={prepend:r}),this.ctx.scope.assertActive(),i=this.ctx.reflect.bind(i);const n=this.bail(this.ctx,"internal/listener",e,i,r);if(n)return n;const s=(a=this._hooks)[e]||(a[e]=[]),o=typeof e=="string"?`event <${e}>`:"event (Symbol)";return this.register(o,s,i,r)}once(e,i,r){const n=this.on(e,function(...s){return n(),i.apply(this,s)},r);return n}async start(){this.isActive=!0;const e=this._hooks.ready||[];for(;e.length;){const{ctx:i,callback:r}=e.shift();i.scope.ensure(async()=>r())}await this.flush()}async stop(){this.isActive=!1,this.ctx.scope.reset()}},X(er,"Lifecycle"),er),Ya=ph,Xa=(t=>(t[t.PENDING=0]="PENDING",t[t.LOADING=1]="LOADING",t[t.ACTIVE=2]="ACTIVE",t[t.FAILED=3]="FAILED",t[t.DISPOSED=4]="DISPOSED",t))(Xa||{});Y.CordisError=(Ti=class extends Error{constructor(e,i){super(i??Ti.Code[e]),this.code=e}},X(Ti,"CordisError"),Ti),(t=>{t.Code={INACTIVE_EFFECT:"cannot create effect on inactive context"}})(Y.CordisError||(Y.CordisError={}));var Is=(tr=class{constructor(e,i){j(this,"uid");j(this,"ctx");j(this,"disposables",[]);j(this,"error");j(this,"status",0);j(this,"isActive",!1);j(this,"context");j(this,"proxy");j(this,"acceptors",[]);j(this,"tasks",new Set);j(this,"hasError",!1);this.parent=e,this.config=i,this.uid=e.registry?e.registry.counter:0,this.ctx=this.context=e.extend({scope:this}),this.proxy=new Proxy({},{get:X((r,n)=>Reflect.get(this.config,n),"get")})}get _config(){return this.runtime.isReactive?this.proxy:this.config}assertActive(){if(!(this.uid!==null||this.isActive))throw new Y.CordisError("INACTIVE_EFFECT")}effect(e,i){this.assertActive();const r=_s(e)?new e(this.ctx,i):e(this.ctx,i);let n=!1;const s=typeof r=="function"?r:r.dispose.bind(r),o=X((...a)=>{if(!n)return n=!0,oi(this.disposables,o),s(...a)},"wrapped");return this.disposables.push(o),typeof r=="function"?o:(r.dispose=o,r)}collect(e,i){const r=Be(()=>(oi(this.disposables,r),i()),"name",e);return this.disposables.push(r),r}restart(){this.reset(),this.error=null,this.hasError=!1,this.status=0,this.start()}_getStatus(){return this.uid===null?4:this.hasError?3:this.tasks.size?1:this.ready?2:0}updateStatus(e){const i=this.status;e?.(),this.status=this._getStatus(),i!==this.status&&this.context.emit("internal/status",this,i)}ensure(e){const i=e().catch(r=>{this.context.emit(this.ctx,"internal/error",r),this.cancel(r)}).finally(()=>{this.updateStatus(()=>this.tasks.delete(i)),this.context.events._tasks.delete(i)});this.updateStatus(()=>this.tasks.add(i)),this.context.events._tasks.add(i)}cancel(e){this.error=e,this.updateStatus(()=>this.hasError=!0),this.reset()}get ready(){return Object.entries(this.runtime.inject).every(([e,i])=>!i.required||!Ie(this.ctx.get(e)))}reset(){this.isActive=!1,this.disposables=this.disposables.splice(0).filter(e=>{if(this.uid!==null&&e[Ze.static]===this)return!0;(async()=>e())().catch(i=>{this.context.emit(this.ctx,"internal/error",i)})})}init(e){this.config?this.start():this.cancel(e)}start(){if(!this.ready||this.isActive||this.uid===null)return!0;this.isActive=!0,this.updateStatus(()=>this.hasError=!1)}accept(...e){const r={keys:Array.isArray(e[0])?e.shift():null,callback:e[0],...e[1]};return this.effect(()=>(this.acceptors.push(r),r.immediate&&r.callback?.(this.config),()=>oi(this.acceptors,r)))}decline(e){return this.accept(e,()=>!0)}checkUpdate(e,i){if(i||!this.config)return[!0,!0];if(i===!1)return[!1,!1];const r=Object.create(null),n=X(l=>{const u=r[l]??(r[l]=!mi(this.config[l],e[l]));return o||(o=u),u},"checkPropertyUpdate"),s=new Set;let o=!1,a=!1,c=this.runtime.isReactive||null;for(const{keys:l,callback:u,passive:d}of this.acceptors){if(!l)c||(c=!d);else if(d)l?.forEach(p=>s.add(p));else{let p=!1;for(const h of l)p||(p=n(h));if(!p)continue}u?.(e)&&(a=!0)}for(const l in{...this.config,...e})if(c!==!1&&!(l in r)&&!s.has(l)){const u=n(l);c===null&&(a||(a=u))}return[o,a]}},X(tr,"EffectScope"),tr),Ja=(ir=class extends Is{constructor(i,r,n,s){super(i,n);j(this,"dispose");this.runtime=r,this.dispose=Be(i.scope.collect(`fork <${i.runtime.name}>`,()=>{this.uid=null,this.reset(),this.context.emit("internal/fork",this);const o=oi(r.disposables,this.dispose);return oi(r.children,this)&&!r.children.length&&i.registry.delete(r.plugin),o}),Ze.static,r),r.children.push(this),r.disposables.push(this.dispose),this.context.emit("internal/fork",this),this.init(s)}start(){if(super.start())return!0;for(const i of this.runtime.forkables)this.ensure(async()=>i(this.context,this._config))}update(i,r){const n=this.config,s=this.runtime.isForkable?this:this.runtime;if(s.config!==n)return;let o;try{o=cr(this.runtime.plugin,i)}catch(l){return this.context.emit("internal/error",l),this.cancel(l)}const[a,c]=s.checkUpdate(o,r);this.context.emit("internal/before-update",this,i),this.config=o,s.config=o,a&&this.context.emit("internal/update",this,n),c&&s.restart()}},X(ir,"ForkScope"),ir),Rs=(rr=class extends Is{constructor(i,r,n,s){super(i,n);j(this,"value");j(this,"runtime",this);j(this,"schema");j(this,"name");j(this,"inject",Object.create(null));j(this,"forkables",[]);j(this,"children",[]);j(this,"isReusable",!1);j(this,"isReactive",!1);j(this,"apply",X((i,r)=>{if(typeof this.plugin!="function")return this.plugin.apply(i,r);if(_s(this.plugin)){const n=new this.plugin(i,r),s=n[Ze.expose];return s&&i.set(s,n),n.fork&&this.forkables.push(n.fork.bind(n)),n}else return this.plugin(i,r)},"apply"));this.plugin=r,r?(this.setup(),this.init(s)):(this.name="root",this.isActive=!0)}get isForkable(){return this.forkables.length>0}fork(i,r,n){return new Ja(i,this,r,n)}dispose(){return this.uid=null,this.reset(),this.context.emit("internal/runtime",this),!0}setup(){const{name:i}=this.plugin;i&&i!=="apply"&&(this.name=i),this.schema=this.plugin.Config||this.plugin.schema,this.inject=xe.resolve(this.plugin.using||this.plugin.inject),this.isReusable=this.plugin.reusable,this.isReactive=this.plugin.reactive,this.context.emit("internal/runtime",this),this.isReusable&&this.forkables.push(this.apply)}reset(){super.reset();for(const i of this.children)i.reset()}start(){if(super.start())return!0;!this.isReusable&&this.plugin&&this.ensure(async()=>this.value=this.apply(this.ctx,this._config));for(const i of this.children)i.start()}update(i,r){if(this.isForkable){const l=new Error(`attempting to update forkable plugin "${this.plugin.name}", which may lead to unexpected behavior`);this.context.emit(this.ctx,"internal/warning",l)}const n=this.config;let s;try{s=cr(this.runtime.plugin||this.context.constructor,i)}catch(l){return this.context.emit("internal/error",l),this.cancel(l)}const[o,a]=this.checkUpdate(s,r),c=this.children.find(l=>l.config===n);this.config=s,c&&(this.context.emit("internal/before-update",c,i),c.config=s,o&&this.context.emit("internal/update",c,n)),a&&this.restart()}},X(rr,"MainScope"),rr);function Za(t){return t&&typeof t=="object"&&typeof t.apply=="function"}X(Za,"isApplicable");function xe(t){return function(e,i){if(i.kind==="class")e.inject=t;else if(i.kind==="method")i.addInitializer(function(){const r=this[U.tracker]?.property;if(!r)throw new Error("missing context tracker");this[r].inject(t,n=>{e.call(ur(this,{[r]:n}))})});else throw new Error("@Inject can only be used on class or class methods")}}X(xe,"Inject"),(t=>{function e(i){if(!i)return{};if(Array.isArray(i))return Object.fromEntries(i.map(o=>[o,{required:!0}]));const{required:r,optional:n,...s}=i;return Array.isArray(r)&&Object.assign(s,Object.fromEntries(r.map(o=>[o,{required:!0}]))),Array.isArray(n)&&Object.assign(s,Object.fromEntries(n.map(o=>[o,{required:!1}]))),s}t.resolve=e,X(e,"resolve")})(xe||(xe={}));var gh=(nr=class{constructor(e,i){j(this,"_counter",0);j(this,"_internal",new Map);j(this,"context");this.ctx=e,Be(this,U.tracker,{associate:"registry",property:"ctx"}),this.context=e;const r=new Rs(e,null,i);e.scope=r,r.ctx=e,this.set(null,r)}get counter(){return++this._counter}get size(){return this._internal.size}resolve(e,i=!1){if(e===null||typeof e=="function")return e;if(Za(e))return e.apply;if(i)throw new Error('invalid plugin, expect function or object with an "apply" method, received '+typeof e)}get(e){const i=this.resolve(e);return i&&this._internal.get(i)}has(e){const i=this.resolve(e);return!!i&&this._internal.has(i)}set(e,i){const r=this.resolve(e);this._internal.set(r,i)}delete(e){const i=this.resolve(e),r=i&&this._internal.get(i);if(r)return this._internal.delete(i),r.dispose(),r}keys(){return this._internal.keys()}values(){return this._internal.values()}entries(){return this._internal.entries()}forEach(e){return this._internal.forEach(e)}using(e,i){return this.inject(e,i)}inject(e,i){return this.plugin({inject:e,apply:i,name:i.name})}plugin(e,i,r){if(this.resolve(e,!0),this.ctx.scope.assertActive(),!r)try{i=cr(e,i)}catch(s){this.context.emit(this.ctx,"internal/error",s),r=s,i=null}let n=this.get(e);return n?(n.isForkable||this.context.emit(this.ctx,"internal/warning",new Error(`duplicate plugin detected: ${e.name}`)),n.fork(this.ctx,i,r)):(n=new Rs(this.ctx,e,i,r),this.set(e,n),n.fork(this.ctx,i,r))}},X(nr,"Registry"),nr),mh=gh,Ze=(Le=class{static is(e){return!!e?.[Le.is]}static associate(e,i){return e}constructor(e){e=cr(this.constructor,e),this[U.store]=Object.create(null),this[U.isolate]=Object.create(null),this[U.internal]=Object.create(null),this[U.intercept]=Object.create(null);const i=new Proxy(this,Ps.handler);i.root=i,i.reflect=new Ps(i),i.registry=new mh(i,e),i.lifecycle=new Ya(i);const r=X(n=>{if(n){r(Object.getPrototypeOf(n));for(const s of Object.getOwnPropertyNames(n)){const o=n[s].prototype?.constructor;o&&(i[n[s].key]=new o(i,e),Be(i[n[s].key],"ctx",i))}}},"attach");return r(this[U.internal]),i}[Symbol.for("nodejs.util.inspect.custom")](){return`Context <${this.name}>`}get name(){let e=this.runtime;for(;e&&!e.name;)e=e.parent.runtime;return e?.name}get events(){return this.lifecycle}get state(){return this.scope}extend(e={}){const i=Reflect.getOwnPropertyDescriptor(this,U.shadow)?.value,r=Object.assign(Object.create(It(this,this)),e);return i?Object.assign(Object.create(r),{[U.shadow]:i}):r}isolate(e,i){const r=Object.create(this[U.isolate]);return r[e]=i??Symbol(e),this.extend({[U.isolate]:r})}intercept(e,i){const r=Object.create(this[U.intercept]);return r[e]=i,this.extend({[U.intercept]:r})}},X(Le,"Context"),j(Le,"store",U.store),j(Le,"events",U.events),j(Le,"static",U.static),j(Le,"filter",U.filter),j(Le,"expose",U.expose),j(Le,"isolate",U.isolate),j(Le,"internal",U.internal),j(Le,"intercept",U.intercept),j(Le,"origin","ctx"),j(Le,"current","ctx"),Le.is[Symbol.toPrimitive]=()=>Symbol.for("cordis.is"),Le.prototype[Le.is]=!0,Le);Ze.prototype[Ze.internal]=Object.create(null);var ht=(ut=class{constructor(...e){j(this,"ctx");j(this,"name");j(this,"config");let i,r,n,s;Ze.is(e[0])?(i=e[0],typeof e[1]=="string"?(r=e[1],n=e[2]):s=e[1]):s=e[0],r??(r=this.constructor[U.provide]),n??(n=this.constructor[U.immediate]);let o=this;const a={associate:r,property:"ctx"};return o[U.invoke]&&(o=$s(r,xs(Object.getPrototypeOf(this),Function.prototype),a)),i?o.ctx=i:o[U.setup](),o.name=r,o.config=s,Be(o,U.tracker,a),o.ctx.provide(r),o.ctx.runtime.name=r,n&&(i?o[U.expose]=r:o.ctx.set(r,o)),o.ctx.on("ready",async()=>{await Promise.resolve(),await o.start(),n||o.ctx.set(r,o)}),o.ctx.on("dispose",()=>o.stop()),o}start(){}stop(){}[U.filter](e){return e[U.isolate][this.name]===this.ctx[U.isolate][this.name]}[U.setup](){this.ctx=new Ze}[U.extend](e){let i;return this[ut.invoke]?i=$s(this.name,this,this[U.tracker]):i=Object.create(this),Object.assign(i,e)}static[Symbol.hasInstance](e){let i=e.constructor;for(;i;){if(i=i.prototype?.constructor,i===this)return!0;i=Object.getPrototypeOf(i)}return!1}},X(ut,"Service"),j(ut,"setup",U.setup),j(ut,"invoke",U.invoke),j(ut,"extend",U.extend),j(ut,"tracker",U.tracker),j(ut,"provide",U.provide),j(ut,"immediate",U.immediate),ut),yh=Object.defineProperty,bh=Object.getOwnPropertyNames,re=(t,e)=>yh(t,"name",{value:e,configurable:!0}),vh=(t,e)=>function(){return e||(0,t[bh(t)[0]])((e={exports:{}}).exports,e),e.exports},wh=vh({"src/index.ts"(t,e){var P;var i=Symbol.for("schemastery"),r=Symbol.for("ValidationError");globalThis.__schemastery_index__??(globalThis.__schemastery_index__=0),globalThis.__schemastery_refs__=void 0;var n=(P=class extends TypeError{constructor(g,w){let S="$";for(const I of w.path||[])typeof I=="string"?S+="."+I:typeof I=="number"?S+="["+I+"]":typeof I=="symbol"&&(S+=`[Symbol(${I.toString()})]`);S.startsWith(".")&&(S=S.slice(1));super((S==="$"?"":`${S} `)+g);j(this,"name","ValidationError");this.options=w}static is(g){return!!g?.[r]}},re(P,"ValidationError"),P);Object.defineProperty(n.prototype,r,{value:!0});var s=re(function(b){const m=re(function(g,w={}){return s.resolve(g,m,w)[0]},"schema");if(b.refs){const g=Kt(b.refs,S=>new s(S)),w=re(S=>g[S],"getRef");for(const S in g){const I=g[S];I.sKey=w(I.sKey),I.inner=w(I.inner),I.list=I.list&&I.list.map(w),I.dict=I.dict&&Kt(I.dict,w)}return g[b.uid]}if(Object.assign(m,b),typeof m.callback=="string")try{m.callback=new Function("return "+m.callback)()}catch{}return Object.defineProperty(m,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(m,s.prototype),m.meta||(m.meta={}),m.toString=m.toString.bind(m),m},"Schema");s.prototype=Object.create(Function.prototype),s.prototype[i]=!0,s.ValidationError=n,s.prototype.toJSON=re(function(){var g,w;if(globalThis.__schemastery_refs__)return(g=globalThis.__schemastery_refs__)[w=this.uid]??(g[w]=JSON.parse(JSON.stringify({...this}))),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));const m={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,m},"toJSON"),s.prototype.set=re(function(m,g){return this.dict[m]=g,this},"set"),s.prototype.push=re(function(m){return this.list.push(m),this},"push");function o(b,m){const g=typeof b=="string"?{"":b}:{...b};for(const w in m){const S=m[w];S?.$description||S?.$desc?g[w]=S.$description||S.$desc:typeof S=="string"&&(g[w]=S)}return g}re(o,"mergeDesc");function a(b){return b?.$value??b?.$inner}re(a,"getInner");function c(b){return Ba(b??{},m=>!m.startsWith("$"))}re(c,"extractKeys"),s.prototype.i18n=re(function(m){const g=s(this),w=o(g.meta.description,m);return Object.keys(w).length&&(g.meta.description=w),g.dict&&(g.dict=Kt(g.dict,(S,I)=>S.i18n(Kt(m,F=>a(F)?.[I]??F?.[I])))),g.list&&(g.list=g.list.map((S,I)=>S.i18n(Kt(m,(F={})=>Array.isArray(a(F))?a(F)[I]:Array.isArray(F)?F[I]:c(F))))),g.inner&&(g.inner=g.inner.i18n(Kt(m,S=>a(S)?a(S):c(S)))),g.sKey&&(g.sKey=g.sKey.i18n(Kt(m,S=>S?.$key))),g},"i18n"),s.prototype.extra=re(function(m,g){const w=s(this);return w.meta={...w.meta,[m]:g},w},"extra");for(const b of["required","disabled","collapse","hidden","loose"])Object.assign(s.prototype,{[b](m=!0){const g=s(this);return g.meta={...g.meta,[b]:m},g}});s.prototype.deprecated=re(function(){var g;const m=s(this);return(g=m.meta).badges||(g.badges=[]),m.meta.badges.push({text:"deprecated",type:"danger"}),m},"deprecated"),s.prototype.experimental=re(function(){var g;const m=s(this);return(g=m.meta).badges||(g.badges=[]),m.meta.badges.push({text:"experimental",type:"warning"}),m},"experimental"),s.prototype.pattern=re(function(m){const g=s(this),w=Ha(m,["source","flags"]);return g.meta={...g.meta,pattern:w},g},"pattern"),s.prototype.simplify=re(function(m){if(mi(m,this.meta.default,this.type==="dict"))return null;if(Ie(m))return m;if(this.type==="object"||this.type==="dict"){const g={};for(const w in m){const I=(this.type==="object"?this.dict[w]:this.inner)?.simplify(m[w]);(this.type==="dict"||!Ie(I))&&(g[w]=I)}return mi(g,this.meta.default,this.type==="dict")?null:g}else if(this.type==="array"||this.type==="tuple"){const g=[];return m.forEach((w,S)=>{const I=this.type==="array"?this.inner:this.list[S],F=I?I.simplify(w):w;g.push(F)}),g}else if(this.type==="intersect"){const g={};for(const w of this.list)Object.assign(g,w.simplify(m));return g}else if(this.type==="union")for(const g of this.list)try{return s.resolve(m,g,{}),g.simplify(m)}catch{}return m},"simplify"),s.prototype.toString=re(function(m){return _[this.type]?.(this,m)??`Schema<${this.type}>`},"toString"),s.prototype.role=re(function(b,m){const g=s(this);return g.meta={...g.meta,role:b,extra:m},g},"role");for(const b of["default","link","comment","description","max","min","step"])Object.assign(s.prototype,{[b](m){const g=s(this);return g.meta={...g.meta,[b]:m},g}});var l={};s.extend=re(function(m,g){l[m]=g},"extend"),s.resolve=re(function(m,g,w={},S=!1){if(!g)return[m];if(w.ignore?.(m,g))return[m];if(Ie(m)&&g.type!=="lazy"){if(g.meta.required)throw new n("missing required value",w);let F=g,N=g.meta.default;for(;F?.type==="intersect"&&Ie(N);)F=F.list[0],N=F?.meta.default;if(Ie(N))return[m];m=Zr(N)}const I=l[g.type];if(!I)throw new n(`unsupported type "${g.type}"`,w);try{return I(m,g,w,S)}catch(F){if(!g.meta.loose)throw F;return[g.meta.default]}},"resolve"),s.from=re(function(m){if(Ie(m))return s.any();if(["string","number","boolean"].includes(typeof m))return s.const(m).required();if(m[i])return m;if(typeof m=="function")switch(m){case String:return s.string().required();case Number:return s.number().required();case Boolean:return s.boolean().required();case Function:return s.function().required();default:return s.is(m).required()}else throw new TypeError(`cannot infer schema from ${m}`)},"from"),s.lazy=re(function(m){const g=re(()=>(w.inner[i]||(w.inner=w.builder(),w.inner.meta={...w.meta,...w.inner.meta}),w.inner.toJSON()),"toJSON"),w=new s({type:"lazy",builder:m,inner:{toJSON:g}});return w},"lazy"),s.natural=re(function(){return s.number().step(1).min(0)},"natural"),s.percent=re(function(){return s.number().step(.01).min(0).max(1).role("slider")},"percent"),s.date=re(function(){return s.union([s.is(Date),s.transform(s.string().role("datetime"),(m,g)=>{const w=new Date(m);if(isNaN(+w))throw new n(`invalid date "${m}"`,g);return w},!0)])},"date"),s.regExp=re(function(m=""){return s.union([s.is(RegExp),s.transform(s.string().role("regexp",{flag:m}),(g,w)=>{try{return new RegExp(g,m)}catch(S){throw new n(S.message,w)}},!0)])},"regExp"),s.arrayBuffer=re(function(m){return s.union([s.is(ArrayBuffer),s.is(SharedArrayBuffer),s.transform(s.any(),(g,w)=>{if(Ct.isSource(g))return Ct.fromSource(g);throw new n(`expected ArrayBufferSource but got ${g}`,w)},!0),...m?[s.transform(s.string(),(g,w)=>{try{return m==="base64"?Ct.fromBase64(g):Ct.fromHex(g)}catch(S){throw new n(S.message,w)}},!0)]:[]])},"arrayBuffer"),s.extend("lazy",(b,m,g,w)=>(m.inner[i]||(m.inner=m.builder(),m.inner.meta={...m.meta,...m.inner.meta}),s.resolve(b,m.inner,g,w))),s.extend("any",b=>[b]),s.extend("never",(b,m,g)=>{throw new n(`expected nullable but got ${b}`,g)}),s.extend("const",(b,{value:m},g)=>{if(mi(b,m))return[m];throw new n(`expected ${m} but got ${b}`,g)});function u(b,m,g,w,S=!1){const{max:I=1/0,min:F=-1/0}=m;if(b>I)throw new n(`expected ${g} <= ${I} but got ${b}`,w);if(b<F&&!S)throw new n(`expected ${g} >= ${F} but got ${b}`,w)}re(u,"checkWithinRange"),s.extend("string",(b,{meta:m},g)=>{if(typeof b!="string")throw new n(`expected string but got ${b}`,g);if(m.pattern){const w=new RegExp(m.pattern.source,m.pattern.flags);if(!w.test(b))throw new n(`expect string to match regexp ${w}`,g)}return u(b.length,m,"string length",g),[b]});function d(b,m){const g=b.toString();if(g.includes("e"))return b*Math.pow(10,m);const w=g.indexOf(".");if(w===-1)return b*Math.pow(10,m);const S=g.slice(w+1),I=g.slice(0,w);return S.length<=m?+(I+S.padEnd(m,"0")):+(I+S.slice(0,m)+"."+S.slice(m))}re(d,"decimalShift");function y(b,m,g){if(g=Math.abs(g),!/^\d+\.\d+$/.test(g.toString()))return(b-m)%g===0;const w=g.toString().indexOf("."),S=g.toString().slice(w+1).length;return Math.abs(d(b,S)-d(m,S))%d(g,S)===0}re(y,"isMultipleOf"),s.extend("number",(b,{meta:m},g)=>{if(typeof b!="number")throw new n(`expected number but got ${b}`,g);u(b,m,"number",g);const{step:w}=m;if(w&&!y(b,m.min??0,w))throw new n(`expected number multiple of ${w} but got ${b}`,g);return[b]}),s.extend("boolean",(b,m,g)=>{if(typeof b=="boolean")return[b];throw new n(`expected boolean but got ${b}`,g)}),s.extend("bitset",(b,{bits:m,meta:g},w)=>{let S=0,I=[];if(typeof b=="number"){S=b;for(const F in m)b&m[F]&&I.push(F)}else if(Array.isArray(b)){I=b;for(const F of I){if(typeof F!="string")throw new n(`expected string but got ${F}`,w);F in m&&(S|=m[F])}}else throw new n(`expected number or array but got ${b}`,w);return S===g.default?[S]:[S,I]}),s.extend("function",(b,m,g)=>{if(typeof b=="function")return[b];throw new n(`expected function but got ${b}`,g)}),s.extend("is",(b,{constructor:m},g)=>{if(typeof m=="function"){if(b instanceof m)return[b];throw new n(`expected ${m.name} but got ${b}`,g)}else{if(Ie(b))throw new n(`expected ${m} but got ${b}`,g);let w=Object.getPrototypeOf(b);for(;w;){if(w.constructor?.name===m)return[b];w=Object.getPrototypeOf(w)}throw new n(`expected ${m} but got ${b}`,g)}});function p(b,m,g,w){try{const[S,I]=s.resolve(b[m],g,{...w,path:[...w.path||[],m]});return I!==void 0&&(b[m]=I),S}catch(S){if(!w?.autofix)throw S;return delete b[m],g.meta.default}}re(p,"property"),s.extend("array",(b,{inner:m,meta:g},w)=>{if(!Array.isArray(b))throw new n(`expected array but got ${b}`,w);return u(b.length,g,"array length",w,!Ie(m.meta.default)),[b.map((S,I)=>p(b,I,m,w))]}),s.extend("dict",(b,{inner:m,sKey:g},w,S)=>{if(!Jr(b))throw new n(`expected object but got ${b}`,w);const I={};for(const F in b){let N;try{N=s.resolve(F,g,w)[0]}catch(G){if(S)continue;throw G}I[N]=p(b,F,m,w),b[N]=b[F],F!==N&&delete b[F]}return[I]}),s.extend("tuple",(b,{list:m},g,w)=>{if(!Array.isArray(b))throw new n(`expected array but got ${b}`,g);const S=m.map((I,F)=>p(b,F,I,g));return w?[S]:(S.push(...b.slice(m.length)),[S])});function h(b,m){for(const g in m)g in b||(b[g]=m[g])}re(h,"merge"),s.extend("object",(b,{dict:m},g,w)=>{if(!Jr(b))throw new n(`expected object but got ${b}`,g);const S={};for(const I in m){const F=p(b,I,m[I],g);(!Ie(F)||I in b)&&(S[I]=F)}return w||h(S,b),[S]}),s.extend("union",(b,{list:m,toString:g},w,S)=>{for(const I of m)try{return s.resolve(b,I,w,S)}catch{}throw new n(`expected ${g()} but got ${JSON.stringify(b)}`,w)}),s.extend("intersect",(b,{list:m,toString:g},w,S)=>{if(!m.length)return[b];let I;for(const F of m){const N=s.resolve(b,F,w,!0)[0];if(!Ie(N))if(Ie(I))I=N;else{if(typeof I!=typeof N)throw new n(`expected ${g()} but got ${JSON.stringify(b)}`,w);if(typeof N=="object")h(I??(I={}),N);else if(I!==N)throw new n(`expected ${g()} but got ${JSON.stringify(b)}`,w)}}return!S&&Jr(b)&&h(I,b),[I]}),s.extend("transform",(b,{inner:m,callback:g,preserve:w},S)=>{const[I,F=b]=s.resolve(b,m,S,!0);return w?[g(I)]:[g(I),g(F)]});var _={};function k(b,m,g){_[b]=g,Object.assign(s,{[b](...w){const S=new s({type:b});return m.forEach((I,F)=>{switch(I){case"sKey":S.sKey=w[F]??s.string();break;case"inner":S.inner=s.from(w[F]);break;case"list":S.list=w[F].map(s.from);break;case"dict":S.dict=Kt(w[F],s.from);break;case"bits":{S.bits={};for(const N in w[F])typeof w[F][N]=="number"&&(S.bits[N]=w[F][N]);break}case"callback":{const N=S.callback=w[F];N.toJSON||(N.toJSON=()=>N.toString());break}case"constructor":{const N=S.constructor=w[F];typeof N=="function"&&(N.toJSON||(N.toJSON=()=>N.name));break}default:S[I]=w[F]}}),b==="object"||b==="dict"?S.meta.default={}:b==="array"||b==="tuple"?S.meta.default=[]:b==="bitset"&&(S.meta.default=0),S}})}re(k,"defineMethod"),k("is",["constructor"],({constructor:b})=>typeof b=="function"?b.name:b),k("any",[],()=>"any"),k("never",[],()=>"never"),k("const",["value"],({value:b})=>typeof b=="string"?JSON.stringify(b):b),k("string",[],()=>"string"),k("number",[],()=>"number"),k("boolean",[],()=>"boolean"),k("bitset",["bits"],()=>"bitset"),k("function",[],()=>"function"),k("array",["inner"],({inner:b})=>`${b.toString(!0)}[]`),k("dict",["inner","sKey"],({inner:b,sKey:m})=>`{ [key: ${m.toString()}]: ${b.toString()} }`),k("tuple",["list"],({list:b})=>`[${b.map(m=>m.toString()).join(", ")}]`),k("object",["dict"],({dict:b})=>Object.keys(b).length===0?"{}":`{ ${Object.entries(b).map(([m,g])=>`${m}${g.meta.required?"":"?"}: ${g.toString()}`).join(", ")} }`),k("union",["list"],({list:b},m)=>{const g=b.map(({toString:w})=>w()).join(" | ");return m?`(${g})`:g}),k("intersect",["list"],({list:b})=>`${b.map(m=>m.toString(!0)).join(" & ")}`),k("transform",["inner","callback","preserve"],({inner:b},m)=>b.toString(m)),e.exports=s}});const R=wh();var As=(t=>(t[t.debug=-1]="debug",t[t.log=0]="log",t[t.info=1]="info",t[t.warn=2]="warn",t[t.error=3]="error",t[t.silent=4]="silent",t))(As||{});const Ts=globalThis||window,Os=Symbol.for("__IPE_LOGGER_COLOR_MAP__");Ts[Os]||(Ts[Os]=new Map);const Ls=Ts[Os];function rn(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i),e=(e>>>0)*16777619;return e>>>0}const el=[[350,360],[0,15],[15,30],[200,230],[230,250],[250,280],[280,310],[310,330],[140,160],[160,180]];function _h(t,e){const i=el.length,r=rn(t)%i,[n,s]=el[r],o=s-n,a=rn(t+":"+e),c=n+a%(o||1),l=rn(t+":s"),u=rn(t+":l");let d,y;if(e==="name")d=62+l%18,y=30+u%12;else{const p=c>=0&&c<50||c>330&&c<360,h=c>=200&&c<=300;d=55+l%20,h?y=55+u%8:p?y=48+u%6:y=50+u%8,d<60&&(d+=5)}return`hsl(${c}, ${d}%, ${y}%)`}function nn(t,e){if(e)return Ls.set(t,e),e;const i=Ls.get(t);if(i)return i;const r=t.startsWith("name:")?"name":"group",n=_h(t,r);return Ls.set(t,n),n}let tl=class Ff{constructor(e={}){this._custom=i=>{if(!this._enabled(i.level))return il;const[r,n]=this._prefix(i.label);return this._consoleMethod(i.method).bind(console,r,...n)},this._name=e.name,this._nameColor=e.color,this._groupPath=e._groupPath?[...e._groupPath]:[],this._dynamicLevels={...e._dynamicLevels},this._levelRef=e._levelRef??{value:e.level??1},this._name&&nn(`name:${this._name}`,this._nameColor),this._installBuiltinLevels();for(const i of Object.keys(this._dynamicLevels))this._installLevelGetter(i,this._dynamicLevels[i]);return kh(this)}get level(){return this._levelRef.value}set level(e){this._levelRef.value=e}group(e,i){return e&&nn(`group:${e}`,i?.color),new Ff({name:this._name,color:this._nameColor,_groupPath:[...this._groupPath,e],_dynamicLevels:this._dynamicLevels,_levelRef:this._levelRef})}defineLevel(e,i){this._dynamicLevels[e]={...i},this._installLevelGetter(e,i)}get debug(){return this._method("debug")}get log(){return this._method("log")}get info(){return this._method("info")}get warn(){return this._method("warn")}get error(){return this._method("error")}_installBuiltinLevels(){}_installLevelGetter(e,i){Object.defineProperty(this,e,{configurable:!0,enumerable:!1,get:()=>this._custom(i)})}_method(e){const i=xh[e];if(!this._enabled(i.level))return il;const[r,n]=this._prefix(i.label);return this._consoleMethod(e).bind(console,r,...n)}_consoleMethod(e){return(console[e]||console.log).bind(console)}_enabled(e){return e>=this._levelRef.value&&this._levelRef.value!==4}_prefix(e){const i=[];let r="";if(this._name){const n=nn(`name:${this._name}`,this._nameColor);r+=`%c${this._name}%c`,i.push(`background:${n}; color:#fff; padding:1px 4px; border-radius:2px; font-weight:700;`,rl)}if(e&&(r+=` ${e}`),this._groupPath.length){const n=this._groupPath.join("/"),s=nn(`group:${n}`);r+=` %c${n}%c`,i.push(`color:${s}; text-decoration: underline;`,rl)}return[r,i]}};const il=()=>{},rl="color:inherit; background:transparent; text-decoration:none;",xh={debug:{level:-1,label:"",method:"debug"},log:{level:0,label:"",method:"log"},info:{level:1,label:"[I]",method:"info"},warn:{level:2,label:"[W]",method:"warn"},error:{level:3,label:"[E]",method:"error"}};function kh(t){const e=function(i,r){return t.group(i,r)};return new Proxy(e,{get(i,r,n){return t[r]},set(i,r,n){return t[r]=n,!0},apply(i,r,n){return t.group(n[0],n[1])},has(i,r){return r in t}})}function nl(t){return new tl(t)}function Ns(t){if(typeof globalThis.structuredClone=="function")try{return globalThis.structuredClone(t)}catch{}return Mi(t,new WeakMap)}function Mi(t,e){if(typeof t!="object"||t===null)return t;const i=e.get(t);if(i)return i;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t.source,t.flags);if(t instanceof URL)return new URL(t.toString());if(t instanceof URLSearchParams)return new URLSearchParams(t.toString());if(t instanceof ArrayBuffer)return t.slice(0);if(ArrayBuffer.isView(t)){if(t instanceof DataView)return new DataView(t.buffer.slice(0),t.byteOffset,t.byteLength);const o=t,a=o.constructor;return new a(o.buffer.slice(0),o.byteOffset,o.length)}if(t instanceof Map){const o=new Map;return e.set(t,o),t.forEach((a,c)=>{o.set(Mi(c,e),Mi(a,e))}),o}if(t instanceof Set){const o=new Set;return e.set(t,o),t.forEach(a=>o.add(Mi(a,e))),o}if(Array.isArray(t)){const o=new Array(t.length);e.set(t,o);for(let a=0;a<o.length;a++)o[a]=Mi(t[a],e);return o}const r=Object.getPrototypeOf(t),n=Object.create(r);e.set(t,n);const s=Object.getOwnPropertyDescriptors(t);for(const o of Reflect.ownKeys(s)){const a=s[o];"value"in a&&(a.value=Mi(a.value,e)),Object.defineProperty(n,o,a)}return n}function Vt(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}const sl=function(t){const e=this.constructor.prototype,i=Reflect.get(e,t,e);function r(...n){return Reflect.apply(i,r,n)}Reflect.setPrototypeOf(r,e);for(const n of Reflect.ownKeys(i)){const s=Reflect.getOwnPropertyDescriptor(i,n);s&&Reflect.defineProperty(r,n,s)}return r};sl.prototype=Object.create(Function.prototype);const Sh=sl;function Rt(t,...e){const i=Ns(t||{});for(const r of e)if(r!=null)for(const n of Reflect.ownKeys(r)){const s=r[n];if(typeof s>"u")continue;if(s===null){delete i[n];continue}const o=i[n];Vt(o)&&Vt(s)?i[n]=Rt(o,s):i[n]=Ns(s)}return i}var ot=(t=>(t.BODY_USED="BODY_USED",t.NO_BODY_READER="NO_BODY_READER",t.TIMEOUT="TIMEOUT",t.NETWORK_ERROR="NETWORK_ERROR",t.BODY_NOT_ALLOWED="BODY_NOT_ALLOWED",t.HOOK_CONTEXT_CHANGED="HOOK_CONTEXT_CHANGED",t.ABORTED_BY_HOOK="ABORTED_BY_HOOK",t.INVALID_HOOK_CALLBACK="INVALID_HOOK_CALLBACK",t.UNEXPECTED_HOOK_RETURN="UNEXPECTED_HOOK_RETURN",t.UNSUPPORTED_RESPONSE_TYPE="UNSUPPORTED_RESPONSE_TYPE",t.FEATURE_MOVED_TO_PLUGIN="FEATURE_MOVED_TO_PLUGIN",t.BODY_TRANSFORM_ERROR="BODY_TRANSFORM_ERROR",t))(ot||{});class Ve extends Error{constructor(i,r,n,s){super(r,s);j(this,"name","FexiosError");this.code=i,this.context=n}static is(i,r){return!(i instanceof Ve)||i instanceof sn?!1:r?i.code===r:!0}}class sn extends Ve{constructor(i,r,n){super(r.statusText,i,void 0,n);j(this,"name","FexiosResponseError");this.response=r}static is(i){return i instanceof sn}}var pt;(t=>{t.makeSearchParams=r=>{if(!r)return new URLSearchParams;if(r instanceof URLSearchParams)return r;if(typeof r!="object"||r?.constructor!==Object)throw new TypeError("only plain object is supported");const n=new URLSearchParams,s=(c,l)=>{l!=null&&n.append(c,l)},o=(c,l)=>{l!=null&&n.set(c,l)},a=(c,l)=>{if(l!=null){if(Array.isArray(l)){for(const u of l)s(c,u?.toString());return}if(typeof l=="object"&&l.constructor===Object){for(const[u,d]of Object.entries(l)){if(d==null)continue;const y=u.endsWith("[]"),p=y?u.slice(0,-2):u,h=`${c}[${p}]`;if(y){const _=`${h}[]`;if(Array.isArray(d))for(const k of d)s(_,k?.toString());else typeof d=="object"&&d!==null&&d.constructor===Object?a(`${h}[]`,d):s(_,d?.toString())}else if(Array.isArray(d))for(const _ of d)s(h,_?.toString());else typeof d=="object"&&d!==null&&d.constructor===Object?a(h,d):o(h,d?.toString())}return}o(c,l?.toString())}};for(const[c,l]of Object.entries(r))a(c,l);return n},t.makeQueryString=r=>(0,t.makeSearchParams)(r).toString(),t.makeURL=(r,n,s,o)=>{const a=typeof window<"u"&&window.location?.origin||"http://localhost",c=typeof r=="string"?new URL(r,o??a):new URL(r),l=(0,t.toQueryRecord)(c.searchParams),u=(0,t.mergeQueries)(l,n||{}),d=(0,t.makeSearchParams)(u);return c.search=d.toString(),typeof s<"u"&&(c.hash=s),c},t.toQueryRecord=r=>{typeof r=="string"&&(r=(0,t.fromString)(r));const n={},s=a=>{if(!a.includes("["))return{path:[a],forceArray:!1};const l=[a.slice(0,a.indexOf("["))],u=/\[([^\]]*)\]/g;let d,y=!1,p=!1;for(;d=u.exec(a);)d[1]===""?(y=!0,p=!0):(l.push(d[1]),p=!1);return y&&p&&(l[l.length-1]=l[l.length-1]+"[]"),{path:l,forceArray:y}},o=(a,c,l,u)=>{let d=a;for(let y=0;y<c.length;y++){const p=c[y];y===c.length-1?u?d[p]===void 0?d[p]=[l]:Array.isArray(d[p])?d[p].push(l):d[p]=[d[p],l]:d[p]===void 0?d[p]=l:Array.isArray(d[p])?d[p].push(l):d[p]=[d[p],l]:((d[p]===void 0||typeof d[p]!="object"||Array.isArray(d[p]))&&(d[p]={}),d=d[p])}};for(const[a,c]of r.entries()){const{path:l,forceArray:u}=s(String(a));o(n,l,c?.toString(),u)}return n},t.fromString=r=>{const n=r.trim();if(!n)return new URLSearchParams;if(n.startsWith("?"))return new URLSearchParams(n.slice(1));const s=n.indexOf("?");if(s>=0){const o=n.indexOf("#",s+1),a=n.slice(s+1,o>=0?o:void 0);return new URLSearchParams(a)}return new URLSearchParams(n)},t.mergeQueries=(...r)=>{const n={};for(const s of r)s!=null&&i(n,e(s));return n};function e(r){if(!r)return{};if(r instanceof URLSearchParams||r instanceof FormData||r instanceof Map)return(0,t.toQueryRecord)(r);if(typeof r=="string")return(0,t.toQueryRecord)((0,t.fromString)(r));if(Vt(r))return r;throw new TypeError(`unsupported type transformation, got: ${Object.prototype.toString.call(r)}`)}function i(r,n){for(const[s,o]of Object.entries(n)){if(o===void 0)continue;if(o===null){delete r[s];continue}const a=r[s];Vt(a)&&Vt(o)?i(a,o):r[s]=Ns(o)}}})(pt||(pt={}));class Eh{constructor(e,i,r){j(this,"ok");j(this,"status");j(this,"statusText");j(this,"headers");j(this,"url");j(this,"redirected");this.rawResponse=e,this.data=i,this.responseType=r,["ok","status","statusText","headers","url","redirected"].forEach(n=>{Reflect.defineProperty(this,n,{get:()=>e[n]})})}}const ol=t=>{const e=t.reduce((n,s)=>n+s.length,0),i=new Uint8Array(e);let r=0;for(const n of t)i.set(n,r),r+=n.length;return i};async function $h(t,e,i){const r=t.getReader();if(!r)throw new Ve(ot.NO_BODY_READER,"Failed to get ReadableStream from response body");const n=[];let s=0;try{for(;;){const{done:a,value:c}=await r.read();if(a)break;n.push(c),s+=c.length,i&&e>0&&i(s/e,ol(n))}}finally{r.releaseLock?.()}const o=ol(n);return i?.(1,o),o}const Ph=t=>{if(t){if(t.includes("application/json")||t.endsWith("+json"))return"json";if(t.startsWith("text/"))return"text";if(t.includes("multipart/form-data")||t.includes("application/x-www-form-urlencoded"))return"form";if(/^image\//.test(t)||/^video\//.test(t)||/^audio\//.test(t)||t.includes("application/pdf"))return"blob";if(t.includes("application/octet-stream")||t.includes("application/zip")||t.includes("application/x-tar")||t.includes("application/x-7z-compressed")||t.includes("application/x-gzip"))return"arrayBuffer"}};async function al(t,e,i,r,n){const s=t.clone(),o=t.headers.get("content-type")?.toLowerCase()??"",a=t.headers.get("content-length"),c=a?Number(a):0,l=t.headers.get("upgrade")?.toLowerCase(),u=t.headers.get("connection")?.toLowerCase();if(e==="ws"||e==="stream")throw new Ve(ot.FEATURE_MOVED_TO_PLUGIN,`responseType "${String(e)}" has been moved to plugins. Use "fexios/plugins" (fx.plugin(pluginWebSocket) / fx.plugin(pluginSSE)) and call fx.ws()/fx.sse() instead.`);if(l==="websocket"&&u==="upgrade")throw new Ve(ot.FEATURE_MOVED_TO_PLUGIN,'WebSocket upgrade response detected. WebSocket support has been moved to plugins. Please use "fexios/plugins" and call fx.ws().');if(o.includes("text/event-stream"))throw new Ve(ot.FEATURE_MOVED_TO_PLUGIN,'SSE (text/event-stream) response detected. SSE support has been moved to plugins. Please use "fexios/plugins" and call fx.sse().');let d=e??Ph(o)??"text";const y=/\bcharset=([^;]+)/i.exec(o)?.[1]?.trim()||"utf-8",p=new TextDecoder(y);let h;try{if(d==="form")h=await s.formData();else{const P=await $h(s.body,c,i);if(d==="arrayBuffer")h=P.buffer.slice(P.byteOffset,P.byteOffset+P.byteLength);else if(d==="blob")h=new Blob([P],{type:o||"application/octet-stream"});else if(d==="text"){const b=p.decode(P);if(e)h=b;else{const m=b.trim();if(m.startsWith("{")&&m.endsWith("}")||m.startsWith("[")&&m.endsWith("]"))try{h=JSON.parse(m),d="json"}catch{h=b}else h=b}}else if(d==="json"){const b=p.decode(P);h=b.length?JSON.parse(b):null}else h=P}}catch(P){if(!(P instanceof Error))throw P;try{h=await s.text(),d="text"}catch{throw new Ve(ot.BODY_TRANSFORM_ERROR,`Failed to transform response body to ${d}`,void 0,{cause:P})}}const _=new Eh(t,h,d),k=r?.(_);if(typeof k=="boolean"?k:!_.ok)throw new sn(_.statusText,_);return _}var dr;(t=>{t.makeHeaders=e=>{if(!e)return new Headers;if(e instanceof Headers)return new Headers(e);const i=new Headers;if(e instanceof Map){for(const[r,n]of e.entries())if(n!=null)if(Array.isArray(n))for(const s of n)s!=null&&i.append(r,String(s));else i.append(r,String(n));return i}if(Vt(e)){for(const[r,n]of Object.entries(e))if(n!=null)if(Array.isArray(n))for(const s of n)s!=null&&i.append(r,String(s));else i.append(r,String(n));return i}throw new TypeError("only plain object, Map/ReadonlyMap, or Headers is supported")},t.toHeaderRecord=e=>{if(e instanceof Headers){const i={};return e.forEach((r,n)=>{i[n]=i[n]?[...i[n],r]:[r]}),i}if(e instanceof Map){const i={};for(const[r,n]of e.entries())if(n!=null)if(Array.isArray(n)){const s=n.filter(o=>o!=null).map(o=>String(o));s.length&&(i[r]=(i[r]??[]).concat(s))}else{const s=String(n);i[r]=i[r]?[...i[r],s]:[s]}return i}throw new TypeError(`unsupported type transformation, got: ${Object.prototype.toString.call(e)}`)},t.mergeHeaders=(...e)=>{const i=new Headers,r=n=>{for(const[s,o]of Object.entries(n))if(o!==void 0){if(o===null){i.delete(s);continue}if(Array.isArray(o)){i.delete(s);for(const a of o)a!=null&&i.append(s,String(a))}else i.set(s,String(o))}};for(const n of e){if(n==null)continue;if(n instanceof Headers){n.forEach((o,a)=>{i.set(a,o)});continue}if(Vt(n)){r(n);continue}const s=(0,t.toHeaderRecord)(n);for(const[o,a]of Object.entries(s)){i.delete(o);for(const c of a)i.append(o,c)}}return i}})(dr||(dr={}));const $e=class $e extends Sh{constructor(i={}){super("request");j(this,"baseConfigs");j(this,"hooks",[]);j(this,"mergeQueries",pt.mergeQueries);j(this,"mergeHeaders",dr.mergeHeaders);j(this,"interceptors",{request:this.createInterceptor("beforeRequest"),response:this.createInterceptor("afterResponse")});j(this,"create",$e.create);j(this,"_plugins",new Map);j(this,"mergeQuery",this.mergeQueries);this.baseConfigs=Rt($e.DEFAULT_CONFIGS,i),$e.ALL_METHODS.forEach(r=>this.createMethodShortcut(r.toLowerCase()))}get defaults(){return this.baseConfigs}set defaults(i){this.baseConfigs=i}attachLegacyAliases(i){const r=()=>i.request,n=()=>i.runtime,s=(o,a)=>{try{Object.defineProperty(i,o,{configurable:!0,...a})}catch{}};s("url",{get:()=>r().url,set:o=>{r().url=o?.toString?.()??String(o)}}),s("method",{get:()=>r().method,set:o=>r().method=o}),s("headers",{get:()=>r().headers,set:o=>r().headers=o}),s("query",{get:()=>r().query,set:o=>r().query=o}),s("body",{get:()=>r().body,set:o=>r().body=o}),s("baseURL",{get:()=>r().baseURL,set:o=>r().baseURL=o}),s("timeout",{get:()=>r().timeout,set:o=>r().timeout=o}),s("credentials",{get:()=>r().credentials,set:o=>r().credentials=o}),s("cache",{get:()=>r().cache,set:o=>r().cache=o}),s("mode",{get:()=>r().mode,set:o=>r().mode=o}),s("fetch",{get:()=>r().fetch,set:o=>r().fetch=o}),s("shouldThrow",{get:()=>r().shouldThrow,set:o=>r().shouldThrow=o}),s("responseType",{get:()=>r().responseType,set:o=>r().responseType=o}),s("abortController",{get:()=>n().abortController,set:o=>n().abortController=o}),s("onProgress",{get:()=>n().onProgress,set:o=>n().onProgress=o}),s("customEnv",{get:()=>n().customEnv,set:o=>n().customEnv=o}),s("rawRequest",{get:()=>r().rawRequest,set:o=>r().rawRequest=o}),s("data",{get:()=>i.response?i.response.data:void 0,set:o=>{i.response&&(i.response.data=o)}})}finalizeContext(i,r){const n=i.response,s=n?.rawResponse??i.rawResponse,o=i.request;Object.defineProperties(i,{url:{get:()=>s?.url||r},data:{get:()=>n.data},headers:{get:()=>s.headers},responseType:{get:()=>n.responseType},rawRequest:{get:()=>o.rawRequest}})}async request(i,r){const n=this;let s=r||{};typeof i=="string"||i instanceof URL?s={...r||{},url:i}:typeof i=="object"&&(s=i);const{abortController:o,onProgress:a,customEnv:c,...l}=s;let u={get app(){return n},request:{...l,url:s.url?.toString?.()??String(s.url)},runtime:{abortController:o,onProgress:a,customEnv:c},response:void 0,rawResponse:void 0,url:"",headers:{},query:{}};if(this.attachLegacyAliases(u),u=await this.emit("beforeInit",u),u[$e.FINAL_SYMBOL])return u;if("customEnv"in this.baseConfigs&&(u.runtime.customEnv=Rt({},this.baseConfigs.customEnv,u.runtime.customEnv)),u.request=this.applyDefaults(u.request),$e.METHODS_WITHOUT_BODY.includes(u.request.method?.toLocaleLowerCase?.())&&u.request.body)throw new Ve(ot.BODY_NOT_ALLOWED,`Request method "${u.request.method}" does not allow body`);if(u=await this.emit("beforeRequest",u),u[$e.FINAL_SYMBOL])return u;let d;const y={},p=u.request;if(typeof p.body<"u"&&p.body!==null&&(p.body instanceof Blob||p.body instanceof FormData||p.body instanceof URLSearchParams?d=p.body:typeof p.body=="object"&&p.body!==null?(d=JSON.stringify(p.body),p.headers=this.mergeHeaders(p.headers,{"Content-Type":"application/json"})):d=p.body),!dr.makeHeaders(p.headers||{}).get("content-type")&&d&&(d instanceof FormData||d instanceof URLSearchParams?y["content-type"]=null:typeof d=="string"&&typeof p.body=="object"?y["content-type"]="application/json":d instanceof Blob&&(y["content-type"]=d.type||"application/octet-stream")),p.body=d,u=await this.emit("afterBodyTransformed",u),u[$e.FINAL_SYMBOL])return u;const _=u.runtime.abortController??(globalThis.AbortController?new AbortController:void 0),k=globalThis.location?.href||"http://localhost",P=new URL(u.request.baseURL||this.baseConfigs.baseURL||k,k),b=new URL(u.request.url,P),m=pt.makeURL(b,u.request.query,b.hash).toString(),g=new Request(m,{method:u.request.method||"GET",credentials:u.request.credentials,cache:u.request.cache,mode:u.request.mode,headers:dr.mergeHeaders(this.baseConfigs.headers,u.request.headers||{},y),body:u.request.body,signal:_?.signal});if(u.request.rawRequest=g,u=await this.emit("beforeActualFetch",u),u[$e.FINAL_SYMBOL])return u;const w=u.request.timeout??this.baseConfigs.timeout??60*1e3,S=u.request.shouldThrow??this.baseConfigs.shouldThrow;if(u.request.url.startsWith("ws")||u.request.responseType==="ws")throw new Ve(ot.FEATURE_MOVED_TO_PLUGIN,'WebSocket support has been moved to plugins. Use "fexios/plugins" and call fx.ws() instead.',u);if(u.request.responseType==="stream")throw new Ve(ot.FEATURE_MOVED_TO_PLUGIN,'SSE support has been moved to plugins. Use "fexios/plugins" and call fx.sse() instead.',u);let I;try{_&&(I=w>0?setTimeout(()=>{_.abort()},w):void 0);const N=await(u.request.fetch||this.baseConfigs.fetch||globalThis.fetch)(u.request.rawRequest).catch(G=>{throw I&&clearTimeout(I),_?.signal.aborted?new Ve(ot.TIMEOUT,`Request timed out after ${w}ms`,u):new Ve(ot.NETWORK_ERROR,G.message,u)});return I&&clearTimeout(I),u.rawResponse=N,await this.emit("afterRawResponse",u),u[$e.FINAL_SYMBOL]?u:(u.response=await al(N,u.request.responseType,(G,K)=>{u.runtime.onProgress?.(G,K)},S,w),u.rawResponse=u.response.rawResponse,this.finalizeContext(u,m),this.emit("afterResponse",u))}catch(F){throw I&&clearTimeout(I),F}}applyDefaults(i){const r=i,n=globalThis.location?.href||"http://localhost",s=r.baseURL||this.baseConfigs.baseURL||n,o=new URL(s,n),a=new URL(r.url.toString(),o),c=pt.toQueryRecord(o.searchParams),l=pt.toQueryRecord(a.searchParams),u=pt.mergeQueries(c,l);a.search=pt.makeSearchParams(u).toString(),r.url=a.toString();const d=pt.mergeQueries(this.baseConfigs.query,r.query);return r.query&&this.restoreNulls(d,r.query),r.query=d,r}restoreNulls(i,r){if(!(!r||typeof r!="object"))for(const[n,s]of Object.entries(r))s===null?i[n]=null:Vt(s)&&((!i[n]||typeof i[n]!="object")&&(i[n]={}),this.restoreNulls(i[n],s))}async emit(i,r,n={shouldHandleShortCircuitResponse:!0}){const s=this.hooks.filter(a=>a.event===i);if(s.length===0)return r;const o=async(a,c)=>{const l=a;if(l.rawResponse=c,!l.request?.rawRequest)try{l.request.rawRequest=new Request(l.request.url,{method:l.request.method||"GET",headers:l.request.headers,body:l.request.body})}catch{}const u=await al(c,a.request?.responseType,(d,y)=>a.runtime?.onProgress?.(d,y),a.request?.shouldThrow??this.baseConfigs.shouldThrow,a.request?.timeout??this.baseConfigs.timeout??60*1e3);if(l.response=u,l.rawResponse=u.rawResponse,this.finalizeContext(l,c.url||""),i!=="afterResponse"){const d=await this.emit("afterResponse",l);return d[$e.FINAL_SYMBOL]=!0,d}else return l[$e.FINAL_SYMBOL]=!0,l};for(let a=0;a<s.length;a++){const c=s[a],l=`${String(i)}#${c.action.name||`anonymous#${a}`}`,u=Symbol("FEXIOS_HOOK_CTX_MARK");try{r[u]=u}catch{}const d=await c.action.call(this,r);try{delete r[u]}catch{}if(d===!1)throw new Ve(ot.ABORTED_BY_HOOK,`Request aborted by hook "${l}"`,r);if(d instanceof Response){if(n.shouldHandleShortCircuitResponse!==!1)return o(r,d);r.rawResponse=d}else d&&typeof d=="object"&&d[u]===u&&(r=d)}return r}on(i,r,n=!1){if(typeof r!="function")throw new Ve(ot.INVALID_HOOK_CALLBACK,`Hook should be a function, but got "${typeof r}"`);return this.hooks[n?"unshift":"push"]({event:i,action:r}),this}off(i,r){return i==="*"||!i?this.hooks=this.hooks.filter(n=>n.action!==r):this.hooks=this.hooks.filter(n=>n.event!==i||n.action!==r),this}createInterceptor(i){return{handlers:()=>this.hooks.filter(r=>r.event===i).map(r=>r.action),use:(r,n=!1)=>this.on(i,r,n),clear:()=>{this.hooks=this.hooks.filter(r=>r.event!==i)}}}createMethodShortcut(i){return Reflect.defineProperty(this,i,{get:()=>(r,n,s)=>($e.METHODS_WITHOUT_BODY.includes(i.toLocaleLowerCase())?s=n:(s=s||{},s.body=n),this.request(r,{...s,method:i}))}),this}extends(i){const r=new $e(Rt(this.baseConfigs,i));return r.hooks=[...this.hooks],r._plugins=new Map(this._plugins),r._plugins.forEach(async n=>{await r.plugin(n)}),r}static create(i){return new $e(i)}plugin(i){if(typeof i?.name=="string"&&typeof i?.install=="function"){if(this._plugins.has(i.name))return this;const r=i.install(this);if(this._plugins.set(i.name,i),r instanceof $e)return r}return this}uninstall(i){return typeof i=="string"&&(i=this._plugins.get(i)),i&&(i?.uninstall?.(this),this._plugins.delete(i.name)),this}};j($e,"version","6.1.1"),j($e,"FINAL_SYMBOL",Symbol("FEXIOS_FINAL_CONTEXT")),j($e,"DEFAULT_CONFIGS",{baseURL:"",timeout:0,credentials:void 0,headers:{},query:{},responseType:void 0,shouldThrow(i){return!i.ok},fetch:globalThis.fetch}),j($e,"ALL_METHODS",["get","post","put","patch","delete","head","options","trace"]),j($e,"METHODS_WITHOUT_BODY",["get","head","options","trace"]);let fr=$e;const Ch=fr.create;Ch();var on;(t=>{function e(r){return Array.isArray(r)?r.join("|"):typeof r=="boolean"||r===null?r?"1":void 0:typeof r=="number"?""+r:r}t.normalizeParamValue=e;function i(r){const n=o=>o&&(o instanceof URLSearchParams||o instanceof FormData);if(r==null)return;const s=new FormData;if(n(r))return r.forEach((o,a)=>{const c=e(o);c!=null&&s.append(a,c)}),s;if(Vt(r))return Object.entries(r).forEach(([o,a])=>{const c=e(a);c!=null&&s.append(o,c)}),s}t.normalizeBody=i})(on||(on={}));var hr=(t=>(t.HTTP_ERROR="HTTP_ERROR",t.LOGIN_FAILED="LOGIN_FAILED",t.LOGIN_RETRY_LIMIT_EXCEEDED="LOGIN_RETRY_LIMIT_EXCEEDED",t.TOKEN_RETRY_LIMIT_EXCEEDED="TOKEN_RETRY_LIMIT_EXCEEDED",t))(hr||{});class et extends Error{constructor(i,r="",n){super();j(this,"name","WikiSaikouError");this.code=i,this.message=r,this.cause=n}static is(i,r){return i instanceof this&&(r===void 0||i.code===r)}}class At extends Error{constructor(i,r){super();j(this,"name","MediaWikiApiError");j(this,"code");this.errors=i,this.cause=r,this.errors=At.normalizeErrors(i),this.message=i.map(n=>n.text).filter(Boolean).join(`
4
- `),this.code=this.isBadTokenError()?"badtoken":this.errors[0]?.code||"Unknown Error"}get firstError(){return this.errors[0]}isBadTokenError(){return this.errors.some(i=>i.code==="badtoken")||["NeedToken","WrongToken"].includes(this.cause?.data?.login?.result)}toString(){return`[${this.name} ${this.code}]`}static is(i){return i instanceof this}static normalizeErrors(i){return Array.isArray(i)===!1?[]:i.filter(r=>typeof r=="object"&&!!r?.code).map(r=>r.text?r:r.info?{...r,text:r.info}:r["*"]?{...r,text:r["*"]}:{...r,text:""})}}(t=>{function e(s){if(s==null)return;if(s?.response?.data!==void 0)return s.response.data;if(s?.data!==void 0)return s.data;const o=s instanceof Error?s.cause:void 0;return o?.response?.data!==void 0?o.response.data:o?.data!==void 0?o.data:s||void 0}function i(s){return r(s).length>0}t.includesMediaWikiApiError=i,t.normalizeMwApiErrors=At.normalizeErrors;function r(s){let o=e(s);if(typeof o!="object"||o===null)return[];const a=o?.error,c=o?.errors,l=[];return a&&l.push(a),Array.isArray(c)&&l.push(...c),(0,t.normalizeMwApiErrors)(l)}t.extractMediaWikiApiErrors=r;function n(s){if(At.is(s))return s.isBadTokenError();{const o=r(s);return new At(o).isBadTokenError()}}t.isBadTokenError=n})(et||(et={}));const ll=Symbol.for("__FEXIOS_SAIKOU__");function cl(t){const e=t instanceof fr?t:new fr({baseURL:t instanceof URL?t.toString():String(t),responseType:"json"});return e[ll]||(Reflect.defineProperty(e,ll,{get:()=>!0,enumerable:!1,configurable:!1}),e.on("beforeInit",i=>{if(i.request.method?.toLowerCase()!=="post")return i;if(i.request.body===void 0||i.request.body===null)return i.request.body=void 0,i;const r=i.request.body=on.normalizeBody(i.request.body),n=new URLSearchParams(i.request.query);return r.has("format")&&n.delete("format"),r.has("formatversion")&&n.delete("formatversion"),r.has("action")&&n.delete("action"),r.has("origin")&&(n.set("origin",""+r.get("origin")),r.delete("origin")),i.request.query=Object.fromEntries(n.entries()),i}),e.on("beforeInit",i=>(i.request.query=pt.mergeQueries({},on.normalizeBody(i.request.query)),i)),e.on("beforeRequest",i=>{const r=new URL(i.request.url),n=pt.mergeQueries(r.searchParams,i.query);if(globalThis.location&&(!n.origin&&location.origin!==r.origin?(n.origin=location.origin,e.baseConfigs.credentials="include",e.baseConfigs.mode="cors"):location.origin===r.origin&&(delete n.origin,e.baseConfigs.credentials=void 0,e.baseConfigs.mode=void 0)),n.origin){const s=encodeURIComponent(n.origin).replace(/\./g,"%2E");delete n.origin,i.request.query=n,i.request.url=`${r.origin}${r.pathname}?origin=${s}`}else i.request.query=n;return i}),e._tokens=new Map,e.on("afterResponse",i=>{const{data:r}=i,n=i.runtime.customEnv?.mwTokenName;n&&et.isBadTokenError(r)&&e._tokens.delete(n);const s=r?.query?.tokens;s&&typeof s=="object"&&Object.entries(s).forEach(([a,c])=>{typeof c=="string"&&e._tokens.set(a.replace(/token$/i,"").toLowerCase(),c)});const o=r?.login?.token;return typeof o=="string"&&e._tokens.set("login",o),i})),e}const ul=(t,e,i)=>{let r={...an.DEFAULT_CONFIGS};if(typeof t=="string"?r=Rt(r,{baseURL:t,fexiosConfigs:e||{},defaultParams:i||{},throwOnApiError:!1}):typeof t=="object"&&t!==null&&(r=Rt(r,t)),!r.baseURL&&typeof window=="object"&&window.mediaWiki){const{wgServer:n,wgScriptPath:s}=window.mediaWiki?.config?.get(["wgServer","wgScriptPath"])||{};typeof n=="string"&&typeof s=="string"&&(r.baseURL=`${n}${s}/api.php`)}if(typeof r.baseURL!="string")throw new Error("baseURL is required");return r},Ih=()=>{},Rh=async(t,e)=>{let i=0;const{retry:r=3,onRetry:n=Ih,shouldRetry:s=()=>!0}=e;let o;do try{return await t()}catch(a){if(o=a,s(a,i))n(a,i),i++;else throw a}while(i<r);throw o||new Error("Retry failed")};const sr=class sr{constructor(e,i,r){j(this,"config");j(this,"version","7.5.0");j(this,"request");j(this,"token",this.getToken);const n=this.config=ul(e,i,r);this.request=cl(n.baseURL)}setBaseURL(e){return this.config.baseURL=e,this.request.baseConfigs.baseURL=e,this}async get(e,i){const r=Rt({},this.config.fexiosConfigs,{query:pt.mergeQueries(this.config.defaultParams,e)},i);return this.runRequestWithApiErrorMapping(()=>this.request.get("",r))}async post(e,i){return this.runRequestWithApiErrorMapping(()=>this.request.post("",e,Rt({},this.config.fexiosConfigs,{query:this.config.defaultParams},i)))}async runRequestWithApiErrorMapping(e){try{const i=await e();return this.handleApiResponse(i)}catch(i){throw this.config.throwOnApiError&&et.includesMediaWikiApiError(i)?new At(et.extractMediaWikiApiErrors(i),i):i}}throwIfApiError(e){const i=et.extractMediaWikiApiErrors(e);if(i.length>0)throw new At(i,e)}handleApiResponse(e){return this.config.throwOnApiError&&this.throwIfApiError(e.data),e}get tokens(){return this.request._tokens}async fetchTokens(e=["csrf"]){return this.config.fexiosConfigs.credentials="include",await this.get({action:"query",meta:"tokens",type:e}),this.tokens}async getToken(e="csrf",i=!1){return(!this.tokens.get(e)||i)&&(this.tokens.delete(e),await this.fetchTokens([e])),this.tokens.get(e)}badToken(e){return this.tokens.delete(e),this.tokens}async postWithToken(e,i,r){const{tokenName:n="token",retry:s=3,noCache:o=!1,fexiosOptions:a}=r||{};if(s<1)throw new et(hr.TOKEN_RETRY_LIMIT_EXCEEDED,"The limit of the number of times to automatically re-acquire the token has been exceeded");let c=0;return Rh(async()=>{const l=await this.getToken(e,o||c>0);try{const u=await this.post({[n]:l,...i},Rt(a||{},{customEnv:{mwTokenName:e}}));if(et.isBadTokenError(u.data))throw u;return u}catch(u){throw et.isBadTokenError(u)||u?.ok===!1||At.is(u)?u:new et(hr.HTTP_ERROR,"Network/transport or SDK-internal error (not a MediaWiki API error)",u)}},{retry:s,onRetry:(l,u)=>{c=u+1},shouldRetry:l=>et.isBadTokenError(l)||l?.ok===!1}).catch(l=>{throw et.isBadTokenError(l)||l?.ok===!1?new et(hr.TOKEN_RETRY_LIMIT_EXCEEDED,"Retry attempts for acquiring/using token exhausted",l):l})}postWithEditToken(e){return this.postWithToken("csrf",e)}get baseURL(){return this.config.baseURL}get defaultParams(){return this.config.defaultParams}get defaultOptions(){return this.config.fexiosConfigs}};j(sr,"INIT_DEFAULT_PARAMS",{action:"query",errorformat:"plaintext",format:"json",formatversion:2}),j(sr,"DEFAULT_CONFIGS",{baseURL:void 0,fexiosConfigs:{responseType:"json"},defaultParams:sr.INIT_DEFAULT_PARAMS,throwOnApiError:!1}),j(sr,"createRequestHandler",cl);let an=sr;class Ms extends an{async clientLogin(e,i,r){r||(r={}),!r.logincontinue&&!r.loginreturnurl&&(r.loginreturnurl=location?.origin);const n=await this.postWithToken("login",{action:"clientlogin",username:e,password:i,...r},{tokenName:"logintoken"});if(n?.data?.clientlogin?.status==="PASS")return n.data.clientlogin;throw new et(hr.LOGIN_FAILED,n.data.clientlogin.message,n)}}class Ah extends Ms{constructor(e,i,r){const n=ul(e,{credentials:"include",mode:"cors",...i},{origin:location.origin,...r});super(n)}}class Th{constructor(e,i={}){this.ctx=e,this.options=i,this._apiClients=new Map,location?.href&&i?.baseURL?.toString()?.startsWith("/")&&(i.baseURL=new URL(i.baseURL,location.origin));const r=this.api=new Ms({baseURL:i.baseURL.toString(),fexiosConfigs:{headers:{"x-api-user-agent":`InPageEdit-NEXT ${e.version}`,...i.headers},...i},throwOnApiError:!0});e.set("api",r),e.set("apiService",this)}getClientByFileRepo(e){const i=new URL(`${e.scriptDirUrl}/api.php`,location.origin),r=i.toString();if(r===this.ctx.root.config.apiConfigs.baseURL?.toString())return this.ctx.api;if(!this._apiClients.has(r)){const n=i.origin===location.origin,s={baseURL:i.toString(),throwOnApiError:!0},o=n?new Ms(s):new Ah(s);o.request.on("beforeRequest",a=>{a.headers=o.request.mergeHeaders(a.headers,{"x-api-user-agent":null,"x-mw-token-name":null})}),this._apiClients.set(r,o)}return this._apiClients.get(r)}}const Ds=(t,e=document)=>e.querySelector(t),Oh=(t,e=document)=>e.querySelectorAll(t);var Lh=Object.create,js=Object.defineProperty,Nh=Object.getOwnPropertyDescriptor,dl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),fl=t=>{throw TypeError(t)},Mh=(t,e,i)=>e in t?js(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Dh=(t,e)=>js(t,"name",{value:e,configurable:!0}),jh=t=>[,,,Lh(t?.[dl("metadata")]??null)],Uh=["class","method","getter","setter","accessor","field","value","get","set"],hl=t=>t!==void 0&&typeof t!="function"?fl("Function expected"):t,Fh=(t,e,i,r,n)=>({kind:Uh[t],name:e,metadata:r,addInitializer:s=>i._?fl("Already initialized"):n.push(hl(s||null))}),qh=(t,e)=>Mh(e,dl("metadata"),t[3]),Bh=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Hh=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&Nh(n,i));Dh(n,i);for(var h=r.length-1;h>=0;h--)c=Fh(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,hl(o)&&(n=o);return qh(t,n),p&&js(n,i,p),u?l^4?s:p:n},pl,Us,gl;pl=[xe(["wiki","wikiTitle"])];let ln=(bt=class extends(gl=ht){constructor(i){super(i,"currentPage",!1);Ni(this,dt);Ni(this,or);this.ctx=i,je(this,or,wt(this,dt,Bf).bind(this)),this.url=new URL(window.location.href),this.isMainPage=void 0,this.wikiTitle=void 0}get logger(){return this.ctx.logger("CURRENT_PAGE")}async start(){await wt(this,dt,qa).call(this),wt(this,dt,qf).call(this),window.addEventListener(bt.HISTORY_CHANGE_EVENT,ce(this,or)),this.ctx.emit("current-page/popstate"),this.logger.info("initialized",this.wikiTitle)}stop(){window.removeEventListener(bt.HISTORY_CHANGE_EVENT,ce(this,or))}get params(){return this.url.searchParams}get canonicalUrl(){const i=(Ds('link[rel="alternate"][hreflang="x-default"]')||Ds('link[rel="canonical"]'))?.href;let r=null;return i&&(r=new URL(i,location.origin)),Reflect.defineProperty(this,"canonicalUrl",{get:()=>r}),r}get wikiAction(){return this.params.get("action")||"view"}},dt=new WeakSet,qa=async function(){await wt(this,dt,zf).call(this),await wt(this,dt,Hf).call(this)},qf=function(){const i=bt.POPSTATE_INJECTION_KEY;if(window[i])return;const r=history.pushState,n=history.replaceState;history.pushState=function(s,o,a){r.apply(this,[s,o,a]),window.dispatchEvent(new CustomEvent(bt.HISTORY_CHANGE_EVENT))},history.replaceState=function(s,o,a){n.apply(this,[s,o,a]),window.dispatchEvent(new CustomEvent(bt.HISTORY_CHANGE_EVENT))},window[i]=!0},Bf=async function(){const i=this.url,r=new URL(window.location.href);this.url=r,(i.pathname!==r.pathname||i.searchParams.get("title")!==r.searchParams.get("title")||i.searchParams.get("curid")!==r.searchParams.get("curid"))&&(await wt(this,dt,qa).call(this),this.ctx.emit("current-page/popstate"),this.logger.info("location changed",r,this.wikiTitle))},or=new WeakMap,Hf=async function(){const r=this.wikiTitle?.getMainDBKey()===this.ctx.wiki.mainPageName;return Reflect.defineProperty(this,"isMainPage",{get:()=>r}),r},zf=async function(){let i=null;return this.canonicalUrl?i=await this.ctx.wikiTitle.newTitleFromUrl(this.canonicalUrl):i=await this.ctx.wikiTitle.newTitleFromUrl(this.url),Object.freeze(i),Reflect.defineProperty(this,"wikiTitle",{get:()=>i}),i},bt.HISTORY_CHANGE_EVENT="inpageedit:historychange",bt.POPSTATE_INJECTION_KEY=Symbol.for("inpageedit:currentpage:popstateinjection"),bt);Us=jh(gl),ln=Hh(Us,0,"CurrentPageService",pl,ln),Bh(Us,1,ln);let zh=ln;class Wh extends ht{constructor(e){super(e,"resourceLoader",!0),this.ctx=e}stop(){this.removeAll()}loadScript(e,i){if(!e)return Promise.resolve(null);const r=`script:${e}`,n=document.querySelector(`[data-ipe="${r}"]`);return n?Promise.resolve(n):new Promise((o,a)=>{const c=document.createElement("script");c.src=e,c.dataset.ipe=r,i&&Object.entries(i).forEach(([l,u])=>{typeof u>"u"||u===!1||u===null?c.removeAttribute(l):c.setAttribute(l,u)}),document.body.appendChild(c),c.onload=()=>o(c),c.onerror=l=>a(l)})}loadStyle(e,i){if(!e)return Promise.resolve(null);const r=`style:${e}`,n=document.querySelector(`[data-ipe="${r}"]`);return n?Promise.resolve(n):new Promise((o,a)=>{const c=document.createElement("link");c.rel="stylesheet",c.href=e,c.dataset.ipe=r,i&&Object.entries(i).forEach(([u,d])=>{typeof d>"u"||d===!1||d===null?c.removeAttribute(u):c.setAttribute(u,d)}),(document.querySelector('meta[name="ipe-styles"]')||(()=>{const u=document.createElement("meta");return u.id="ipe-styles",u.name="ipe-styles",document.head.insertAdjacentElement("afterbegin",u),u})()).before(c),c.onload=()=>o(c),c.onerror=u=>a(u)})}removeStyle(e){const i=`style:${e}`,r=document.querySelector(`[data-ipe="${i}"]`);r&&r.remove()}removeScript(e){const i=`script:${e}`,r=document.querySelector(`[data-ipe="${i}"]`);r&&r.remove()}removeAll(){document.querySelectorAll("[data-ipe]").forEach(e=>{e.remove()})}resolveImportPath(e){if(e.startsWith("http")||e.startsWith("//"))return e;const i=document.currentScript?.src;if(!i)return`https://unpkg.com/mediawiki-inpageedit@latest/dist/${e}`;const r=new URL(i);return r.pathname.endsWith(".js")||(r.pathname=r.pathname+"/"),new URL(e,r.toString()).toString()}}const cn=Object.keys;function Kh(t){return typeof t=="boolean"}function Vh(t){return t&&typeof t.nodeType=="number"}function un(t){return typeof t=="string"}function ml(t){return typeof t=="number"}function yi(t){return typeof t=="object"?t!==null:pr(t)}function pr(t){return typeof t=="function"}function Gh(t){return!!(t&&t.isComponent)}function Qh(t){return yi(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function Fs(t,e){if(t)for(const i of cn(t))e(t[i],i)}function Yh(t){return yi(t)&&"current"in t}const qs={animationIterationCount:0,borderImageOutset:0,borderImageSlice:0,borderImageWidth:0,boxFlex:0,boxFlexGroup:0,boxOrdinalGroup:0,columnCount:0,columns:0,flex:0,flexGrow:0,flexPositive:0,flexShrink:0,flexNegative:0,flexOrder:0,gridArea:0,gridRow:0,gridRowEnd:0,gridRowSpan:0,gridRowStart:0,gridColumn:0,gridColumnEnd:0,gridColumnSpan:0,gridColumnStart:0,fontWeight:0,lineClamp:0,lineHeight:0,opacity:0,order:0,orphans:0,tabSize:0,widows:0,zIndex:0,zoom:0,fillOpacity:0,floodOpacity:0,stopOpacity:0,strokeDasharray:0,strokeDashoffset:0,strokeMiterlimit:0,strokeOpacity:0,strokeWidth:0};function Xh(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const Jh=["Webkit","ms","Moz","O"];cn(qs).forEach(t=>{Jh.forEach(e=>{qs[Xh(e,t)]=0})});const Zh=Symbol.for("jsx-dom:type");var yl=(function(t){return t.ShadowRoot="ShadowRoot",t})(yl||{});function ep(t){return t!=null&&t[Zh]===yl.ShadowRoot}const tp="http://www.w3.org/2000/svg",ip="http://www.w3.org/1999/xlink",rp="http://www.w3.org/XML/1998/namespace";function bl(t){return!Kh(t)&&t!=null}function Bs(t){return Array.isArray(t)?t.map(Bs).filter(Boolean).join(" "):yi(t)?Symbol.iterator in t?Bs(Array.from(t)):cn(t).filter(e=>t[e]).join(" "):bl(t)?""+t:""}const np={animate:0,circle:0,clipPath:0,defs:0,desc:0,ellipse:0,feBlend:0,feColorMatrix:0,feComponentTransfer:0,feComposite:0,feConvolveMatrix:0,feDiffuseLighting:0,feDisplacementMap:0,feDistantLight:0,feFlood:0,feFuncA:0,feFuncB:0,feFuncG:0,feFuncR:0,feGaussianBlur:0,feImage:0,feMerge:0,feMergeNode:0,feMorphology:0,feOffset:0,fePointLight:0,feSpecularLighting:0,feSpotLight:0,feTile:0,feTurbulence:0,filter:0,foreignObject:0,g:0,image:0,line:0,linearGradient:0,marker:0,mask:0,metadata:0,path:0,pattern:0,polygon:0,polyline:0,radialGradient:0,rect:0,stop:0,svg:0,switch:0,symbol:0,text:0,textPath:0,tspan:0,use:0,view:0},sp=/^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/;function bi(t){const e=document.createDocumentFragment();return dn(t.children,e),e}function op(t,e,i){e={...e,children:i};const r=new t(e),n=r.render();return"ref"in e&&Hs(e.ref,r),n}function f(t,e){let{children:i,...r}=e;!r.namespaceURI&&np[t]===0&&(r={...r,namespaceURI:tp});let n;if(un(t)){if(n=r.namespaceURI?document.createElementNS(r.namespaceURI,t):document.createElement(t),cp(r,n),dn(i,n),n instanceof window.HTMLSelectElement&&r.value!=null)if(r.multiple===!0&&Array.isArray(r.value)){const s=r.value.map(o=>String(o));n.querySelectorAll("option").forEach(o=>o.selected=s.includes(o.value))}else n.value=r.value;Hs(r.ref,n)}else if(pr(t))yi(t.defaultProps)&&(r={...t.defaultProps,...r}),n=Gh(t)?op(t,r,i):t({...r,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return n}function gr(t,e){for(var i=arguments.length,r=new Array(i>2?i-2:0),n=2;n<i;n++)r[n-2]=arguments[n];return(un(e)||Array.isArray(e))&&(r.unshift(e),e={}),e=e||{},e.children!=null&&!r.length&&({children:r,...e}=e),f(t,{...e,children:r},e.key)}function Hs(t,e){Yh(t)?t.current=e:pr(t)&&t(e)}function dn(t,e){if(Qh(t))ap(t,e);else if(un(t)||ml(t))zs(document.createTextNode(t),e);else if(t===null)zs(document.createComment(""),e);else if(Vh(t))zs(t,e);else if(ep(t)){const i=e.attachShadow(t.attr);dn(t.children,i),Hs(t.ref,i)}}function ap(t,e){for(const i of[...t])dn(i,e);return e}function zs(t,e){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}function fn(t,e){return t.replace(/[A-Z]/g,i=>e+i.toLowerCase())}function vl(t,e){e==null||e===!1||(Array.isArray(e)?e.forEach(i=>vl(t,i)):un(e)?t.setAttribute("style",e):yi(e)&&Fs(e,(i,r)=>{r.indexOf("-")===0?t.style.setProperty(r,i):ml(i)&&qs[r]!==0?t.style[r]=i+"px":t.style[r]=i}))}function lp(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":wl(i,ip,fn(t,":"),e);return;case"xmlnsXlink":Di(i,fn(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":wl(i,rp,fn(t,":"),e);return}switch(t){case"htmlFor":Di(i,"for",e);return;case"dataset":Fs(e,(r,n)=>{r!=null&&(i.dataset[n]=r)});return;case"innerHTML":case"innerText":case"textContent":bl(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":yi(e)&&(i.innerHTML=e.__html);return;case"value":if(e==null||i instanceof window.HTMLSelectElement)return;if(i instanceof window.HTMLTextAreaElement){i.value=e;return}break;case"spellCheck":i.spellcheck=e;return;case"class":case"className":pr(e)?e(i):Di(i,"class",Bs(e));return;case"ref":case"namespaceURI":return;case"style":vl(i,e);return;case"on":case"onCapture":Fs(e,(r,n)=>{i.addEventListener(n,r,t==="onCapture")});return}if(pr(e)){if(t[0]==="o"&&t[1]==="n"){let r=t.toLowerCase();const n=r.endsWith("capture");if(r==="ondoubleclick"?r="ondblclick":n&&r==="ondoubleclickcapture"&&(r="ondblclickcapture"),!n&&i[r]===null)i[r]=e;else if(n)i.addEventListener(r.substring(2,r.length-7),e,!0);else{let s;r in window?s=r.substring(2):s=r[2]+t.slice(3),i.addEventListener(s,e)}}}else yi(e)?i[t]=e:e===!0?Di(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!sp.test(t)?Di(i,fn(t,"-"),e):Di(i,t,e))}function Di(t,e,i){t.setAttribute(e,i)}function wl(t,e,i,r){t.setAttributeNS(e,i,r)}function cp(t,e){for(const i of cn(t))lp(i,t[i],e);return e}const hn=Object.keys;function up(t){return typeof t=="boolean"}function dp(t){return t&&typeof t.nodeType=="number"}function Ws(t){return typeof t=="string"}function _l(t){return typeof t=="number"}function vi(t){return typeof t=="object"?t!==null:mr(t)}function mr(t){return typeof t=="function"}function fp(t){return!!(t&&t.isComponent)}function hp(t){return vi(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function Ks(t,e){if(t)for(const i of hn(t))e(t[i],i)}function pp(t){return vi(t)&&"current"in t}const Vs={animationIterationCount:0,borderImageOutset:0,borderImageSlice:0,borderImageWidth:0,boxFlex:0,boxFlexGroup:0,boxOrdinalGroup:0,columnCount:0,columns:0,flex:0,flexGrow:0,flexPositive:0,flexShrink:0,flexNegative:0,flexOrder:0,gridArea:0,gridRow:0,gridRowEnd:0,gridRowSpan:0,gridRowStart:0,gridColumn:0,gridColumnEnd:0,gridColumnSpan:0,gridColumnStart:0,fontWeight:0,lineClamp:0,lineHeight:0,opacity:0,order:0,orphans:0,tabSize:0,widows:0,zIndex:0,zoom:0,fillOpacity:0,floodOpacity:0,stopOpacity:0,strokeDasharray:0,strokeDashoffset:0,strokeMiterlimit:0,strokeOpacity:0,strokeWidth:0};function gp(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const mp=["Webkit","ms","Moz","O"];hn(Vs).forEach(t=>{mp.forEach(e=>{Vs[gp(e,t)]=0})});const yp=Symbol.for("jsx-dom:type");var xl=(function(t){return t.ShadowRoot="ShadowRoot",t})(xl||{});function bp(t){return t!=null&&t[yp]===xl.ShadowRoot}const vp="http://www.w3.org/2000/svg",wp="http://www.w3.org/1999/xlink",_p="http://www.w3.org/XML/1998/namespace";function kl(t){return!up(t)&&t!=null}function Gs(t){return Array.isArray(t)?t.map(Gs).filter(Boolean).join(" "):vi(t)?Symbol.iterator in t?Gs(Array.from(t)):hn(t).filter(e=>t[e]).join(" "):kl(t)?""+t:""}const xp={animate:0,circle:0,clipPath:0,defs:0,desc:0,ellipse:0,feBlend:0,feColorMatrix:0,feComponentTransfer:0,feComposite:0,feConvolveMatrix:0,feDiffuseLighting:0,feDisplacementMap:0,feDistantLight:0,feFlood:0,feFuncA:0,feFuncB:0,feFuncG:0,feFuncR:0,feGaussianBlur:0,feImage:0,feMerge:0,feMergeNode:0,feMorphology:0,feOffset:0,fePointLight:0,feSpecularLighting:0,feSpotLight:0,feTile:0,feTurbulence:0,filter:0,foreignObject:0,g:0,image:0,line:0,linearGradient:0,marker:0,mask:0,metadata:0,path:0,pattern:0,polygon:0,polyline:0,radialGradient:0,rect:0,stop:0,svg:0,switch:0,symbol:0,text:0,textPath:0,tspan:0,use:0,view:0},kp=/^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/;function Sp(t){const e=document.createDocumentFragment();return pn(t.children,e),e}function Ep(t,e,i){e={...e,children:i};const r=new t(e),n=r.render();return"ref"in e&&Qs(e.ref,r),n}function Ee(t,e){let{children:i,...r}=e;!r.namespaceURI&&xp[t]===0&&(r={...r,namespaceURI:vp});let n;if(Ws(t)){if(n=r.namespaceURI?document.createElementNS(r.namespaceURI,t):document.createElement(t),Cp(r,n),pn(i,n),n instanceof window.HTMLSelectElement&&r.value!=null)if(r.multiple===!0&&Array.isArray(r.value)){const s=r.value.map(o=>String(o));n.querySelectorAll("option").forEach(o=>o.selected=s.includes(o.value))}else n.value=r.value;Qs(r.ref,n)}else if(mr(t))vi(t.defaultProps)&&(r={...t.defaultProps,...r}),n=fp(t)?Ep(t,r,i):t({...r,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return n}function Qs(t,e){pp(t)?t.current=e:mr(t)&&t(e)}function pn(t,e){if(hp(t))$p(t,e);else if(Ws(t)||_l(t))Ys(document.createTextNode(t),e);else if(t===null)Ys(document.createComment(""),e);else if(dp(t))Ys(t,e);else if(bp(t)){const i=e.attachShadow(t.attr);pn(t.children,i),Qs(t.ref,i)}}function $p(t,e){for(const i of[...t])pn(i,e);return e}function Ys(t,e){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}function gn(t,e){return t.replace(/[A-Z]/g,i=>e+i.toLowerCase())}function Sl(t,e){e==null||e===!1||(Array.isArray(e)?e.forEach(i=>Sl(t,i)):Ws(e)?t.setAttribute("style",e):vi(e)&&Ks(e,(i,r)=>{r.indexOf("-")===0?t.style.setProperty(r,i):_l(i)&&Vs[r]!==0?t.style[r]=i+"px":t.style[r]=i}))}function Pp(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":El(i,wp,gn(t,":"),e);return;case"xmlnsXlink":ji(i,gn(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":El(i,_p,gn(t,":"),e);return}switch(t){case"htmlFor":ji(i,"for",e);return;case"dataset":Ks(e,(r,n)=>{r!=null&&(i.dataset[n]=r)});return;case"innerHTML":case"innerText":case"textContent":kl(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":vi(e)&&(i.innerHTML=e.__html);return;case"value":if(e==null||i instanceof window.HTMLSelectElement)return;if(i instanceof window.HTMLTextAreaElement){i.value=e;return}break;case"spellCheck":i.spellcheck=e;return;case"class":case"className":mr(e)?e(i):ji(i,"class",Gs(e));return;case"ref":case"namespaceURI":return;case"style":Sl(i,e);return;case"on":case"onCapture":Ks(e,(r,n)=>{i.addEventListener(n,r,t==="onCapture")});return}if(mr(e)){if(t[0]==="o"&&t[1]==="n"){let r=t.toLowerCase();const n=r.endsWith("capture");if(r==="ondoubleclick"?r="ondblclick":n&&r==="ondoubleclickcapture"&&(r="ondblclickcapture"),!n&&i[r]===null)i[r]=e;else if(n)i.addEventListener(r.substring(2,r.length-7),e,!0);else{let s;r in window?s=r.substring(2):s=r[2]+t.slice(3),i.addEventListener(s,e)}}}else vi(e)?i[t]=e:e===!0?ji(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!kp.test(t)?ji(i,gn(t,"-"),e):ji(i,t,e))}function ji(t,e,i){t.setAttribute(e,i)}function El(t,e,i,r){t.setAttributeNS(e,i,r)}function Cp(t,e){for(const i of hn(t))Pp(i,t[i],e);return e}var Xs=(t=>(t.Init="modal.init",t.BeforeShow="modal.beforeShow",t.Show="modal.show",t.BeforeClose="modal.beforeClose",t.Close="modal.close",t.Destroy="modal.destroy",t.ToastShow="toast.show",t.ToastClose="toast.close",t))(Xs||{});let Ip=0;const $l=t=>`${t}-${++Ip}`;function yr(t){return t instanceof Node?t:document.createTextNode(String(t))}function Gt(t,e){if(!t)throw new Error(`${e??"Element"} not found`);return t}function Pl(t){const e=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");return Array.from(t.querySelectorAll(e)).filter(i=>!!(i.offsetWidth||i.offsetHeight||i.getClientRects().length))}function Ge(t,e={}){const i=document.createElement(t);if(e.className&&(i.className=e.className),e.html!=null&&(i.innerHTML=e.html),e.text!=null&&(i.textContent=e.text),e.attrs)for(const[r,n]of Object.entries(e.attrs))i.setAttribute(r,n);return i}const Rp=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/i.test(navigator.platform),Cl=["ctrl","alt","shift","meta"];function Ap(t){if(!t)return null;const e=String(t).trim().toLowerCase().split(/[+\-\s]+/g).filter(Boolean),i=[];let r=null;const n=o=>{i.includes(o)||i.push(o)};for(const o of e){let a=o;if(a==="control"||a==="ctrl"){n("ctrl");continue}if(a==="alt"||a==="option"){n("alt");continue}if(a==="shift"){n("shift");continue}if(a==="meta"||a==="cmd"||a==="command"||a==="super"){n("meta");continue}if(a==="mod"){n(Rp?"meta":"ctrl");continue}a==="esc"&&(a="escape"),a==="return"&&(a="enter"),(a==="space"||a==="spacebar")&&(a="space"),r=a}const s=Cl.filter(o=>i.includes(o));return!r||r===""?s.length?s.join("+"):null:s.length?`${s.join("+")}+${r}`:r}function Tp(t){const e=[];t.ctrlKey&&e.push("ctrl"),t.altKey&&e.push("alt"),t.shiftKey&&e.push("shift"),t.metaKey&&e.push("meta");let i=t.key;i===" "&&(i="space");const r=(i.length,i.toLowerCase()),n=Cl.filter(s=>e.includes(s));return n.length?`${n.join("+")}+${r}`:r}class Op{constructor(){this.zBase=1e3,this.stack=[]}push(e){this.stack.push(e),this.syncZ()}remove(e){this.stack=this.stack.filter(i=>i!==e),this.syncZ()}top(){return this.stack[this.stack.length-1]}closeAll(e,i){const r=new Set((Array.isArray(i)?i:i?[i]:[]).map(String)),n=new Set((Array.isArray(e)?e:e?[e]:[]).map(String));[...this.stack].reverse().forEach(s=>{const o=s.modalId,a=n.size?n.has(s.pluginName):!0,c=r.has(o);a&&!c&&s.close()})}removeAll(){[...this.stack].forEach(e=>e.destroy()),this.stack=[]}syncZ(){this.stack.forEach((e,i)=>e.setZIndex(this.zBase+i*2))}lockBodyScroll(){document.body.classList.add("ipe-modal-no-scroll")}unlockBodyScroll(){document.body.classList.remove("ipe-modal-no-scroll")}}const tt=new Op,Kr=class Kr{constructor(e={}){this.backdropId=$l("ipe-modal-backdrop"),this.modalId=$l("ipe-modal"),this.numberId=this.modalId.split("-")[1],this._isDestroyed=!1,this.pluginName="normalModal",this.buttonElsLeft=[],this.buttonElsRight=[],this.keyMap=new Map,this.isOpen=!1,this.isToast=!1,this.isDragging=!1,this.dragStartX=0,this.dragStartY=0,this.modalStartX=0,this.modalStartY=0,this.Event=Xs,this._hooks=[],this.startCloseTimer=i=>{this.stopCloseTimer(),this.closeTimer=window.setTimeout(()=>this.close(),i)},this.stopCloseTimer=()=>{this.closeTimer&&window.clearTimeout(this.closeTimer),this.closeTimer=void 0},this.onDragMove=i=>{if(!this.isDragging)return;i.preventDefault();const r=i.clientX-this.dragStartX,n=i.clientY-this.dragStartY,s=this.get$modal(),o=this.modalStartX+r,a=this.modalStartY+n;s.style.left=`${o}px`,s.style.top=`${a}px`},this.onDragEnd=()=>{if(!this.isDragging)return;this.isDragging=!1,document.removeEventListener("pointermove",this.onDragMove),document.removeEventListener("pointerup",this.onDragEnd);const i=this.get$modal(),r=this.get$window();i.classList.remove("is-dragging"),r.style.animation="none",requestAnimationFrame(()=>{this.applyAnimation(!0)})},this.options={...Kr.DEFAULT_OPTIONS,...e},this.options.backdrop===!1&&e.bodyScroll===void 0&&(this.options.bodyScroll=!0)}get isDestroyed(){return this._isDestroyed}static extends(e={}){return class extends this{constructor(i={}){super({...e,...i})}}}init(){if(this.$modal)return this;const e=this.options.backdrop!==!1;let i;e&&(i=Ge("div",{className:"ipe-modal-backdrop",attrs:{id:this.backdropId,"data-modal-id":this.modalId}}));const r=Ge("div",{className:"ipe-modal-modal",attrs:{id:this.modalId,role:"dialog","aria-modal":"true",tabindex:"-1"}});if(r.modal=this,!e){r.classList.add("no-backdrop");const p=window.pageYOffset||document.documentElement.scrollTop,h=window.pageXOffset||document.documentElement.scrollLeft,_=window.innerWidth;r.style.top=`${p+60}px`,this.once("modal.show",()=>{r.style.left=`${h+_/2-r.offsetWidth/2}px`})}const n=Ge("div",{className:`ipe-modal-modal__window size--${this.options.sizeClass||"auto"} plugin--${this.pluginName}`});n.modal=this;const s=Ge("div",{className:"ipe-modal-modal__header"}),o=`${this.modalId}-title`,a=Ge("h2",{className:"ipe-modal-modal__title",attrs:{id:o,role:"heading","aria-level":"2"}});r.setAttribute("aria-labelledby",o);const c=Ge("div",{className:"ipe-modal-modal__icons"});if(this.options.closeIcon){const p=Ge("button",{className:"ipe-modal-modal__close",attrs:{type:"button","aria-label":"Close"},html:"&times;"});p.addEventListener("click",()=>{let h=!0;typeof this.options.onClickClose=="function"?this.options.onClickClose(this)===!1&&(h=!1):this.options.onClickClose===!1&&(h=!1),h&&this.close()}),c.appendChild(p)}s.append(a,c),this.options.draggable&&e&&(this.options.draggable=!1),this.options.draggable&&(s.style.cursor="move",s.style.userSelect="none",s.addEventListener("pointerdown",this.onDragStart.bind(this)),r.classList.add("is-draggable"));const l=Ge("div",{className:"ipe-modal-modal__content"}),u=Ge("div",{className:"ipe-modal-modal__footer"}),d=Ge("div",{className:"ipe-modal-modal__buttons ipe-modal-modal__buttons--left"}),y=Ge("div",{className:"ipe-modal-modal__buttons ipe-modal-modal__buttons--right"});return u.append(d,y),n.append(s,l,u),r.appendChild(n),this.$backdrop=i,this.$modal=r,this.$window=n,this.$header=s,this.$title=a,this.$icons=c,this.$content=l,this.$footer=u,this.$buttonsLeft=d,this.$buttonsRight=y,this.options.title&&this.setTitle(this.options.title),this.options.content&&this.setContent(this.options.content),this.options.buttons?.length?this.setButtons(this.options.buttons):u.style.display="none",this.options.center&&this.$modal.classList.add("is-centered"),this.options.fitScreen&&this.$modal.classList.add("is-fullscreen"),this.options.iconButtons&&this.$header.classList.add("has-icon-buttons"),this.options.className&&this.$window.classList.add(...this.options.className.split(/[\s\.#+]+/g).filter(Boolean)),typeof this.options.fixedHeight=="number"?this.$window.style.height=`${Math.max(0,this.options.fixedHeight)}px`:this.options.fixedHeight===!0&&this.$window.classList.add("is-fixed-height"),i&&i.addEventListener("pointerup",p=>{this.options.outSideClose&&p.target===i&&this.close()}),this.options.draggable&&n.addEventListener("pointerdown",p=>{p.target&&n.contains(p.target)&&this.bringToFront()}),this.onKeyDown=this.onKeyDown.bind(this),this.emit("modal.init"),this}show(){if(this.$modal||this.init(),!this.$modal)throw new Error("Failed to initialize modal");if(this.isOpen)return this;{const r=this.emit("modal.beforeShow",!0),n=this.options.beforeShow?this.options.beforeShow(this)!==!1:!0;if(!r||!n)return this}this.lastFocused=document.activeElement??null,this.$backdrop&&document.body.appendChild(this.$backdrop),document.body.appendChild(this.$modal),this.shouldLockBodyOnOpen()&&tt.lockBodyScroll(),requestAnimationFrame(()=>{this.$backdrop?.classList.add("is-open"),this.$modal.classList.add("is-open"),this.applyAnimation(!0),this.focusFirst()}),document.addEventListener("keydown",this.onKeyDown),tt.push(this),this.isOpen=!0,this.options.onShow?.(this),this.emit("modal.show");const e=typeof this.options.closeAfter=="number"?this.options.closeAfter:this.options.closeAfter?.time,i=typeof this.options.closeAfter=="number"?!0:this.options.closeAfter?.resetOnHover;return e&&(this.startCloseTimer(e),i&&(this.$window?.addEventListener("mouseenter",this.stopCloseTimer),this.$window?.addEventListener("mouseleave",()=>this.startCloseTimer(e)))),this}close(){if(!this.isOpen)return this;{const s=this.emit("modal.beforeClose",!0),o=this.options.beforeClose?this.options.beforeClose(this)!==!1:!0;if(!s||!o)return this}if(this.isToast){this.applyAnimation(!1),this.emit("modal.close"),this.emit("toast.close");const s=this.isAnimationDisabled()?0:this.options.animationSpeed??200;let o=!1;const a=()=>{o||(o=!0,this.destroy(),this.options.onClose?.(this))},c=(l,u)=>{const d=()=>{l.removeEventListener(u,d),a()};l.addEventListener(u,d,{once:!0})};return s>0&&this.$window?(c(this.$window,"transitionend"),c(this.$window,"animationend"),window.setTimeout(a,s+20)):window.setTimeout(a,s),this}this.applyAnimation(!1),this.$backdrop?.classList.remove("is-open"),this.$modal?.classList.remove("is-open"),this.emit("modal.close");const e=this.isAnimationDisabled()?0:this.options.animationSpeed??200;let i=!1;const r=()=>{i||(i=!0,this.destroy(),this.options.onClose?.(this))},n=(s,o)=>{const a=()=>{s.removeEventListener(o,a),r()};s.addEventListener(o,a,{once:!0})};return e>0&&this.$window?(n(this.$window,"transitionend"),n(this.$window,"animationend"),window.setTimeout(r,e+20)):window.setTimeout(r,e),this}destroy(){if(this._isDestroyed)return this;if(this.stopCloseTimer(),document.removeEventListener("keydown",this.onKeyDown),this.isDragging&&this.onDragEnd(),this.$window?.removeEventListener("mouseenter",this.stopCloseTimer),this.isToast){this.$window?.parentElement&&this.$window.parentElement.removeChild(this.$window);const e=wi.indexOf(this);e!==-1&&wi.splice(e,1)}else this.$backdrop?.parentElement&&this.$backdrop.parentElement.removeChild(this.$backdrop),this.$modal?.parentElement&&this.$modal.parentElement.removeChild(this.$modal),tt.remove(this),this.shouldUnlockBodyOnClose()&&tt.unlockBodyScroll();return this.isOpen=!1,this.lastFocused?.focus?.(),this.emit("modal.destroy"),this._isDestroyed=!0,this}get$backdrop(){return this.$backdrop}get$modal(){return Gt(this.$modal,"modal")}get$window(){return Gt(this.$window,"window")}get$header(){return Gt(this.$header,"header")}get$title(){return Gt(this.$title,"title")}get$content(){return Gt(this.$content,"content")}get$icons(){return Gt(this.$icons,"icons")}get$buttons(e){return e==="leftButtons"?Gt(this.$buttonsLeft,"leftButtons"):e==="rightButtons"?Gt(this.$buttonsRight,"rightButtons"):Gt(this.$footer,"buttons")}setTitle(e){const i=this.get$title();return i.innerHTML="",i.append(yr(e)),this}setContent(e,i="replace"){const r=this.get$content();return i==="replace"?(r.innerHTML="",r.append(yr(e))):i==="append"?r.append(yr(e)):r.prepend(yr(e)),this}setIcons(e){const i=this.get$icons();i.innerHTML="";for(const r of e){const n=Ge("button",{className:`ipe-modal-modal__icon ${r.className}`,attrs:{type:"button"}});n.addEventListener("click",r.method),i.appendChild(n)}return this}setButtons(e,i){const r=this.$buttonsLeft,n=this.$buttonsRight;[r,n].forEach(o=>o.innerHTML=""),this.buttonElsLeft=[],this.buttonElsRight=[],this.keyMap.clear();const s=i??this.$footer;if(s===this.$footer)e.forEach(o=>this.addButton(o)),e.length===0&&(this.$footer.style.display="none");else{s.innerHTML="";for(const o of e){const a=this.generateButton(o);s.appendChild(a)}}return this}generateButton(e){const i=e.type??"button",r=i==="link"?Ge("a"):Ge("button",{attrs:{type:"button"}});e.id&&(r.id=e.id),r.className=`ipe-modal-btn ${e.className??""}`.trim();const n=yr(e.label??"OK");if(r.append(n),i==="link"&&e.href&&(r.href=e.href),e.method&&r.addEventListener("click",s=>{if(r._ipe_tmpDisabled){s.preventDefault(),s.stopPropagation();return}e.method.call(r,s,this)}),typeof e.closeAfter=="number"&&e.closeAfter>=0&&r.addEventListener("click",()=>{window.setTimeout(()=>this.close(),e.closeAfter)}),typeof e.enableAfter=="number"&&e.enableAfter>0){i==="button"&&r.setAttribute("disabled","true"),r._ipe_tmpDisabled=!0,r.setAttribute("aria-disabled","true");const s=()=>{i==="button"&&r.removeAttribute("disabled"),delete r._ipe_tmpDisabled,r.removeAttribute("aria-disabled")};window.setTimeout(s,e.enableAfter)}if(e.keyPress){const s=String(e.keyPress).split(/[\,\|]+/g).map(o=>o.trim()).filter(Boolean);for(const o of s){const a=Ap(o);a&&this.keyMap.set(a,r)}}return r}addButton(e,i){this.$footer&&(this.$footer.style.display="");const r=e.side??"right",n=r==="left"?this.$buttonsLeft:this.$buttonsRight,s=r==="left"?this.buttonElsLeft:this.buttonElsRight,o=this.generateButton(e),a=Math.max(0,Math.min(i??s.length,s.length));return a>=n.children.length?n.appendChild(o):n.insertBefore(o,n.children[a]),s.splice(a,0,o),this}removeButton(e){const i=this.buttonElsLeft,r=this.buttonElsRight,n=[...i,...r];let s=null;if(e==="*")return n.forEach(a=>{this.keyMap.delete(a.id),a.parentElement?.removeChild(a)}),this.$footer&&(this.$footer.style.display="none"),this;if(typeof e=="number"?s=n[e]??null:typeof e=="string"?s=n.find(a=>a.id===e)??null:e instanceof HTMLElement&&(s=n.find(a=>a===e)??null),!s)return this;for(const[a,c]of this.keyMap.entries())c===s&&this.keyMap.delete(a);let o=i.indexOf(s);return o!==-1?(i.splice(o,1),s.parentElement?.removeChild(s)):(o=r.indexOf(s),o!==-1&&(r.splice(o,1),s.parentElement?.removeChild(s))),i.length===0&&r.length===0&&this.$footer&&(this.$footer.style.display="none"),this}changePreviewState(){return this.get$modal().classList.toggle("is-fullscreen"),this}setModalHeight(e,i="height"){const r=this.get$window(),n=Math.max(0,window.innerHeight-e);return r.style[i]=`${n}px`,n}setOptions(e,i){return typeof e=="string"?this.options[e]=i:Object.assign(this.options,e),this}setPluginName(e){return this.$window&&(this.$window.className=this.$window.className.replace(`plugin--${this.pluginName}`,`plugin--${e}`)),this.pluginName=e,this}applyAnimation(e){const i=this.get$modal(),r=this.get$window(),n=this.$backdrop,s=this.options.modalAnimation??this.options.animation,o=typeof s=="string"?s:s&&(e?s.show:s.hide),a=this.options.backdropAnimation??this.options.animation,c=typeof a=="string"?a:a&&(e?a.show:a.hide);!o||o===!1?(i.style.transition="none",r.style.animation="none",r.style.removeProperty("--ipe-modal-anim")):(i.style.removeProperty("transition"),r.style.setProperty("--ipe-modal-anim",o)),n&&(!c||c===!1?n.style.transition="none":n.style.removeProperty("transition"))}on(e,i){return this._hooks.push({type:e,listener:i}),()=>this.off(e,i)}off(e,i){return this._hooks=this._hooks.filter(r=>r.type!==e&&(i?r.listener!==i:!0)),this}once(e,i){const r=this.on(e,n=>(r(),i(n)));return r}emit(e,i){const r=this._hooks.filter(a=>a.type===e);let n=!0;for(const a of r){const c=new CustomEvent(e,{detail:this,cancelable:i}),l=a.listener(c);if(c.defaultPrevented&&(n=!1),l===!1&&(n=!1),!n)break}const s=this.$modal??document.body,o=new CustomEvent(e,{detail:this,cancelable:i});return(!s.dispatchEvent(o)||o.defaultPrevented)&&(n=!1),n}focusFirst(){const e=this.get$modal(),i=Pl(e);i.length?i[0].focus():e.focus({preventScroll:!0})}onKeyDown(e){if(tt.top()!==this)return;if(e.key==="Escape"){e.preventDefault(),this.close();return}const i=this.get$modal();if(!i.contains(document.activeElement))return;if(e.key==="Tab"){const a=Pl(i);if(!a.length)return;const c=a[0],l=a[a.length-1],u=document.activeElement;e.shiftKey&&u===c?(e.preventDefault(),l.focus()):!e.shiftKey&&u===l&&(e.preventDefault(),c.focus())}const r=e.ctrlKey||e.altKey||e.metaKey,n=e.target;if(!r&&(n&&["INPUT","TEXTAREA"].includes(n.tagName)||n.contentEditable==="true"))return;const s=Tp(e),o=this.keyMap.get(s);if(o){e.preventDefault(),o.click();return}}setZIndex(e){this.$backdrop&&(this.$backdrop.style.zIndex=String(e)),this.$modal&&(this.$modal.style.zIndex=String(e+1))}bringToFront(){return tt.remove(this),tt.push(this),this}isAnimationDisabled(){const e=this.options.modalAnimation??this.options.animation;return e===!1||e==null}shouldLockBodyOnOpen(){return this.options.backdrop===!1||this.options.bodyScroll!==!1?!1:!tt.stack.some(e=>e!==this&&e.options.backdrop!==!1&&e.options.bodyScroll===!1)}shouldUnlockBodyOnClose(){return this.options.backdrop===!1||this.options.bodyScroll!==!1?!1:!tt.stack.some(e=>e!==this&&e.options.backdrop!==!1&&e.options.bodyScroll===!1)}onDragStart(e){if(this.options.backdrop!==!1||!this.options.draggable)return;e.preventDefault(),this.isDragging=!0,this.bringToFront(),this.dragStartX=e.clientX,this.dragStartY=e.clientY;const i=this.get$modal(),r=i.getBoundingClientRect();this.modalStartX=r.left+window.pageXOffset,this.modalStartY=r.top+window.pageYOffset,i.style.transform="none",i.style.left=`${this.modalStartX}px`,i.style.top=`${this.modalStartY}px`,document.addEventListener("pointermove",this.onDragMove),document.addEventListener("pointerup",this.onDragEnd),i.classList.add("is-dragging")}showToast(e){this.$window||this.init();const i=Lp(e.position??"top right"),r=this.get$window();this.isToast=!0,r.style.pointerEvents="auto",this.applyAnimation(!0),i.appendChild(r);const n=(typeof this.options.closeAfter=="number"?this.options.closeAfter:this.options.closeAfter?.time)??3e3,s=(typeof this.options.closeAfter=="number"?!0:this.options.closeAfter?.resetOnHover)??!0;return n>0&&(this.startCloseTimer(n),s&&(r.addEventListener("mouseenter",this.stopCloseTimer),r.addEventListener("mouseleave",()=>this.startCloseTimer(n)))),this.isOpen=!0,this.options.onShow?.(this),wi.push(this),this.emit("toast.show"),this.emit("modal.show"),this}static show(e,i){return new this(e).init().show()}static createObject(e,i){return new this(e)}static close(e){if(!e){const s=tt.top();return s?.close(),s}const i=typeof e=="string"?e:e.id,r=tt.stack.find(s=>s.modalId===i);if(r)return r.close(),r;const n=wi.find(s=>s.modalId===i);return n?.close(),n}static closeAll(e,i){const r=new Set((Array.isArray(i)?i:i?[i]:[]).map(String)),n=new Set((Array.isArray(e)?e:e?[e]:[]).map(String));return tt.closeAll(e,i),[...wi].forEach(s=>{const o=s.modalId,a=n.size?n.has(s.pluginName):!0,c=r.has(o);a&&!c&&s.close()}),tt.top()??new Kr}static removeAll(){tt.removeAll(),[...wi].forEach(e=>e.destroy())}static dialog(e,i){const r=new this({sizeClass:"dialog",buttons:[{label:"OK",className:"is-primary is-ghost",method:(n,s)=>{i?.(n,s),n.defaultPrevented||r.close()},keyPress:"Enter"}],...e});return r.init().show()}static confirm(e,i){e.title??(e.title="Confirm"),e.content??(e.content="Are you sure you want to perform this action?");const r=e.okBtn??{label:"OK",className:"is-primary is-ghost"},n=e.cancelBtn??{label:"Cancel",className:"is-danger is-ghost"};return new this({sizeClass:"dialog",...e,buttons:[{label:n.label,className:n.className,keyPress:"n",method:(s,o)=>{i?.(!1,o,s),o.close()}},{label:r.label,className:r.className,keyPress:"y",method:(s,o)=>{i?.(!0,o,s),s.defaultPrevented||o.close()}}]}).init().show()}static getDefaultNotifyIcon(e){switch(e){case"success":return Ee("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-circle-check",children:[Ee("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ee("path",{d:"M17 3.34a10 10 0 1 1 -14.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 14.995 -8.336zm-1.293 5.953a1 1 0 0 0 -1.32 -.083l-.094 .083l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.403 1.403l.083 .094l2 2l.094 .083a1 1 0 0 0 1.226 0l.094 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z"})]});case"error":return Ee("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-alert-triangle",children:[Ee("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ee("path",{d:"M12 1.67c.955 0 1.845 .467 2.39 1.247l.105 .16l8.114 13.548a2.914 2.914 0 0 1 -2.307 4.363l-.195 .008h-16.225a2.914 2.914 0 0 1 -2.582 -4.2l.099 -.185l8.11 -13.538a2.914 2.914 0 0 1 2.491 -1.403zm.01 13.33l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007zm-.01 -7a1 1 0 0 0 -.993 .883l-.007 .117v4l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-4l-.007 -.117a1 1 0 0 0 -.993 -.883z"})]});case"warning":return Ee("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-alert-circle",children:[Ee("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ee("path",{d:"M12 2c5.523 0 10 4.477 10 10a10 10 0 0 1 -19.995 .324l-.005 -.324l.004 -.28c.148 -5.393 4.566 -9.72 9.996 -9.72zm.01 13l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007zm-.01 -8a1 1 0 0 0 -.993 .883l-.007 .117v4l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-4l-.007 -.117a1 1 0 0 0 -.993 -.883z"})]});case"info":return Ee("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-info-circle",children:[Ee("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ee("path",{d:"M12 2c5.523 0 10 4.477 10 10a10 10 0 0 1 -19.995 .324l-.005 -.324l.004 -.28c.148 -5.393 4.566 -9.72 9.996 -9.72zm0 9h-1l-.117 .007a1 1 0 0 0 0 1.986l.117 .007v3l.007 .117a1 1 0 0 0 .876 .876l.117 .007h1l.117 -.007a1 1 0 0 0 .876 -.876l.007 -.117l-.007 -.117a1 1 0 0 0 -.764 -.857l-.112 -.02l-.117 -.006v-3l-.007 -.117a1 1 0 0 0 -.876 -.876l-.117 -.007zm.01 -3l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007z"})]});case"dialog":return Ee("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-message-dots",children:[Ee("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ee("path",{d:"M12 11v.01"}),Ee("path",{d:"M8 11v.01"}),Ee("path",{d:"M16 11v.01"}),Ee("path",{d:"M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3z"})]});case"confirm":return Ee("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-copy-check",children:[Ee("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ee("path",{d:"M18.333 6a3.667 3.667 0 0 1 3.667 3.667v8.666a3.667 3.667 0 0 1 -3.667 3.667h-8.666a3.667 3.667 0 0 1 -3.667 -3.667v-8.666a3.667 3.667 0 0 1 3.667 -3.667zm-3.333 -4c1.094 0 1.828 .533 2.374 1.514a1 1 0 1 1 -1.748 .972c-.221 -.398 -.342 -.486 -.626 -.486h-10c-.548 0 -1 .452 -1 1v9.998c0 .32 .154 .618 .407 .805l.1 .065a1 1 0 1 1 -.99 1.738a3 3 0 0 1 -1.517 -2.606v-10c0 -1.652 1.348 -3 3 -3zm1.293 9.293l-3.293 3.292l-1.293 -1.292a1 1 0 0 0 -1.414 1.414l2 2a1 1 0 0 0 1.414 0l4 -4a1 1 0 0 0 -1.414 -1.414"})]});default:return null}}static notify(e,i,r){var a,c,l,u;if(i?.overrideOther&&[...wi].forEach(d=>d.close()),typeof i.title>"u"){const d=e||"Notification";i.title=d[0].toUpperCase()+d.slice(1).toLowerCase()}const n=i.icon??this.getDefaultNotifyIcon(e);n&&(n instanceof Element&&n.classList.add("ipe-modal-notify-icon"),i.title=Ee(Sp,{children:[n,i.title]})),e==="confirm"&&(typeof i.closeAfter>"u"&&(i.closeAfter=0),i.okBtn||(i.okBtn={label:"OK"})),i.okBtn&&(typeof i.okBtn!="object"&&(i.okBtn={label:"OK"}),(a=i.okBtn).label??(a.label="OK"),(c=i.okBtn).className??(c.className="is-primary is-text ok-btn"),i.okBtn.method=(d,y)=>{r?.(!0,y,d),y.close()}),i.cancelBtn&&(typeof i.cancelBtn!="object"&&(i.cancelBtn={label:"Cancel"}),(l=i.cancelBtn).label??(l.label="Cancel"),(u=i.cancelBtn).className??(u.className="is-danger is-text cancel-btn"),i.cancelBtn.method=(d,y)=>{r?.(!1,y,d),y.close()}),i.buttons=[i.cancelBtn,i.okBtn,...i.buttons??[]].filter(Boolean);const s=`is-notify type-${e||"default"} ${i.className??""}`,o=new this({...i,className:s,sizeClass:"auto",center:!1,fitScreen:!1,closeIcon:!0,outSideClose:!1,bodyScroll:!0,buttons:i.buttons??[]});return o.setPluginName("toast"),o.showToast({position:i.position??"top right"})}};Kr.DEFAULT_OPTIONS={className:"",sizeClass:"auto",center:!0,fitScreen:!1,closeIcon:!0,bodyScroll:!1,outSideClose:!0,backdrop:!0,animation:{show:"ipe-modal-fade-in",hide:"ipe-modal-fade-out"},animationSpeed:200};let Js=Kr;const wi=[];function Lp(t="top right"){const e="ipe-modal-toast-container",i=`${e}-${t.replace(/[\s-\.|\/]+/g,"-")}`;let r=document.getElementById(i);return r||(r=Ge("div",{className:`${e} ${t}`,attrs:{id:i,"data-position":t}}),document.body.appendChild(r)),r}const Np={ipe_progress:"_ipe_progress_so6hn_1"},_i=t=>{const e=t.indeterminate??!0,i=f("div",{class:`${Np.ipe_progress}`,"data-indeterminate":`${e}`,style:{width:"100%","--progress":t.progress?`${t.progress}%`:"0%"},...t});return i.setProgress=r=>{typeof r=="number"?(i.dataset.indeterminate="false",i.style.setProperty("--progress",`${r}%`)):(i.dataset.indeterminate="true",i.style.setProperty("--progress","0%"))},i};class Me extends Js{constructor(e={}){e.className||(e.className=""),e.className+=" theme-ipe",e.modalAnimation||(e.modalAnimation={show:"ipe-modal-fade-in",hide:"ipe-modal-fade-out"}),super(e)}setLoadingState(e){if(this.get$window().classList.toggle("loading",e),e){const i=this.get$window().querySelectorAll("input:not([disabled]),button:not([disabled])");this._tmpDisabledActiveInputs=i,i.forEach(r=>{r.disabled=!0}),this.get$content().append(f("div",{id:"ipe-modalLoadingWrapper",style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"rgba(255, 255, 255, 0.5)",zIndex:2e3},children:f(_i,{style:{width:"80%",maxWidth:"800px"}})}))}else{this.get$window().querySelector("#ipe-modalLoadingWrapper")?.remove();const i=this._tmpDisabledActiveInputs;i&&i.forEach(r=>{r.disabled=!1})}}}class Mp{constructor(e){this.ctx=e,this.IPEModal=Me,this.IPEModalEvent=Xs,this.show=Me.show.bind(Me),this.createObject=Me.createObject.bind(Me),this.close=Me.close.bind(Me),this.closeAll=Me.closeAll.bind(Me),this.removeAll=Me.removeAll.bind(Me),this.dialog=Me.dialog.bind(Me),this.confirm=Me.confirm.bind(Me),this.notify=Me.notify.bind(Me),e.set("modal",this),e.on("dispose",()=>{Me.closeAll()})}}const Il=t=>{if(!t)return new URLSearchParams;if(t instanceof URLSearchParams)return t;if(typeof t!="object"||t?.constructor!==Object)throw new TypeError("only plain object is supported");const e=new URLSearchParams;for(const[i,r]of Object.entries(t))if(r!=null){if(Array.isArray(r)){for(const n of r)e.append(i,n?.toString());continue}if(typeof r=="object"&&r!==null&&r.constructor===Object){for(const[n,s]of Object.entries(r))s!=null&&e.set(`${i}[${n}]`,s?.toString());continue}e.set(i,r?.toString())}return e},Rl=(t,e,i)=>{const r=typeof t=="string"?new URL(t,window?.location?.origin):new URL(t),n=new URLSearchParams(r.search),s=Il(e);for(const[o,a]of s.entries())n.set(o,a);return r.search=n.toString(),r.hash="",r};var Dp=Object.create,Zs=Object.defineProperty,jp=Object.getOwnPropertyDescriptor,Al=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Tl=t=>{throw TypeError(t)},Up=(t,e,i)=>e in t?Zs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Fp=(t,e)=>Zs(t,"name",{value:e,configurable:!0}),qp=t=>[,,,Dp(t?.[Al("metadata")]??null)],Bp=["class","method","getter","setter","accessor","field","value","get","set"],Ol=t=>t!==void 0&&typeof t!="function"?Tl("Function expected"):t,Hp=(t,e,i,r,n)=>({kind:Bp[t],name:e,metadata:r,addInitializer:s=>i._?Tl("Already initialized"):n.push(Ol(s||null))}),zp=(t,e)=>Up(e,Al("metadata"),t[3]),Wp=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Kp=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&jp(n,i));Fp(n,i);for(var h=r.length-1;h>=0;h--)c=Hp(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,Ol(o)&&(n=o);return zp(t,n),p&&Zs(n,i,p),u?l^4?s:p:n},Ll,eo,Nl;Ll=[xe(["api","storage"])];class mn extends(Nl=ht){constructor(e){super(e,"wiki",!1),this.ctx=e,this._data={},this.CACHE_VERSION=4,this.CACHE_TTL={siteinfo:1e3*60*60*24*3,userinfo:1e3*60*30},this.QUERY_DATA={siteinfo:{meta:"siteinfo|filerepoinfo",siprop:"general|specialpagealiases|namespacealiases|namespaces|magicwords",friprop:"canUpload|displayname|initialCapital|local|name|rootUrl|scriptDirUrl|thumbUrl|url"},userinfo:{meta:"userinfo",uiprop:"groups|rights|blockinfo|options"}},this.CACHE_DB=void 0,this.mwConfig={get:((i,r)=>window?.mw?.config?.get?.(i,r)??r),has:(i=>window?.mw?.config?.exists?.(i)??!1),get values(){return window?.mw?.config?.values||{}}},this.CACHE_DB=e.storage.createDatabase("wiki-metadata",1/0,this.CACHE_VERSION)}get logger(){return this.ctx.logger("WIKI_METADATA")}get api(){return this.ctx.api}async start(){await Promise.all(Object.keys(this.QUERY_DATA).map(e=>this.initData(e))),this.ctx.on("clear-cache",this.onClearCache.bind(this)),this.ctx.set("getUrl",this.getUrl.bind(this)),this.ctx.set("getSciprtUrl",this.getSciprtUrl.bind(this)),this.ctx.set("getMainpageUrl",this.getMainpageUrl.bind(this)),this.ctx.inject(["preferences","$"],e=>{const i=e.$;e.preferences.registerCustomConfig("WikiMetadataService",R.object({WikiMetadataService:R.const(f("div",{children:[f("h3",{children:i`Wiki Informations`}),f("ul",{children:[f("li",{children:[f("strong",{children:[i`Site`,":"]})," ",this.general.sitename," (",this.landingPageUrl,")"]}),f("li",{children:[f("strong",{children:i`User`}),": ",this.userInfo.name," (ID: ",this.userInfo.id,")"]}),f("li",{children:[f("strong",{children:i`Groups`}),": ",this.userGroups.join(", ")||"None"]})]}),f("div",{children:[f("p",{style:{fontStyle:"italic"},children:i`If the information shown above is incorrect (for example, the user is not you), click the button below.`}),f("button",{className:"btn danger",onClick:async r=>{r.preventDefault(),await e.serial("clear-cache")||window.location.reload()},children:["🧹 ",i`Clear caches & Reload`]})]})]})).role("raw-html")}).description("WikiMetadataService"),"about")}),this.logger.info("All initialized",this._data)}async initData(e,i=!1){const r=i?null:await this.fetchFromCache(e);if(r)return this._data[e]=r,this.logger.debug("Using cached",e,r),r;{const n=await this.fetchFromApi(e);return this.saveToCache(e,n),this._data[e]=n,this.logger.debug("Fetched from API",e,n),n}}getCacheKey(e){return`${e}:${new URL(this.ctx.api.config.baseURL).pathname.replace(/^\//,"")}`}async fetchFromApi(e){return this.api.get({action:"query",...this.QUERY_DATA[e]}).then(({data:i})=>{if(typeof i?.query!="object"||i.query===null)throw new Error("Invalid query data",{cause:i});return e==="siteinfo"?i.query:i.query?.[e]||i.query}).catch(i=>(this.logger.error("Failed to fetch",i),Promise.reject(i)))}async fetchFromCache(e){const i=this.getCacheKey(e);return await this.CACHE_DB.get(i,this.CACHE_TTL[e])}async saveToCache(e,i){const r=this.getCacheKey(e);return this.CACHE_DB.set(r,i)}async invalidateCache(e){const i=this.getCacheKey(e);return this.CACHE_DB.delete(i)}async onClearCache(){await this.CACHE_DB.clear()}get _raw(){return this._data}get siteInfo(){return this._data.siteinfo}get general(){return this.siteInfo.general}get specialPageAliases(){return this.siteInfo.specialpagealiases}get namespaceAliases(){return this.siteInfo.namespacealiases}get namespaces(){return this.siteInfo.namespaces}get namespaceMap(){const e=Object.values(this.namespaces).map(i=>({id:i.id,canonical:i.canonical,aliases:this.namespaceAliases.filter(r=>r.id===i.id).map(r=>r.alias)})).sort((i,r)=>i.id-r.id);return Reflect.defineProperty(this,"namespaceMap",{get:()=>e}),e}get magicWords(){return this.siteInfo.magicwords}get userInfo(){return this._data.userinfo}get userOptions(){return this.userInfo.options}get isUserBlocked(){return this.userInfo.blockedbyid&&this.userInfo.blockexpiry&&new Date(this.userInfo.blockexpiry).getTime()>Date.now()}get userGroups(){return this.userInfo.groups}get userRights(){return this.userInfo.rights}get fileRepos(){return this.siteInfo.repos||[]}get baseUrl(){const e=this.general.server;return e.startsWith("//")?`${window?.location?.protocol||"https:"}//${e.slice(2)}`:e}get landingPageUrl(){return this.general.base}get mainPageName(){return this.general.mainpage}get mainPageUrl(){return this.getUrl(this.mainPageName)}get articlePath(){return this.general.articlepath}get scriptPath(){return this.general.scriptpath}get articleBaseUrl(){return`${this.baseUrl}${this.articlePath}`}get scriptBaseUrl(){return`${this.baseUrl}${this.scriptPath}`}getSciprtUrl(e="index"){return`${this.scriptBaseUrl}/${e.replace(/\.php$/,"")}.php`}getMainpageUrl(e){return Rl(this.siteInfo.general.base,e).toString()}getUrl(e,i){const r=Il(i);let n;return typeof e=="string"&&e!==""?n=new URL(`${this.articleBaseUrl.replace("$1",e)}`):typeof e=="number"?(r.set("curid",e.toString()),n=new URL(this.getSciprtUrl("index"))):n=new URL(this.getSciprtUrl("index")),n.search=r.toString(),n.toString()}hasRight(e){return this.userRights.includes(e)}hasAnyRight(...e){return e.some(i=>this.hasRight(i))}hasEveryRights(...e){return e.every(i=>this.hasRight(i))}inGroup(e){return this.userGroups.includes(e)}inAnyGroup(...e){return this.userGroups.some(i=>e.includes(i))}getBlockInfo(){return this.isUserBlocked?{blockid:this.userInfo.blockid,blockedby:this.userInfo.blockedbyid,blockedbyid:this.userInfo.blockedbyid,blockreason:this.userInfo.blockreason,blockedtimestamp:this.userInfo.blockedtimestamp,blockexpiry:this.userInfo.blockexpiry}:null}}eo=qp(Nl),mn=Kp(eo,0,"WikiMetadataService",Ll,mn),Wp(eo,1,mn);class Vp{constructor(){this.values={}}get length(){return Object.keys(this.values).length}clear(){this.values={}}getItem(e){return this.values[e]??null}setItem(e,i){this.values[e]=typeof i=="string"?i:String(i)}removeItem(e){delete this.values[e]}key(e){return Object.keys(this.values)[e]??null}}const Gp=()=>new Proxy(new Vp,{set(t,e,i){return typeof e=="string"&&t.setItem(e,i),!0},get(t,e){return typeof e=="string"&&!(e in t)?t.getItem(e):Reflect.get(t,e)}}),Qp=(()=>{const t=Symbol.for("IPE.GlobalMemoryStorage");return t in globalThis||(globalThis[t]=Gp()),globalThis[t]})();class Yp{constructor(e,i,r=1/0,n,s="localStorage"){this.dbName=e,this.storeName=i,this.ttl=r,this.version=n,this.engine=s,typeof r!="number"&&(this.ttl=Number(r)),(isNaN(this.ttl)||this.ttl<=0)&&(this.ttl=1/0),this.engine==="localStorage"&&"localStorage"in window?this.db=window.localStorage:this.engine==="sessionStorage"&&"sessionStorage"in window?this.db=window.sessionStorage:this.db=Qp}makeKey(e){return`${this.dbName?this.dbName+":":""}${this.storeName?this.storeName+"/":""}${e}`}load(e){const i=this.getRaw(e);if(i===null)return null;let r;try{r=JSON.parse(i)}catch{return this.deleteSync(e),null}const n=r;return typeof n.time!="number"||!("value"in n)?(this.deleteSync(e),null):typeof this.version<"u"&&typeof this.version<"u"&&n.version!==this.version?(this.deleteSync(e),null):n}getRaw(e){const i=this.makeKey(e);return this.db.getItem(i)}setRaw(e,i){const r=this.makeKey(e);try{this.db.setItem(r,i)}catch{}}deleteSync(e){const i=this.makeKey(e);this.db.removeItem(i)}isExpired(e,i=this.ttl){return e?Date.now()-e.time>i:!1}async get(e,i=this.ttl,r){const n=this.load(e),s=this.isExpired(n,i);if(!n||s){if(typeof r=="function"){const o=await r();return await this.set(e,o),o}return null}return n.value}async set(e,i){const r=Date.now();if(typeof e=="string"){const o=e,a=i;if(a===null||typeof a>"u"){await this.delete(o);return}const c={time:r,value:a,version:this.version};return this.setRaw(o,JSON.stringify(c)),c}const n=e,s={};for(const[o,a]of Object.entries(n)){if(a===null||typeof a>"u"){this.deleteSync(o);continue}const c={time:r,value:a,version:this.version};this.setRaw(o,JSON.stringify(c)),s[o]=c}return s}async has(e,i=this.ttl){const r=this.load(e);return r!==null&&!this.isExpired(r,i)}async delete(e){this.deleteSync(e)}async updatedAt(e){const i=this.load(e);return i?i.time:0}async clear(){const e=this.makeKey(""),i=[];for(let r=0;r<this.db.length;r++){const n=this.db.key(r);n&&n.startsWith(e)&&i.push(n)}for(const r of i)this.db.removeItem(r);return this}async*keys(){const e=this.makeKey("");for(let i=0;i<this.db.length;i++){const r=this.db.key(i);r&&r.startsWith(e)&&(yield r.slice(e.length))}}async*values(){for await(const e of this.keys()){const i=this.load(e);if(i){if(this.isExpired(i)){this.deleteSync(e);continue}yield i}}}async*entries(){for await(const e of this.keys()){const i=this.load(e);if(i){if(this.isExpired(i)){this.deleteSync(e);continue}yield[e,i]}}}}var Te;(t=>{t.cache=new Map,t.defaults=Object.freeze({iterBatch:100,retry:{attempts:3,baseDelayMs:16}}),t.sleep=l=>new Promise(u=>setTimeout(u,l));function e(l){const u=l?.name??"";return u==="AbortError"||u==="InvalidStateError"||u==="TransactionInactiveError"||u==="UnknownError"}t.shouldReconnect=e;async function i(l,u,d){const y=Math.max(1,l.attempts);for(let p=0;p<y;p++)try{return await u(p)}catch(h){if(p===y-1)throw h;await d?.(h,p);const _=l.baseDelayMs*Math.pow(2,p)+Math.floor(Math.random()*10);await(0,t.sleep)(_)}throw new Error("withRetry exhausted unexpectedly")}t.withRetry=i;function r(l,u,d){return new Promise((y,p)=>{const h=indexedDB.open(l,u);h.onupgradeneeded=()=>{try{const _=h.result,k=h.transaction;d?.(_,k)}catch(_){p(_)}},h.onerror=()=>p(h.error),h.onblocked=()=>{},h.onsuccess=()=>{const _=h.result;_.onversionchange=()=>{try{_.close()}finally{t.cache.delete(l)}},y(_)}})}async function n(l,u,d){let y=!l.objectStoreNames.contains(u),p=[];if(!y&&d?.indexes?.length){const k=l.transaction(u,"readonly"),P=k.objectStore(u),b=new Set(Array.from(P.indexNames));p=(d.indexes||[]).filter(m=>!b.has(m.name)),await new Promise((m,g)=>{k.oncomplete=()=>m(),k.onabort=()=>g(k.error),k.onerror=()=>g(k.error)})}if(!y&&p.length===0)return l;const h=l.version+1;l.close();const _=await r(l.name,h,(k,P)=>{let b;k.objectStoreNames.contains(u)?b=P.objectStore(u):b=k.createObjectStore(u,{keyPath:d?.keyPath??void 0,autoIncrement:!!d?.autoIncrement});for(const m of p)b.indexNames.contains(m.name)||b.createIndex(m.name,m.keyPath,m.options)});return _.onversionchange=()=>{try{_.close()}finally{t.cache.delete(_.name)}},_}async function s(l,u,d){let y=t.cache.get(l);return y?(y=y.then(p=>n(p,u,d)),t.cache.set(l,y)):(y=(async()=>{const p=await r(l);return n(p,u,d)})(),t.cache.set(l,y)),y}t.getDB=s;async function o(l){const u=t.cache.get(l);if(t.cache.delete(l),u)try{(await u).close()}catch{}}t.closeConnection=o;function a(l){return new Promise((u,d)=>{l.onsuccess=()=>u(l.result),l.onerror=()=>d(l.error)})}t.asyncRequest=a;function c(l){return new Promise((u,d)=>{l.oncomplete=()=>u(),l.onabort=()=>d(l.error??new DOMException("Aborted","AbortError")),l.onerror=()=>d(l.error??new DOMException("TransactionError","UnknownError"))})}t.waitTx=c})(Te||(Te={}));let Xp=class{constructor(e,i,r={}){this.dbName=e,this.storeName=i,this.options=r}get _iterBatch(){return this.options.iterBatch??Te.defaults.iterBatch}get _retryCfg(){const e=this.options.retry??Te.defaults.retry;return{attempts:e.attempts??3,baseDelayMs:e.baseDelayMs??16}}async _withStore(e,i){const r=this._retryCfg;return Te.withRetry(r,async()=>{const n=await Te.getDB(this.dbName,this.storeName,this.options.ensure);try{const s=n.transaction(this.storeName,e),o=s.objectStore(this.storeName),a=await i(o);return await Te.waitTx(s),a}catch(s){throw s}},async n=>{Te.shouldReconnect(n)&&await Te.closeConnection(this.dbName)})}async get(e){return this._withStore("readonly",async i=>{const r=await Te.asyncRequest(i.get(e));return r===void 0?void 0:r})}async set(e,i){return await this._withStore("readwrite",async r=>{const n=this.options.ensure?.keyPath!=null?r.put(i):r.put(i,e);await Te.asyncRequest(n)}),this}async delete(e){return this._withStore("readwrite",async i=>{const r=await Te.asyncRequest(i.get(e))!==void 0;return await Te.asyncRequest(i.delete(e)),r})}async clear(){await this._withStore("readwrite",async e=>{await Te.asyncRequest(e.clear())})}async has(e){return await this.get(e)!==void 0}async count(){return this._withStore("readonly",async e=>await Te.asyncRequest(e.count())??0)}async*_iterateEntries(){let e=null,i=!1;const r=Math.max(1,this._iterBatch);for(;!i;){const n=await this._withStore("readonly",async s=>{const o=[],a=e===null?void 0:IDBKeyRange.lowerBound(e,!0);return await new Promise((c,l)=>{const u=s.openCursor(a);u.onerror=()=>l(u.error),u.onsuccess=()=>{const d=u.result;if(!d){i=!0,c();return}o.push([d.key,d.value]),e=d.key,o.length>=r?c():d.continue()}}),o});for(const s of n)yield s;if(n.length===0)break}}entries(){return this._iterateEntries()}async*keys(){for await(const[e]of this.entries())yield e}async*values(){for await(const[,e]of this.entries())yield e}[Symbol.asyncIterator](){return this.entries()[Symbol.asyncIterator]()}async forEach(e){for await(const[i,r]of this.entries())await e(r,i,this)}async getMany(e){const i=new Map;for await(const r of e)i.set(r,void 0);return await this._withStore("readonly",async r=>{await Promise.all(i.keys().map(async n=>{const s=await Te.asyncRequest(r.get(n));i.set(n,s===void 0?void 0:s)}))}),i}async setMany(e){const i=this.options.ensure?.keyPath!=null;return await this._withStore("readwrite",async r=>{for await(const[n,s]of e){const o=i?r.put(s):r.put(s,n);await Te.asyncRequest(o)}}),this}async deleteMany(e){let i=0;return await this._withStore("readwrite",async r=>{for await(const n of e)await Te.asyncRequest(r.get(n))!==void 0&&i++,await Te.asyncRequest(r.delete(n))}),i}async disconnect(){await Te.closeConnection(this.dbName)}};class Jp{constructor(e,i,r=1/0,n){this.dbName=e,this.storeName=i,this.ttl=r,this.version=n,this.db=new Xp(e,i),this.keys=this.db.keys.bind(this.db),this.values=this.db.values.bind(this.db),this.entries=this.db.entries.bind(this.db),typeof this.ttl!="number"&&(this.ttl=Number(this.ttl)),(isNaN(this.ttl)||this.ttl<=0)&&(this.ttl=1/0),this._clearExpiredEntries().catch(()=>{})}async _clearExpiredEntries(){if(this.ttl===1/0)return;const e=Date.now(),i=[];for await(const[r,n]of this.db.entries())typeof n.time=="number"&&e-n.time>this.ttl&&i.push(r);i.length>0&&await this.db.deleteMany(i)}async get(e,i=this.ttl,r){const n=await this.loadFromDB(e),s=this.checkIfExpired(n,i);if(!n||s){if(typeof r=="function"){const o=await r();return await this.set(e,o),o}return null}return n.value}async set(e,i){const r=Date.now();if(typeof e=="string"){const c=e,l=i;if(l===null||typeof l>"u")return this.delete(c);const u={time:r,value:l,version:this.version};return await this.db.set(c,u),u}const n=e,s=[],o=[],a={};for(const[c,l]of Object.entries(n))if(l===null||typeof l>"u")o.push(c);else{const u={time:r,value:l,version:this.version};s.push([c,u]),a[c]=u}return s.length>0&&await this.db.setMany(s),o.length>0&&await this.db.deleteMany(o),a}async has(e,i=this.ttl){const r=await this.loadFromDB(e),n=this.checkIfExpired(r,i);return r!==null&&!n}async delete(e){await this.db.delete(e)}async updatedAt(e){const i=await this.loadFromDB(e);return i?i.time:0}async loadFromDB(e){const i=await this.db.get(e);if(i===void 0)return null;if(typeof i.time!="number"||typeof i.value>"u"){try{await this.delete(e)}catch{}return null}if(typeof this.version<"u"&&typeof this.version<"u"&&i.version!==this.version){try{await this.delete(e)}catch{}return null}return i}checkIfExpired(e,i=this.ttl){return e?Date.now()-e.time>i:!1}async clear(){return await this.db.clear(),this}}class Zp extends ht{constructor(e,i){super(e,"storage",!1),this.config=i,this.kv=this.createDatabase("key-val",0,1,"indexedDB"),this.simpleKV=this.createDatabase("~",0,1,"localStorage"),this.memoryKV=this.createDatabase("~",0,1,"memory")}createDatabase(e,i,r,n="indexedDB"){const s="indexedDB"in window&&window.indexedDB!==null;switch(n==="indexedDB"&&!s&&(n="localStorage"),n){case"indexedDB":return new Jp(this.config.dbName,e,i,r);case"localStorage":case"sessionStorage":case"memory":return new Yp(this.config.dbName,e,i,r,n);default:throw new Error(`Unsupported storage engine: ${n}`)}}}function Tt(t){return function(e){return e.PreferencesSchema=t,e}}var eg=Object.create,to=Object.defineProperty,tg=Object.getOwnPropertyDescriptor,Ml=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Dl=t=>{throw TypeError(t)},ig=(t,e,i)=>e in t?to(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,rg=(t,e)=>to(t,"name",{value:e,configurable:!0}),ng=t=>[,,,eg(t?.[Ml("metadata")]??null)],sg=["class","method","getter","setter","accessor","field","value","get","set"],jl=t=>t!==void 0&&typeof t!="function"?Dl("Function expected"):t,og=(t,e,i,r,n)=>({kind:sg[t],name:e,metadata:r,addInitializer:s=>i._?Dl("Already initialized"):n.push(jl(s||null))}),ag=(t,e)=>ig(e,Ml("metadata"),t[3]),lg=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},cg=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&tg(n,i));rg(n,i);for(var h=r.length-1;h>=0;h--)c=og(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,jl(o)&&(n=o);return ag(t,n),p&&to(n,i,p),u?l^4?s:p:n},Ul,io,Fl;Ul=[xe(["preferences"]),Tt(R.object({theme:R.union([R.const("auto").description("Follow system"),R.const("light").description("Light mode"),R.const("dark").description("Dark mode"),R.const("fandom").description("Follow Fandom")]).default("auto").description("Theme preference")}).description("Theme settings").extra("category","general"))];class yn extends(Fl=ht){constructor(e){super(e,"theme",!1),this.ctx=e,this._mediaQueryList=null,this._observer=null,this._handleSystemThemeChange=this._onSystemThemeChange.bind(this),this._handleBodyClassChange=this._onBodyClassChange.bind(this)}async start(){this._mediaQueryList=window.matchMedia("(prefers-color-scheme: dark)"),this._mediaQueryList.addEventListener("change",this._handleSystemThemeChange),this._observer=new MutationObserver(this._handleBodyClassChange),await this.applyTheme(),this.ctx.on("preferences/changed",async({changes:e})=>{"theme"in e&&await this.applyTheme()})}stop(){this._mediaQueryList&&this._mediaQueryList.removeEventListener("change",this._handleSystemThemeChange),this._observer?.disconnect()}async _onSystemThemeChange(){await this.applyTheme()}async _onBodyClassChange(){await this.applyTheme()}async applyTheme(){const e=await this.ctx.preferences.get("theme")||"auto";this.updateFandomObserver(e);const i=this.getTheme(e);this.applyThemeClass(i),this.ctx.emit("theme/changed",{ctx:this.ctx,theme:i})}updateFandomObserver(e){e==="fandom"?this._observer?.observe(document.body,{attributes:!0,attributeFilter:["class"]}):this._observer?.disconnect()}getTheme(e){if(e==="auto")return this._mediaQueryList?.matches?"dark":"light";if(e==="fandom"){const i=document.body;return i.classList.contains("theme-fandomdesktop-dark")||i.classList.contains("theme-fandommobile-dark")?"dark":"light"}return e}applyThemeClass(e){const i=document.body;e==="dark"?(i.classList.add("ipe-theme-dark"),i.setAttribute("data-ipe-theme","dark")):(i.classList.remove("ipe-theme-dark"),i.setAttribute("data-ipe-theme","light"))}get currentTheme(){return document.body.classList.contains("ipe-theme-dark")?"dark":"light"}}io=ng(Fl),yn=cg(io,0,"ThemeService",Ul,yn),lg(io,1,yn);var _t=(t=>(t.preferences="preferences",t.watch="watch",t.unwatch="unwatch",t.nochange="nochange",t))(_t||{});function ug(t){const i=class i{constructor(n,s=!0){this._loaded=s,this.api=t,n.revisions?.forEach(o=>{typeof o?.slots?.main=="object"&&Object.assign(o,o.slots.main)}),this.pageInfo={...i.DEFAULT_PAGE_INFO,...n}}static async newFromApi(n){const{data:s}=await this.api.get({...i.DEFAULT_QUERY_PARAMS,...n}),o=s?.query?.pages?.[0];if(!o||!o.title)throw new Error("Invalid page info",{cause:s});return new i(o,!0)}static newBlankPage(n={}){return new i(n,!1)}static async newFromAnyKind(n){const{title:s,pageId:o,revisionId:a}=n||{};return a?this.newFromApi({revids:parseInt(a.toString(),10)}):o?this.newFromApi({pageids:parseInt(o.toString(),10)}):s?this.newFromApi({titles:s.toString()}):null}static async newBatchFromApi(n){const{titles:s,pageids:o,revids:a,...c}=n||{},{data:l}=await this.api.post({...i.DEFAULT_QUERY_PARAMS,titles:s?.join("|")??void 0,pageids:o?.join("|")??void 0,revids:a?.join("|")??void 0,...c});return l?.query?.pages?.map(u=>new i(u,!0))||[]}async parse(n){return this.api.post({action:"parse",page:this.pageInfo.title,prop:"text|langlinks|categories|links|templates|images|externallinks|sections|revid|displaytitle|iwlinks|properties|parsewarnings",...n})}async preview(n,s){return this.parse({action:"parse",page:void 0,title:this.title,text:n,pst:1,preview:1,disableeditsection:1,disablelimitreport:1,...s})}async edit(n,s){const o=await this.api.postWithEditToken({action:"edit",title:this.title,starttimestamp:this.pageInfo.touched,basetimestamp:this.revisions[0]?.timestamp,...n,...s});if(o.data?.edit?.result==="Success")return o;throw new At([{module:"edit",code:"editfailure",text:"Unknown edit failure. Please try again.",docref:"https://www.mediawiki.org/wiki/API:Edit"}],o)}async createOnly(n,s){return this.edit(n,{createonly:1,recreate:n.recreate,...s})}async delete(n,s){return this.api.postWithEditToken({action:"delete",title:this.pageInfo.title||void 0,pageid:this.pageInfo.pageid||void 0,reason:n,deletetalk:s?.deletetalk,...s})}async moveTo(n,s,o){return this.api.postWithEditToken({action:"move",from:this.pageInfo.title,to:n,reason:s,movetalk:1,movesubpages:1,...o})}userCan(n){return!!this.pageInfo?.actions?.[n]}userCanEdit(){return this.userCan("edit")}async reloadSelfInfo(){const n=await i.newFromApi({pageids:this.pageInfo.pageid,titles:this.pageInfo.title}),s=(this.pageInfo.revisions||[]).concat(n.revisions||[]).sort((o,a)=>o.revid-a.revid).reduce((o,a)=>(o.find(c=>c.revid===a.revid)||o.push(a),o),[]);return this.pageInfo=n.pageInfo,this.pageInfo.revisions=s,this._loaded=!0,this}get pageid(){return this.pageInfo.pageid}get title(){return this.pageInfo.title}get ns(){return this.pageInfo.ns}get contentmodel(){return this.pageInfo.contentmodel}get fullurl(){return this.pageInfo.fullurl}get canonicalurl(){return this.pageInfo.canonicalurl}get editurl(){return this.pageInfo.editurl}get revisions(){return this.pageInfo.revisions||[]}get lastrevid(){return this.pageInfo.lastrevid}get templates(){return this.pageInfo.templates||[]}get images(){return this.pageInfo.images||[]}};i.api=t,i.DEFAULT_QUERY_PARAMS={action:"query",prop:"info|templates|transcludedin|images|pageimages|revisions",inprop:"protection|url|varianttitles",intestactions:"edit|move|delete",tllimit:"max",tilimit:"max",imlimit:"max",piprop:"thumbnail|name|original",pithumbsize:"200",pilimit:"max",rvprop:"ids|timestamp|flags|comment|user|content",rvslots:"main"},i.DEFAULT_PAGE_INFO={pageid:0,ns:0,title:"",contentmodel:"wikitext",pagelanguage:"",pagelanguagehtmlcode:"",pagelanguagedir:"ltr",touched:new Date().toISOString(),lastrevid:0,length:0,protection:[],restrictiontypes:[],fullurl:"",canonicalurl:"",editurl:"",varianttitles:{},actions:{edit:!0,move:!1,delete:!1},revisions:[],templates:[],images:[]};let e=i;return e}const Ua=class Ua extends ht{constructor(e){super(e,"wikiPage",!0),this.ctx=e,this.WikiPage=ug(this.ctx.api)}async createInstance(e,i=!1){return await this.WikiPage.newFromApi(e)}async newFromTitle(e,i=!1,r,n=!1){return this.createInstance({titles:e.toString(),converttitles:i,rvsection:r},n)}async newFromPageId(e,i,r=!1){return this.createInstance({pageids:e,rvsection:i},r)}async newFromRevision(e,i,r=!1){return await this.createInstance({revids:e,rvsection:i},r)}newBlankPage(e={}){return this.WikiPage.newBlankPage(e)}};Ua.inject=["api"];let ro=Ua;const ql=new WeakMap,br={toDBKey:t=>t.replace(/ /g,"_"),toNormalText:t=>t.replace(/_/g," "),ensureCase:(t,e)=>e==="first-letter"?t.charAt(0).toUpperCase()+t.slice(1):t},vr={normalizeSpecialPageName:t=>t.toLowerCase(),buildSpecialPageIndex:t=>{const e=new Map,i=new Map,r=new Map;for(const n of t.specialpagealiases){const s=n.realname;e.set(s,s);const o=vr.normalizeSpecialPageName(s);r.set(o,s);for(const a of n.aliases){i.set(a,s);const c=vr.normalizeSpecialPageName(a);r.set(c,s)}}return{byRealName:e,byAlias:i,byNormalized:r}},findSpecialPageRealName:(t,e)=>{const i=t.split("/")[0];let r=e.byRealName.get(i)??e.byAlias.get(i);if(r!==void 0)return r;const n=vr.normalizeSpecialPageName(i);return e.byNormalized.get(n)??null}},Ot={normalizeNamespaceText:t=>t.replace(/[_\s]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),buildIndex:t=>{const e=new Map,i=new Map,r=new Map,n=new Map;for(const[s,o]of Object.entries(t.namespaces)){const a=parseInt(s);e.set(o.name,a),i.set(o.canonical??"",a);const c=Ot.normalizeNamespaceText(o.name),l=Ot.normalizeNamespaceText(o.canonical??"");n.set(c,a),n.set(l,a)}for(const s of t.namespacealiases){r.set(s.alias,s.id);const o=Ot.normalizeNamespaceText(s.alias);n.set(o,s.id)}return{byName:e,byCanonical:i,byAlias:r,byNormalized:n}},findNamespaceId:(t,e)=>{let i=e.byName.get(t)??e.byCanonical.get(t)??e.byAlias.get(t);if(i!==void 0)return i;const r=Ot.normalizeNamespaceText(t);return e.byNormalized.get(r)??null},isTalkPage:t=>t%2===1&&t>0,getDefaultNamespaceInfo:t=>({id:t,name:"",canonical:"",case:"first-letter",content:!1,nonincludable:!1,subpages:!1})};function dg(t){var s,o;const e=ql.get(t);if(e)return e;const i=Ot.buildIndex(t),r=vr.buildSpecialPageIndex(t),a=class a{constructor(l,u){Ni(this,s);Ni(this,o);if(this.newTitle=a.create.bind(a),this.toText=this.getPrefixedText.bind(this),this.toString=this.getPrefixedDBKey.bind(this),je(this,s,l||""),je(this,o,u??0),u===void 0)this.fixNSByTitle();else{const d=this.parseTitlePrefix(ce(this,s));d&&d.namespaceId===ce(this,o)&&je(this,s,d.mainTitle)}if(this.getMainText()==="")throw new Error("Invalid title")}static create(l,u){return new a(l,u)}parseTitlePrefix(l){const u=l.indexOf(":");if(u<=0)return null;const d=l.substring(0,u),y=l.substring(u+1),p=Ot.findNamespaceId(d,a._namespaceIndex);return p===null?null:{namespaceId:p,mainTitle:y}}adoptNamespaceFromTitle(){const l=this.parseTitlePrefix(ce(this,s));l&&(je(this,s,l.mainTitle),je(this,o,l.namespaceId))}fixNSByTitle(){const l=ce(this,s).indexOf(":");if(l!==-1){if(l===0){je(this,s,ce(this,s).substring(1));return}this.adoptNamespaceFromTitle()}}getNamespaceInfo(){return a._meta.namespaces[ce(this,o)]??Ot.getDefaultNamespaceInfo(ce(this,o))}resolveSpecialFullTitle(){if(ce(this,o)!==-1)return null;const l=vr.findSpecialPageRealName(ce(this,s),a._specialPageIndex);if(!l)return null;const u=ce(this,s).includes("/")?ce(this,s).substring(ce(this,s).indexOf("/")):"";return l+u}formatMainForOutput(l){const u=this.getNamespaceInfo(),y=this.resolveSpecialFullTitle()??ce(this,s),p=l==="db"?br.toDBKey(y):br.toNormalText(y);return br.ensureCase(p,u.case)}getMainDBKey(){return this.formatMainForOutput("db")}getMainText(){return this.formatMainForOutput("text")}getMainRootText(){return this.getMainText().split("/")[0]}getPrefixedDBKey(){return ce(this,o)===0?this.getMainDBKey():`${this.getNamespaceDBKey()}:${this.getMainDBKey()}`}getPrefixedText(){return ce(this,o)===0?this.getMainText():`${this.getNamespaceText()}:${this.getMainText()}`}getNamespaceId(){return ce(this,o)}getNamespaceText(){return this.getNamespaceInfo().name??""}getNamespaceDBKey(){const l=this.getNamespaceInfo();return br.ensureCase(br.toDBKey(this.getNamespaceText()),l.case)}getSubjectPage(){if(Ot.isTalkPage(ce(this,o))){const l=ce(this,o)-1;return new a(ce(this,s),l)}return this}getTalkPage(){if(Ot.isTalkPage(ce(this,o)))return this;if(ce(this,o)<0)return null;const l=ce(this,o)+1;return a._meta.namespaces[l.toString()]?new a(ce(this,s),l):null}getURL(l){const u=this.getPrefixedDBKey();return this.buildArticleURL(u,l)}buildArticleURL(l,u){const y=a._meta.general.articlepath.replace("$1",l),p=new URL(y,location.origin);return u&&(u instanceof URLSearchParams?u:new URLSearchParams(u)).forEach((_,k)=>{p.searchParams.set(k,_)}),p}setTitle(l){je(this,s,l);const u=ce(this,o);je(this,o,0);const d=this.parseTitlePrefix(ce(this,s));return d?(u!==0&&d.namespaceId===u?(je(this,s,d.mainTitle),je(this,o,u)):(je(this,s,d.mainTitle),je(this,o,d.namespaceId)),this):this}setMainText(l){return je(this,s,l),this}setNamespaceText(l){const u=Ot.findNamespaceId(l,a._namespaceIndex);return u!==null&&je(this,o,u),this}setNamespaceId(l){return je(this,o,l),this}equals(l){return typeof l=="string"&&(l=new a(l)),this.getPrefixedDBKey()===l.getPrefixedDBKey()}isSpecial(l){if(ce(this,o)!==-1)return!1;const u=new a(l,-1);return this.getMainRootText()===u.getMainRootText()}toJSON(){return{ns:ce(this,o),text:this.getMainText(),title:this.getPrefixedText(),url:this.getURL().toString(),isSpecial:ce(this,o)<0}}};s=new WeakMap,o=new WeakMap,a._meta=t,a._namespaceIndex=i,a._specialPageIndex=r;let n=a;return ql.set(t,n),n}const wr=()=>{let t,e;return{promise:new Promise((r,n)=>{t=r,e=n}),resolve:t,reject:e}},Vr=class Vr extends ht{constructor(e){super(e,"wikiTitle",!0),this.ctx=e,this.logger=this.ctx.logger("WikiTitleService"),this._cachedTitles=new Map,this.wiki=this.ctx.wiki,this.wikiBaseUrl=this.wiki.baseUrl,this.wikiArticlePath=this.wiki.articlePath.replace("$1",""),this.wikiArticleBaseUrl=this.wiki.articleBaseUrl.replace("$1",""),this.wikiIndexPhpUrl=this.wiki.getSciprtUrl("index.php"),this.Title=dg(this.ctx.wiki.siteInfo)}newTitle(e,i){return typeof e=="string"?new this.Title(e,i):e}newMainPageTitle(){return this.newTitle(this.ctx.wiki.mainPageName)}async newTitleFromUrl(e){const i=this.parseWikiLink(e);return i?.title?i.title:i?.pageId?this.newTitleFromPageId(i.pageId):null}async newTitleFromAnyId(e,i=!1){const{title:r,pageId:n,revId:s}=e??{};if(typeof r=="string")return this.newTitle(r);let o,a;if(s?(o=parseInt(s.toString(),10),a="revid"):n&&(o=parseInt(n.toString(),10),a="pageid"),!o||!a||isNaN(o)||o<=0)throw new Error("Invalid id or kind",{cause:e});if(!i&&this._cachedTitles.has(`${a}:${o}`))return await this._cachedTitles.get(`${a}:${o}`);const{promise:c,resolve:l,reject:u}=wr();this._cachedTitles.set(`${a}:${o}`,c);try{const{wikiPage:d}=this.ctx;let y=null;if(a==="pageid")y=await d.newFromPageId(o);else if(a==="revid")y=await d.newFromRevision(o);else throw new Error(`Invalid kind: ${a}`);l(this.newTitle(y.title))}catch(d){this._cachedTitles.delete(`${a}:${o}`),u(d)}return c}async newTitleFromPageId(e){return this.newTitleFromAnyId({pageId:e})}async newTitleFromRevision(e){return this.newTitleFromAnyId({revId:e})}resolveSpecialPageTarget(e){const i=typeof e=="string"?this.newTitle(e):e;if(!i||i.getNamespaceId()!==-1)return null;let r,n,s="view";const o=i.getMainDBKey().split("/").slice(1).join("/")||"";if(i.isSpecial("edit")&&o)r=o,s="edit";else if(i.isSpecial("talkpage")&&o){const a=i.newTitle(o).getTalkPage();if(!a)return null;r=a.getPrefixedDBKey()}else if(i.isSpecial("mypage"))r=i.newTitle(this.ctx.wiki.userInfo.name,2).getPrefixedDBKey()+(o?`/${o}`:"");else if(i.isSpecial("mytalk"))r=i.newTitle(this.ctx.wiki.userInfo.name,3).getPrefixedDBKey()+(o?`/${o}`:"");else if(i.isSpecial("newsection")&&o)r=o,n="new",s="edit";else return null;return{title:new this.Title(r),section:n,action:s}}isWikiLink(e){return e.startsWith(this.wikiArticleBaseUrl)||e.startsWith(this.wikiIndexPhpUrl)||e.startsWith(`${this.wikiBaseUrl}/?`)||e===this.ctx.wiki.landingPageUrl}validateHrefAttr(e){return typeof e!="string"?!1:!Vr.REG_SKIPPED_HREF.test(e)}parseWikiLink(e){if(!e||typeof e=="string"&&!this.validateHrefAttr(e))return null;const i=Rl(e);if(!this.isWikiLink(i.toString()))return null;const r=i.searchParams,n=i.hash.replace("#",""),s=r.get("action")||"view",o=r.get("title")||"",a=parseInt(r.get("curid")||"0",10),c=parseInt(r.get("oldid")||"0",10);let l=o||(()=>{try{return decodeURIComponent(i.pathname.substring(this.wikiArticlePath.length))}catch(p){return this.logger.error("parseLink",i,p),""}})();l.endsWith("index.php")&&(l="");let u,d,y;if(c)y=c;else if(a)d=a;else if(l)u=this.newTitle(l);else if(i.origin+i.pathname===this.ctx.wiki.landingPageUrl)u=this.newMainPageTitle();else return null;return{title:u,pageId:d,revId:y,url:i,params:r,hash:n,action:s}}};Vr.inject=["wiki","wikiPage"],Vr.REG_SKIPPED_HREF=/^(#|javascript:|vbscript:|file:)/i;let no=Vr;const Bl=t=>typeof t=="function";async function fg(t){return Bl(t)?await t():t}function Hl(t){return Bl(t)?t():t}var hg=Object.create,so=Object.defineProperty,pg=Object.getOwnPropertyDescriptor,zl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Wl=t=>{throw TypeError(t)},gg=(t,e,i)=>e in t?so(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,mg=(t,e)=>so(t,"name",{value:e,configurable:!0}),yg=t=>[,,,hg(t?.[zl("metadata")]??null)],bg=["class","method","getter","setter","accessor","field","value","get","set"],Kl=t=>t!==void 0&&typeof t!="function"?Wl("Function expected"):t,vg=(t,e,i,r,n)=>({kind:bg[t],name:e,metadata:r,addInitializer:s=>i._?Wl("Already initialized"):n.push(Kl(s||null))}),wg=(t,e)=>gg(e,zl("metadata"),t[3]),_g=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},xg=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&pg(n,i));mg(n,i);for(var h=r.length-1;h>=0;h--)c=vg(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,Kl(o)&&(n=o);return wg(t,n),p&&so(n,i,p),u?l^4?s:p:n},Vl,oo,Gl;Vl=[xe(["storage","wiki"])];class bn extends(Gl=ht){constructor(e){super(e,"preferences",!0),this.ctx=e,this.db=void 0,this.customRegistries=[],this.categoryDefinitions=[],this._defaultPreferences={},e.set("prefs",this),this.db=e.storage.createDatabase(`preferences:${e.wiki.userInfo.id}`,1/0);try{this._migrageFromLegacyMasterDB()}catch{}}get logger(){return this.ctx.logger("PREFERENCES")}async start(){}async get(e,i){if(!e)return this.getAll();i??(i=()=>{const n=this.defaultOf(e);return this.logger.debug(e,`(fallback value: ${n})`),n});const r=await this.db.get(e,void 0);return r!==null?r:await fg(i)}async getAll(){const e=this.loadDefaultConfigs();for await(const[i,r]of this.db.entries())i!=="_touched"&&i in e&&(e[i]=r.value);return e}async set(e,i){return(await this.setMany({[e]:i}))[e]}async setMany(e){const i=this.loadDefaultConfigs(),r={};for(const[n,s]of Object.entries(e))s===i[n]||s===void 0?r[n]=void 0:r[n]=s;return await this.db.set(r),this.ctx.emit("preferences/changed",{ctx:this.ctx,input:e,changes:r}),r}defaultOf(e){var i;return(i=this._defaultPreferences)[e]??(i[e]=this.loadDefaultConfigs()[e])}async getExportableRecord(e){e??(e=await this.getAll());const i=this.loadDefaultConfigs(),r={};return Object.entries(i).sort(([n],[s])=>n.localeCompare(s)).forEach(([n,s])=>{const o=e[n];o!==void 0&&o!==s&&(r[n]=o)}),r}loadDefaultConfigs(){const e={};return this.getConfigRegistries().forEach(i=>{try{const r=i.schema({});Object.entries(r).forEach(([n,s])=>{e[n]=s})}catch{}}),Object.entries(e).forEach(([i,r])=>{this._defaultPreferences[i]=r}),e}registerCustomConfig(e,i,r){const n={name:e,schema:i,category:r||"general"},s=this.customRegistries.findIndex(o=>o.name===e);return s>=0?this.customRegistries[s]=n:this.customRegistries.push(n),this}getConfigRegistries(e){return Array.from(this.ctx.registry.entries()).map(([i])=>i===null?{name:"@root",schema:Fi?.PreferencesSchema||null}:{name:i.name,schema:i?.PreferencesSchema||null}).filter(i=>i.schema!==null).map(i=>({...i,category:i.schema.meta.category||"general"})).concat(this.customRegistries).filter(i=>!e||i.category===e)}getAllSchema(){return new R(R.intersect(this.getConfigRegistries().map(e=>e.schema)))}defineCategory(e){const i=this.categoryDefinitions.findIndex(r=>r.name===e.name);return i<0?this.categoryDefinitions.push(e):this.categoryDefinitions[i]=e,this.categoryDefinitions.sort((r,n)=>(r.index??0)-(n.index??0)),this}getConfigCategories(){return this.categoryDefinitions}async _migrageFromLegacyMasterDB(){const e=this.ctx.storage.createDatabase("preferences",1/0);let i=0;for await(const[r,n]of e.entries())r!=="_touched"&&(await this.db.set(r,n.value),i++);return i&&this.logger.info(`Migrated ${i} preferences from master DB`),await e.clear(),await e?.db?.disconnect?.(),i}}oo=yg(Gl),bn=xg(oo,0,"PreferencesService",Vl,bn),_g(oo,1,bn);var Lt=(t=>(t.ANALYTICS_API_BASE="https://analytics.ipe.wiki/api/v6",t.ANALYTICS_DASH_URL="https://analytics.ipe.wiki",t.GITHUB_URL="https://github.com/inpageedit/inpageedit-next",t.GITHUB_OWNER="inpageedit",t.GITHUB_REPO="inpageedit-next",t.HOME_URL="https://www.ipe.wiki/",t.UPDATE_LOGS_URL="https://www.ipe.wiki/changelogs/",t.PLUGIN_REGISTRY_URL="https://registry.ipe.wiki/registry.v1.json",t.I18N_INDEX_URL="https://registry.ipe.wiki/i18n/index.json",t.QQ_GROUP_ID="1026023666",t))(Lt||{});const Ql="",Yl="",kg=/\\\{/g,Sg=/\\\}/g,Eg=new RegExp(Ql,"g"),$g=new RegExp(Yl,"g");function Xl(t){const e=t?{...t}:void 0;return(r,...n)=>Pg(e,r,...n)}function Pg(t,e,...i){if(!e)return"";let r=String(e).replace(kg,Ql).replace(Sg,Yl),n={},s=[];i.length===1&&Array.isArray(i[0])?s=i[0]:i.length===1&&Cg(i[0])?n=i[0]:i.length>0&&(s=i);const o=Object.create(null);if(s&&s.length)for(let a=0;a<s.length;a++)o[`$${a+1}`]=s[a];if(n&&Object.keys(n).length)for(const a of Object.keys(n))o[a]=n[a];if(t&&Object.keys(t).length)for(const a of Object.keys(t))typeof o[a]>"u"&&(o[a]=t[a]);return r=r.replace(/\{\{\s*([\s\S]*?)\s*\}\}/g,(a,c)=>{const l=String(c).trim();if(!l)return"";try{const u=Ig(l,o);return u==null?"":String(u)}catch{return""}}),r.replace(Eg,"{").replace($g,"}")}function Cg(t){return typeof t=="object"&&t!==null&&t.constructor===Object}const Ig=Rg();function Rg(){const t=new Set(["eval","Object","Array","String","Number","Boolean","Date","Math","JSON","undefined","null","true","false","NaN","Infinity","isNaN","isFinite","parseInt","parseFloat"]),e=new Function("__expr__","ctx",`
3
+ `),e.emit(e,"internal/warning",r)}get(e){if(this.ctx[U.internal][e]?.type!=="service")return;const r=this.ctx[U.isolate][e],n=this.ctx[U.store][r]?.value;return It(this.ctx,n)}set(e,i){this.provide(e);const r=this.ctx[U.isolate][e],n=this.ctx[U.store][r]?.value;i??(i=void 0);let s=X(()=>{},"dispose");if(n===i)return s;if(!Ie(i)&&!Ie(n))throw new Error(`service ${e} has been registered`);const o=this.ctx;Ie(i)||(s=o.effect(()=>()=>{o.set(e,void 0)})),Qa(i)&&o.emit(o,"internal/warning",new Error(`service ${e} is an unproxyable object, which may lead to unexpected behavior`));const a=Object.create(o);return a[U.filter]=c=>o[U.isolate][e]===c[U.isolate][e],o.emit(a,"internal/before-service",e,i),o[U.store][r]={value:i,source:o},o.emit(a,"internal/service",e,n),s}provide(e,i,r){const n=this.ctx.root[U.internal];if(e in n)return;const s=Symbol(e);n[e]={type:"service",builtin:r},this.ctx.root[U.isolate][e]=s,ks(i)&&(this.ctx[U.store][s]={value:i,source:null},Be(i,U.tracker,{associate:e,property:"ctx"}))}_accessor(e,i){const r=this.ctx.root[U.internal];return e in r?()=>{}:(r[e]={type:"accessor",...i},()=>delete this.ctx.root[U.isolate][e])}accessor(e,i){this.ctx.scope.effect(()=>this._accessor(e,i))}alias(e,i){const r=this.ctx.root[U.internal];if(!(e in r))for(const n of i)r[n]||(r[n]={type:"alias",name:e})}_mixin(e,i){const r=Array.isArray(i)?i.map(o=>[o,o]):Object.entries(i),n=typeof e=="string"?o=>o[e]:()=>e,s=r.map(([o,a])=>this._accessor(a,{get(c){const l=n(this);if(Ie(l))return l;const u=c?ur(c,l):l,d=Reflect.get(l,o,u);return typeof d!="function"?d:d.bind(u??l)},set(c,l){const u=n(this),d=l?ur(l,u):u;return Reflect.set(u,o,c,d)}}));return()=>s.forEach(o=>o())}mixin(e,i){this.ctx.scope.effect(()=>this._mixin(e,i))}trace(e){return It(this.ctx,e)}bind(e){return new Proxy(e,{apply:X((i,r,n)=>i.apply(this.trace(r),n.map(s=>this.trace(s))),"apply")})}},X(yt,"ReflectService"),j(yt,"handler",{get:X((e,i,r)=>{if(typeof i!="string")return Reflect.get(e,i,r);if(Reflect.has(e,i))return It(r,Reflect.get(e,i,r),!0);const[n,s]=yt.resolveInject(e,i),o=new Error(`property ${n} is not registered, declare it as \`inject\` to suppress this warning`);return s?s.type==="accessor"?s.get.call(r,r[U.receiver]):(s.builtin||yt.checkInject(r,n,o),r.reflect.get(n)):(yt.checkInject(r,n,o),Reflect.get(e,n,r))},"get"),set:X((e,i,r,n)=>{if(typeof i!="string")return Reflect.set(e,i,r,n);const[s,o]=yt.resolveInject(e,i);return o?o.type==="accessor"?o.set?o.set.call(n,r,n[U.receiver]):!1:(n.reflect.set(s,r),!0):Reflect.set(e,s,r,n)},"set"),has:X((e,i)=>{if(typeof i!="string")return Reflect.has(e,i);if(Reflect.has(e,i))return!0;const[,r]=yt.resolveInject(e,i);return!!r},"has")}),yt),Ps=gh;function Cs(t){return t!==null&&t!==!1&&t!==void 0}X(Cs,"isBailed");var mh=(er=class{constructor(e){j(this,"isActive",!1);j(this,"_tasks",new Set);j(this,"_hooks",{});this.ctx=e,Be(this,U.tracker,{associate:"lifecycle",property:"ctx"}),Be(this.on("internal/listener",function(r,n,s){const o=s.prepend?"unshift":"push";if(r==="ready")return this.lifecycle.isActive?(this.scope.ensure(async()=>n()),()=>!1):void 0;if(r==="dispose")return this.scope.disposables[o](n),Be(n,"name","event <dispose>"),()=>oi(this.scope.disposables,n);if(r==="fork")return this.scope.runtime.forkables[o](n),this.scope.collect("event <fork>",()=>oi(this.scope.runtime.forkables,n))}),Ze.static,e.scope);for(const r of["info","error","warning"])Be(this.on(`internal/${r}`,(n,...s)=>{this._hooks[`internal/${r}`].length>1}),Ze.static,e.scope);Be(this.on("internal/before-service",function(r){for(const n of this.registry.values()){if(!n.inject[r]?.required)continue;const s=n.isReusable?n.children:[n];for(const o of s)this[U.filter](o.ctx)&&(o.updateStatus(),o.reset())}},{global:!0}),Ze.static,e.scope),Be(this.on("internal/service",function(r){for(const n of this.registry.values()){if(!n.inject[r]?.required)continue;const s=n.isReusable?n.children:[n];for(const o of s)this[U.filter](o.ctx)&&o.start()}},{global:!0}),Ze.static,e.scope);const i=X((r,n)=>{if(!r.runtime.plugin)return!1;for(const s in r.runtime.inject)if(n===Ps.resolveInject(r.ctx,s)[0])return!0;return i(r.parent.scope,n)},"checkInject");Be(this.on("internal/inject",function(r){return i(this.scope,r)},{global:!0}),Ze.static,e.scope)}async flush(){for(;this._tasks.size;)await Promise.all(Array.from(this._tasks))}filterHooks(e,i){return i=It(this.ctx,i),e.slice().filter(r=>{const n=i?.[Ze.filter];return r.global||!n||n.call(i,r.ctx)})}*dispatch(e,i){const r=typeof i[0]=="object"||typeof i[0]=="function"?i.shift():null,n=i.shift();n!=="internal/event"&&this.emit("internal/event",e,n,i,r);for(const s of this.filterHooks(this._hooks[n]||[],r))yield s.callback.apply(r,i)}async parallel(...e){await Promise.all(this.dispatch("emit",e))}emit(...e){Array.from(this.dispatch("emit",e))}async serial(...e){for await(const i of this.dispatch("serial",e))if(Cs(i))return i}bail(...e){for(const i of this.dispatch("bail",e))if(Cs(i))return i}register(e,i,r,n){const s=n.prepend?"unshift":"push";return i[s]({ctx:this.ctx,callback:r,...n}),this.ctx.state.collect(e,()=>this.unregister(i,r))}unregister(e,i){const r=e.findIndex(n=>n.callback===i);if(r>=0)return e.splice(r,1),!0}on(e,i,r){var a;typeof r!="object"&&(r={prepend:r}),this.ctx.scope.assertActive(),i=this.ctx.reflect.bind(i);const n=this.bail(this.ctx,"internal/listener",e,i,r);if(n)return n;const s=(a=this._hooks)[e]||(a[e]=[]),o=typeof e=="string"?`event <${e}>`:"event (Symbol)";return this.register(o,s,i,r)}once(e,i,r){const n=this.on(e,function(...s){return n(),i.apply(this,s)},r);return n}async start(){this.isActive=!0;const e=this._hooks.ready||[];for(;e.length;){const{ctx:i,callback:r}=e.shift();i.scope.ensure(async()=>r())}await this.flush()}async stop(){this.isActive=!1,this.ctx.scope.reset()}},X(er,"Lifecycle"),er),Xa=mh,Ja=(t=>(t[t.PENDING=0]="PENDING",t[t.LOADING=1]="LOADING",t[t.ACTIVE=2]="ACTIVE",t[t.FAILED=3]="FAILED",t[t.DISPOSED=4]="DISPOSED",t))(Ja||{});Y.CordisError=(Ti=class extends Error{constructor(e,i){super(i??Ti.Code[e]),this.code=e}},X(Ti,"CordisError"),Ti),(t=>{t.Code={INACTIVE_EFFECT:"cannot create effect on inactive context"}})(Y.CordisError||(Y.CordisError={}));var Is=(tr=class{constructor(e,i){j(this,"uid");j(this,"ctx");j(this,"disposables",[]);j(this,"error");j(this,"status",0);j(this,"isActive",!1);j(this,"context");j(this,"proxy");j(this,"acceptors",[]);j(this,"tasks",new Set);j(this,"hasError",!1);this.parent=e,this.config=i,this.uid=e.registry?e.registry.counter:0,this.ctx=this.context=e.extend({scope:this}),this.proxy=new Proxy({},{get:X((r,n)=>Reflect.get(this.config,n),"get")})}get _config(){return this.runtime.isReactive?this.proxy:this.config}assertActive(){if(!(this.uid!==null||this.isActive))throw new Y.CordisError("INACTIVE_EFFECT")}effect(e,i){this.assertActive();const r=_s(e)?new e(this.ctx,i):e(this.ctx,i);let n=!1;const s=typeof r=="function"?r:r.dispose.bind(r),o=X((...a)=>{if(!n)return n=!0,oi(this.disposables,o),s(...a)},"wrapped");return this.disposables.push(o),typeof r=="function"?o:(r.dispose=o,r)}collect(e,i){const r=Be(()=>(oi(this.disposables,r),i()),"name",e);return this.disposables.push(r),r}restart(){this.reset(),this.error=null,this.hasError=!1,this.status=0,this.start()}_getStatus(){return this.uid===null?4:this.hasError?3:this.tasks.size?1:this.ready?2:0}updateStatus(e){const i=this.status;e?.(),this.status=this._getStatus(),i!==this.status&&this.context.emit("internal/status",this,i)}ensure(e){const i=e().catch(r=>{this.context.emit(this.ctx,"internal/error",r),this.cancel(r)}).finally(()=>{this.updateStatus(()=>this.tasks.delete(i)),this.context.events._tasks.delete(i)});this.updateStatus(()=>this.tasks.add(i)),this.context.events._tasks.add(i)}cancel(e){this.error=e,this.updateStatus(()=>this.hasError=!0),this.reset()}get ready(){return Object.entries(this.runtime.inject).every(([e,i])=>!i.required||!Ie(this.ctx.get(e)))}reset(){this.isActive=!1,this.disposables=this.disposables.splice(0).filter(e=>{if(this.uid!==null&&e[Ze.static]===this)return!0;(async()=>e())().catch(i=>{this.context.emit(this.ctx,"internal/error",i)})})}init(e){this.config?this.start():this.cancel(e)}start(){if(!this.ready||this.isActive||this.uid===null)return!0;this.isActive=!0,this.updateStatus(()=>this.hasError=!1)}accept(...e){const r={keys:Array.isArray(e[0])?e.shift():null,callback:e[0],...e[1]};return this.effect(()=>(this.acceptors.push(r),r.immediate&&r.callback?.(this.config),()=>oi(this.acceptors,r)))}decline(e){return this.accept(e,()=>!0)}checkUpdate(e,i){if(i||!this.config)return[!0,!0];if(i===!1)return[!1,!1];const r=Object.create(null),n=X(l=>{const u=r[l]??(r[l]=!mi(this.config[l],e[l]));return o||(o=u),u},"checkPropertyUpdate"),s=new Set;let o=!1,a=!1,c=this.runtime.isReactive||null;for(const{keys:l,callback:u,passive:d}of this.acceptors){if(!l)c||(c=!d);else if(d)l?.forEach(p=>s.add(p));else{let p=!1;for(const h of l)p||(p=n(h));if(!p)continue}u?.(e)&&(a=!0)}for(const l in{...this.config,...e})if(c!==!1&&!(l in r)&&!s.has(l)){const u=n(l);c===null&&(a||(a=u))}return[o,a]}},X(tr,"EffectScope"),tr),Za=(ir=class extends Is{constructor(i,r,n,s){super(i,n);j(this,"dispose");this.runtime=r,this.dispose=Be(i.scope.collect(`fork <${i.runtime.name}>`,()=>{this.uid=null,this.reset(),this.context.emit("internal/fork",this);const o=oi(r.disposables,this.dispose);return oi(r.children,this)&&!r.children.length&&i.registry.delete(r.plugin),o}),Ze.static,r),r.children.push(this),r.disposables.push(this.dispose),this.context.emit("internal/fork",this),this.init(s)}start(){if(super.start())return!0;for(const i of this.runtime.forkables)this.ensure(async()=>i(this.context,this._config))}update(i,r){const n=this.config,s=this.runtime.isForkable?this:this.runtime;if(s.config!==n)return;let o;try{o=cr(this.runtime.plugin,i)}catch(l){return this.context.emit("internal/error",l),this.cancel(l)}const[a,c]=s.checkUpdate(o,r);this.context.emit("internal/before-update",this,i),this.config=o,s.config=o,a&&this.context.emit("internal/update",this,n),c&&s.restart()}},X(ir,"ForkScope"),ir),As=(rr=class extends Is{constructor(i,r,n,s){super(i,n);j(this,"value");j(this,"runtime",this);j(this,"schema");j(this,"name");j(this,"inject",Object.create(null));j(this,"forkables",[]);j(this,"children",[]);j(this,"isReusable",!1);j(this,"isReactive",!1);j(this,"apply",X((i,r)=>{if(typeof this.plugin!="function")return this.plugin.apply(i,r);if(_s(this.plugin)){const n=new this.plugin(i,r),s=n[Ze.expose];return s&&i.set(s,n),n.fork&&this.forkables.push(n.fork.bind(n)),n}else return this.plugin(i,r)},"apply"));this.plugin=r,r?(this.setup(),this.init(s)):(this.name="root",this.isActive=!0)}get isForkable(){return this.forkables.length>0}fork(i,r,n){return new Za(i,this,r,n)}dispose(){return this.uid=null,this.reset(),this.context.emit("internal/runtime",this),!0}setup(){const{name:i}=this.plugin;i&&i!=="apply"&&(this.name=i),this.schema=this.plugin.Config||this.plugin.schema,this.inject=xe.resolve(this.plugin.using||this.plugin.inject),this.isReusable=this.plugin.reusable,this.isReactive=this.plugin.reactive,this.context.emit("internal/runtime",this),this.isReusable&&this.forkables.push(this.apply)}reset(){super.reset();for(const i of this.children)i.reset()}start(){if(super.start())return!0;!this.isReusable&&this.plugin&&this.ensure(async()=>this.value=this.apply(this.ctx,this._config));for(const i of this.children)i.start()}update(i,r){if(this.isForkable){const l=new Error(`attempting to update forkable plugin "${this.plugin.name}", which may lead to unexpected behavior`);this.context.emit(this.ctx,"internal/warning",l)}const n=this.config;let s;try{s=cr(this.runtime.plugin||this.context.constructor,i)}catch(l){return this.context.emit("internal/error",l),this.cancel(l)}const[o,a]=this.checkUpdate(s,r),c=this.children.find(l=>l.config===n);this.config=s,c&&(this.context.emit("internal/before-update",c,i),c.config=s,o&&this.context.emit("internal/update",c,n)),a&&this.restart()}},X(rr,"MainScope"),rr);function el(t){return t&&typeof t=="object"&&typeof t.apply=="function"}X(el,"isApplicable");function xe(t){return function(e,i){if(i.kind==="class")e.inject=t;else if(i.kind==="method")i.addInitializer(function(){const r=this[U.tracker]?.property;if(!r)throw new Error("missing context tracker");this[r].inject(t,n=>{e.call(ur(this,{[r]:n}))})});else throw new Error("@Inject can only be used on class or class methods")}}X(xe,"Inject"),(t=>{function e(i){if(!i)return{};if(Array.isArray(i))return Object.fromEntries(i.map(o=>[o,{required:!0}]));const{required:r,optional:n,...s}=i;return Array.isArray(r)&&Object.assign(s,Object.fromEntries(r.map(o=>[o,{required:!0}]))),Array.isArray(n)&&Object.assign(s,Object.fromEntries(n.map(o=>[o,{required:!1}]))),s}t.resolve=e,X(e,"resolve")})(xe||(xe={}));var yh=(nr=class{constructor(e,i){j(this,"_counter",0);j(this,"_internal",new Map);j(this,"context");this.ctx=e,Be(this,U.tracker,{associate:"registry",property:"ctx"}),this.context=e;const r=new As(e,null,i);e.scope=r,r.ctx=e,this.set(null,r)}get counter(){return++this._counter}get size(){return this._internal.size}resolve(e,i=!1){if(e===null||typeof e=="function")return e;if(el(e))return e.apply;if(i)throw new Error('invalid plugin, expect function or object with an "apply" method, received '+typeof e)}get(e){const i=this.resolve(e);return i&&this._internal.get(i)}has(e){const i=this.resolve(e);return!!i&&this._internal.has(i)}set(e,i){const r=this.resolve(e);this._internal.set(r,i)}delete(e){const i=this.resolve(e),r=i&&this._internal.get(i);if(r)return this._internal.delete(i),r.dispose(),r}keys(){return this._internal.keys()}values(){return this._internal.values()}entries(){return this._internal.entries()}forEach(e){return this._internal.forEach(e)}using(e,i){return this.inject(e,i)}inject(e,i){return this.plugin({inject:e,apply:i,name:i.name})}plugin(e,i,r){if(this.resolve(e,!0),this.ctx.scope.assertActive(),!r)try{i=cr(e,i)}catch(s){this.context.emit(this.ctx,"internal/error",s),r=s,i=null}let n=this.get(e);return n?(n.isForkable||this.context.emit(this.ctx,"internal/warning",new Error(`duplicate plugin detected: ${e.name}`)),n.fork(this.ctx,i,r)):(n=new As(this.ctx,e,i,r),this.set(e,n),n.fork(this.ctx,i,r))}},X(nr,"Registry"),nr),bh=yh,Ze=(Le=class{static is(e){return!!e?.[Le.is]}static associate(e,i){return e}constructor(e){e=cr(this.constructor,e),this[U.store]=Object.create(null),this[U.isolate]=Object.create(null),this[U.internal]=Object.create(null),this[U.intercept]=Object.create(null);const i=new Proxy(this,Ps.handler);i.root=i,i.reflect=new Ps(i),i.registry=new bh(i,e),i.lifecycle=new Xa(i);const r=X(n=>{if(n){r(Object.getPrototypeOf(n));for(const s of Object.getOwnPropertyNames(n)){const o=n[s].prototype?.constructor;o&&(i[n[s].key]=new o(i,e),Be(i[n[s].key],"ctx",i))}}},"attach");return r(this[U.internal]),i}[Symbol.for("nodejs.util.inspect.custom")](){return`Context <${this.name}>`}get name(){let e=this.runtime;for(;e&&!e.name;)e=e.parent.runtime;return e?.name}get events(){return this.lifecycle}get state(){return this.scope}extend(e={}){const i=Reflect.getOwnPropertyDescriptor(this,U.shadow)?.value,r=Object.assign(Object.create(It(this,this)),e);return i?Object.assign(Object.create(r),{[U.shadow]:i}):r}isolate(e,i){const r=Object.create(this[U.isolate]);return r[e]=i??Symbol(e),this.extend({[U.isolate]:r})}intercept(e,i){const r=Object.create(this[U.intercept]);return r[e]=i,this.extend({[U.intercept]:r})}},X(Le,"Context"),j(Le,"store",U.store),j(Le,"events",U.events),j(Le,"static",U.static),j(Le,"filter",U.filter),j(Le,"expose",U.expose),j(Le,"isolate",U.isolate),j(Le,"internal",U.internal),j(Le,"intercept",U.intercept),j(Le,"origin","ctx"),j(Le,"current","ctx"),Le.is[Symbol.toPrimitive]=()=>Symbol.for("cordis.is"),Le.prototype[Le.is]=!0,Le);Ze.prototype[Ze.internal]=Object.create(null);var ht=(ut=class{constructor(...e){j(this,"ctx");j(this,"name");j(this,"config");let i,r,n,s;Ze.is(e[0])?(i=e[0],typeof e[1]=="string"?(r=e[1],n=e[2]):s=e[1]):s=e[0],r??(r=this.constructor[U.provide]),n??(n=this.constructor[U.immediate]);let o=this;const a={associate:r,property:"ctx"};return o[U.invoke]&&(o=$s(r,xs(Object.getPrototypeOf(this),Function.prototype),a)),i?o.ctx=i:o[U.setup](),o.name=r,o.config=s,Be(o,U.tracker,a),o.ctx.provide(r),o.ctx.runtime.name=r,n&&(i?o[U.expose]=r:o.ctx.set(r,o)),o.ctx.on("ready",async()=>{await Promise.resolve(),await o.start(),n||o.ctx.set(r,o)}),o.ctx.on("dispose",()=>o.stop()),o}start(){}stop(){}[U.filter](e){return e[U.isolate][this.name]===this.ctx[U.isolate][this.name]}[U.setup](){this.ctx=new Ze}[U.extend](e){let i;return this[ut.invoke]?i=$s(this.name,this,this[U.tracker]):i=Object.create(this),Object.assign(i,e)}static[Symbol.hasInstance](e){let i=e.constructor;for(;i;){if(i=i.prototype?.constructor,i===this)return!0;i=Object.getPrototypeOf(i)}return!1}},X(ut,"Service"),j(ut,"setup",U.setup),j(ut,"invoke",U.invoke),j(ut,"extend",U.extend),j(ut,"tracker",U.tracker),j(ut,"provide",U.provide),j(ut,"immediate",U.immediate),ut),vh=Object.defineProperty,wh=Object.getOwnPropertyNames,re=(t,e)=>vh(t,"name",{value:e,configurable:!0}),_h=(t,e)=>function(){return e||(0,t[wh(t)[0]])((e={exports:{}}).exports,e),e.exports},xh=_h({"src/index.ts"(t,e){var P;var i=Symbol.for("schemastery"),r=Symbol.for("ValidationError");globalThis.__schemastery_index__??(globalThis.__schemastery_index__=0),globalThis.__schemastery_refs__=void 0;var n=(P=class extends TypeError{constructor(g,w){let S="$";for(const I of w.path||[])typeof I=="string"?S+="."+I:typeof I=="number"?S+="["+I+"]":typeof I=="symbol"&&(S+=`[Symbol(${I.toString()})]`);S.startsWith(".")&&(S=S.slice(1));super((S==="$"?"":`${S} `)+g);j(this,"name","ValidationError");this.options=w}static is(g){return!!g?.[r]}},re(P,"ValidationError"),P);Object.defineProperty(n.prototype,r,{value:!0});var s=re(function(b){const m=re(function(g,w={}){return s.resolve(g,m,w)[0]},"schema");if(b.refs){const g=Kt(b.refs,S=>new s(S)),w=re(S=>g[S],"getRef");for(const S in g){const I=g[S];I.sKey=w(I.sKey),I.inner=w(I.inner),I.list=I.list&&I.list.map(w),I.dict=I.dict&&Kt(I.dict,w)}return g[b.uid]}if(Object.assign(m,b),typeof m.callback=="string")try{m.callback=new Function("return "+m.callback)()}catch{}return Object.defineProperty(m,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(m,s.prototype),m.meta||(m.meta={}),m.toString=m.toString.bind(m),m},"Schema");s.prototype=Object.create(Function.prototype),s.prototype[i]=!0,s.ValidationError=n,s.prototype.toJSON=re(function(){var g,w;if(globalThis.__schemastery_refs__)return(g=globalThis.__schemastery_refs__)[w=this.uid]??(g[w]=JSON.parse(JSON.stringify({...this}))),this.uid;globalThis.__schemastery_refs__={[this.uid]:{...this}},globalThis.__schemastery_refs__[this.uid]=JSON.parse(JSON.stringify({...this}));const m={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,m},"toJSON"),s.prototype.set=re(function(m,g){return this.dict[m]=g,this},"set"),s.prototype.push=re(function(m){return this.list.push(m),this},"push");function o(b,m){const g=typeof b=="string"?{"":b}:{...b};for(const w in m){const S=m[w];S?.$description||S?.$desc?g[w]=S.$description||S.$desc:typeof S=="string"&&(g[w]=S)}return g}re(o,"mergeDesc");function a(b){return b?.$value??b?.$inner}re(a,"getInner");function c(b){return Ha(b??{},m=>!m.startsWith("$"))}re(c,"extractKeys"),s.prototype.i18n=re(function(m){const g=s(this),w=o(g.meta.description,m);return Object.keys(w).length&&(g.meta.description=w),g.dict&&(g.dict=Kt(g.dict,(S,I)=>S.i18n(Kt(m,F=>a(F)?.[I]??F?.[I])))),g.list&&(g.list=g.list.map((S,I)=>S.i18n(Kt(m,(F={})=>Array.isArray(a(F))?a(F)[I]:Array.isArray(F)?F[I]:c(F))))),g.inner&&(g.inner=g.inner.i18n(Kt(m,S=>a(S)?a(S):c(S)))),g.sKey&&(g.sKey=g.sKey.i18n(Kt(m,S=>S?.$key))),g},"i18n"),s.prototype.extra=re(function(m,g){const w=s(this);return w.meta={...w.meta,[m]:g},w},"extra");for(const b of["required","disabled","collapse","hidden","loose"])Object.assign(s.prototype,{[b](m=!0){const g=s(this);return g.meta={...g.meta,[b]:m},g}});s.prototype.deprecated=re(function(){var g;const m=s(this);return(g=m.meta).badges||(g.badges=[]),m.meta.badges.push({text:"deprecated",type:"danger"}),m},"deprecated"),s.prototype.experimental=re(function(){var g;const m=s(this);return(g=m.meta).badges||(g.badges=[]),m.meta.badges.push({text:"experimental",type:"warning"}),m},"experimental"),s.prototype.pattern=re(function(m){const g=s(this),w=za(m,["source","flags"]);return g.meta={...g.meta,pattern:w},g},"pattern"),s.prototype.simplify=re(function(m){if(mi(m,this.meta.default,this.type==="dict"))return null;if(Ie(m))return m;if(this.type==="object"||this.type==="dict"){const g={};for(const w in m){const I=(this.type==="object"?this.dict[w]:this.inner)?.simplify(m[w]);(this.type==="dict"||!Ie(I))&&(g[w]=I)}return mi(g,this.meta.default,this.type==="dict")?null:g}else if(this.type==="array"||this.type==="tuple"){const g=[];return m.forEach((w,S)=>{const I=this.type==="array"?this.inner:this.list[S],F=I?I.simplify(w):w;g.push(F)}),g}else if(this.type==="intersect"){const g={};for(const w of this.list)Object.assign(g,w.simplify(m));return g}else if(this.type==="union")for(const g of this.list)try{return s.resolve(m,g,{}),g.simplify(m)}catch{}return m},"simplify"),s.prototype.toString=re(function(m){return _[this.type]?.(this,m)??`Schema<${this.type}>`},"toString"),s.prototype.role=re(function(b,m){const g=s(this);return g.meta={...g.meta,role:b,extra:m},g},"role");for(const b of["default","link","comment","description","max","min","step"])Object.assign(s.prototype,{[b](m){const g=s(this);return g.meta={...g.meta,[b]:m},g}});var l={};s.extend=re(function(m,g){l[m]=g},"extend"),s.resolve=re(function(m,g,w={},S=!1){if(!g)return[m];if(w.ignore?.(m,g))return[m];if(Ie(m)&&g.type!=="lazy"){if(g.meta.required)throw new n("missing required value",w);let F=g,N=g.meta.default;for(;F?.type==="intersect"&&Ie(N);)F=F.list[0],N=F?.meta.default;if(Ie(N))return[m];m=Zr(N)}const I=l[g.type];if(!I)throw new n(`unsupported type "${g.type}"`,w);try{return I(m,g,w,S)}catch(F){if(!g.meta.loose)throw F;return[g.meta.default]}},"resolve"),s.from=re(function(m){if(Ie(m))return s.any();if(["string","number","boolean"].includes(typeof m))return s.const(m).required();if(m[i])return m;if(typeof m=="function")switch(m){case String:return s.string().required();case Number:return s.number().required();case Boolean:return s.boolean().required();case Function:return s.function().required();default:return s.is(m).required()}else throw new TypeError(`cannot infer schema from ${m}`)},"from"),s.lazy=re(function(m){const g=re(()=>(w.inner[i]||(w.inner=w.builder(),w.inner.meta={...w.meta,...w.inner.meta}),w.inner.toJSON()),"toJSON"),w=new s({type:"lazy",builder:m,inner:{toJSON:g}});return w},"lazy"),s.natural=re(function(){return s.number().step(1).min(0)},"natural"),s.percent=re(function(){return s.number().step(.01).min(0).max(1).role("slider")},"percent"),s.date=re(function(){return s.union([s.is(Date),s.transform(s.string().role("datetime"),(m,g)=>{const w=new Date(m);if(isNaN(+w))throw new n(`invalid date "${m}"`,g);return w},!0)])},"date"),s.regExp=re(function(m=""){return s.union([s.is(RegExp),s.transform(s.string().role("regexp",{flag:m}),(g,w)=>{try{return new RegExp(g,m)}catch(S){throw new n(S.message,w)}},!0)])},"regExp"),s.arrayBuffer=re(function(m){return s.union([s.is(ArrayBuffer),s.is(SharedArrayBuffer),s.transform(s.any(),(g,w)=>{if(Ct.isSource(g))return Ct.fromSource(g);throw new n(`expected ArrayBufferSource but got ${g}`,w)},!0),...m?[s.transform(s.string(),(g,w)=>{try{return m==="base64"?Ct.fromBase64(g):Ct.fromHex(g)}catch(S){throw new n(S.message,w)}},!0)]:[]])},"arrayBuffer"),s.extend("lazy",(b,m,g,w)=>(m.inner[i]||(m.inner=m.builder(),m.inner.meta={...m.meta,...m.inner.meta}),s.resolve(b,m.inner,g,w))),s.extend("any",b=>[b]),s.extend("never",(b,m,g)=>{throw new n(`expected nullable but got ${b}`,g)}),s.extend("const",(b,{value:m},g)=>{if(mi(b,m))return[m];throw new n(`expected ${m} but got ${b}`,g)});function u(b,m,g,w,S=!1){const{max:I=1/0,min:F=-1/0}=m;if(b>I)throw new n(`expected ${g} <= ${I} but got ${b}`,w);if(b<F&&!S)throw new n(`expected ${g} >= ${F} but got ${b}`,w)}re(u,"checkWithinRange"),s.extend("string",(b,{meta:m},g)=>{if(typeof b!="string")throw new n(`expected string but got ${b}`,g);if(m.pattern){const w=new RegExp(m.pattern.source,m.pattern.flags);if(!w.test(b))throw new n(`expect string to match regexp ${w}`,g)}return u(b.length,m,"string length",g),[b]});function d(b,m){const g=b.toString();if(g.includes("e"))return b*Math.pow(10,m);const w=g.indexOf(".");if(w===-1)return b*Math.pow(10,m);const S=g.slice(w+1),I=g.slice(0,w);return S.length<=m?+(I+S.padEnd(m,"0")):+(I+S.slice(0,m)+"."+S.slice(m))}re(d,"decimalShift");function y(b,m,g){if(g=Math.abs(g),!/^\d+\.\d+$/.test(g.toString()))return(b-m)%g===0;const w=g.toString().indexOf("."),S=g.toString().slice(w+1).length;return Math.abs(d(b,S)-d(m,S))%d(g,S)===0}re(y,"isMultipleOf"),s.extend("number",(b,{meta:m},g)=>{if(typeof b!="number")throw new n(`expected number but got ${b}`,g);u(b,m,"number",g);const{step:w}=m;if(w&&!y(b,m.min??0,w))throw new n(`expected number multiple of ${w} but got ${b}`,g);return[b]}),s.extend("boolean",(b,m,g)=>{if(typeof b=="boolean")return[b];throw new n(`expected boolean but got ${b}`,g)}),s.extend("bitset",(b,{bits:m,meta:g},w)=>{let S=0,I=[];if(typeof b=="number"){S=b;for(const F in m)b&m[F]&&I.push(F)}else if(Array.isArray(b)){I=b;for(const F of I){if(typeof F!="string")throw new n(`expected string but got ${F}`,w);F in m&&(S|=m[F])}}else throw new n(`expected number or array but got ${b}`,w);return S===g.default?[S]:[S,I]}),s.extend("function",(b,m,g)=>{if(typeof b=="function")return[b];throw new n(`expected function but got ${b}`,g)}),s.extend("is",(b,{constructor:m},g)=>{if(typeof m=="function"){if(b instanceof m)return[b];throw new n(`expected ${m.name} but got ${b}`,g)}else{if(Ie(b))throw new n(`expected ${m} but got ${b}`,g);let w=Object.getPrototypeOf(b);for(;w;){if(w.constructor?.name===m)return[b];w=Object.getPrototypeOf(w)}throw new n(`expected ${m} but got ${b}`,g)}});function p(b,m,g,w){try{const[S,I]=s.resolve(b[m],g,{...w,path:[...w.path||[],m]});return I!==void 0&&(b[m]=I),S}catch(S){if(!w?.autofix)throw S;return delete b[m],g.meta.default}}re(p,"property"),s.extend("array",(b,{inner:m,meta:g},w)=>{if(!Array.isArray(b))throw new n(`expected array but got ${b}`,w);return u(b.length,g,"array length",w,!Ie(m.meta.default)),[b.map((S,I)=>p(b,I,m,w))]}),s.extend("dict",(b,{inner:m,sKey:g},w,S)=>{if(!Jr(b))throw new n(`expected object but got ${b}`,w);const I={};for(const F in b){let N;try{N=s.resolve(F,g,w)[0]}catch(G){if(S)continue;throw G}I[N]=p(b,F,m,w),b[N]=b[F],F!==N&&delete b[F]}return[I]}),s.extend("tuple",(b,{list:m},g,w)=>{if(!Array.isArray(b))throw new n(`expected array but got ${b}`,g);const S=m.map((I,F)=>p(b,F,I,g));return w?[S]:(S.push(...b.slice(m.length)),[S])});function h(b,m){for(const g in m)g in b||(b[g]=m[g])}re(h,"merge"),s.extend("object",(b,{dict:m},g,w)=>{if(!Jr(b))throw new n(`expected object but got ${b}`,g);const S={};for(const I in m){const F=p(b,I,m[I],g);(!Ie(F)||I in b)&&(S[I]=F)}return w||h(S,b),[S]}),s.extend("union",(b,{list:m,toString:g},w,S)=>{for(const I of m)try{return s.resolve(b,I,w,S)}catch{}throw new n(`expected ${g()} but got ${JSON.stringify(b)}`,w)}),s.extend("intersect",(b,{list:m,toString:g},w,S)=>{if(!m.length)return[b];let I;for(const F of m){const N=s.resolve(b,F,w,!0)[0];if(!Ie(N))if(Ie(I))I=N;else{if(typeof I!=typeof N)throw new n(`expected ${g()} but got ${JSON.stringify(b)}`,w);if(typeof N=="object")h(I??(I={}),N);else if(I!==N)throw new n(`expected ${g()} but got ${JSON.stringify(b)}`,w)}}return!S&&Jr(b)&&h(I,b),[I]}),s.extend("transform",(b,{inner:m,callback:g,preserve:w},S)=>{const[I,F=b]=s.resolve(b,m,S,!0);return w?[g(I)]:[g(I),g(F)]});var _={};function k(b,m,g){_[b]=g,Object.assign(s,{[b](...w){const S=new s({type:b});return m.forEach((I,F)=>{switch(I){case"sKey":S.sKey=w[F]??s.string();break;case"inner":S.inner=s.from(w[F]);break;case"list":S.list=w[F].map(s.from);break;case"dict":S.dict=Kt(w[F],s.from);break;case"bits":{S.bits={};for(const N in w[F])typeof w[F][N]=="number"&&(S.bits[N]=w[F][N]);break}case"callback":{const N=S.callback=w[F];N.toJSON||(N.toJSON=()=>N.toString());break}case"constructor":{const N=S.constructor=w[F];typeof N=="function"&&(N.toJSON||(N.toJSON=()=>N.name));break}default:S[I]=w[F]}}),b==="object"||b==="dict"?S.meta.default={}:b==="array"||b==="tuple"?S.meta.default=[]:b==="bitset"&&(S.meta.default=0),S}})}re(k,"defineMethod"),k("is",["constructor"],({constructor:b})=>typeof b=="function"?b.name:b),k("any",[],()=>"any"),k("never",[],()=>"never"),k("const",["value"],({value:b})=>typeof b=="string"?JSON.stringify(b):b),k("string",[],()=>"string"),k("number",[],()=>"number"),k("boolean",[],()=>"boolean"),k("bitset",["bits"],()=>"bitset"),k("function",[],()=>"function"),k("array",["inner"],({inner:b})=>`${b.toString(!0)}[]`),k("dict",["inner","sKey"],({inner:b,sKey:m})=>`{ [key: ${m.toString()}]: ${b.toString()} }`),k("tuple",["list"],({list:b})=>`[${b.map(m=>m.toString()).join(", ")}]`),k("object",["dict"],({dict:b})=>Object.keys(b).length===0?"{}":`{ ${Object.entries(b).map(([m,g])=>`${m}${g.meta.required?"":"?"}: ${g.toString()}`).join(", ")} }`),k("union",["list"],({list:b},m)=>{const g=b.map(({toString:w})=>w()).join(" | ");return m?`(${g})`:g}),k("intersect",["list"],({list:b})=>`${b.map(m=>m.toString(!0)).join(" & ")}`),k("transform",["inner","callback","preserve"],({inner:b},m)=>b.toString(m)),e.exports=s}});const A=xh();var Rs=(t=>(t[t.debug=-1]="debug",t[t.log=0]="log",t[t.info=1]="info",t[t.warn=2]="warn",t[t.error=3]="error",t[t.silent=4]="silent",t))(Rs||{});const Ts=globalThis||window,Os=Symbol.for("__IPE_LOGGER_COLOR_MAP__");Ts[Os]||(Ts[Os]=new Map);const Ls=Ts[Os];function rn(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i),e=(e>>>0)*16777619;return e>>>0}const tl=[[350,360],[0,15],[15,30],[200,230],[230,250],[250,280],[280,310],[310,330],[140,160],[160,180]];function kh(t,e){const i=tl.length,r=rn(t)%i,[n,s]=tl[r],o=s-n,a=rn(t+":"+e),c=n+a%(o||1),l=rn(t+":s"),u=rn(t+":l");let d,y;if(e==="name")d=62+l%18,y=30+u%12;else{const p=c>=0&&c<50||c>330&&c<360,h=c>=200&&c<=300;d=55+l%20,h?y=55+u%8:p?y=48+u%6:y=50+u%8,d<60&&(d+=5)}return`hsl(${c}, ${d}%, ${y}%)`}function nn(t,e){if(e)return Ls.set(t,e),e;const i=Ls.get(t);if(i)return i;const r=t.startsWith("name:")?"name":"group",n=kh(t,r);return Ls.set(t,n),n}let il=class Bf{constructor(e={}){this._custom=i=>{if(!this._enabled(i.level))return rl;const[r,n]=this._prefix(i.label);return this._consoleMethod(i.method).bind(console,r,...n)},this._name=e.name,this._nameColor=e.color,this._groupPath=e._groupPath?[...e._groupPath]:[],this._dynamicLevels={...e._dynamicLevels},this._levelRef=e._levelRef??{value:e.level??1},this._name&&nn(`name:${this._name}`,this._nameColor),this._installBuiltinLevels();for(const i of Object.keys(this._dynamicLevels))this._installLevelGetter(i,this._dynamicLevels[i]);return Eh(this)}get level(){return this._levelRef.value}set level(e){this._levelRef.value=e}group(e,i){return e&&nn(`group:${e}`,i?.color),new Bf({name:this._name,color:this._nameColor,_groupPath:[...this._groupPath,e],_dynamicLevels:this._dynamicLevels,_levelRef:this._levelRef})}defineLevel(e,i){this._dynamicLevels[e]={...i},this._installLevelGetter(e,i)}get debug(){return this._method("debug")}get log(){return this._method("log")}get info(){return this._method("info")}get warn(){return this._method("warn")}get error(){return this._method("error")}_installBuiltinLevels(){}_installLevelGetter(e,i){Object.defineProperty(this,e,{configurable:!0,enumerable:!1,get:()=>this._custom(i)})}_method(e){const i=Sh[e];if(!this._enabled(i.level))return rl;const[r,n]=this._prefix(i.label);return this._consoleMethod(e).bind(console,r,...n)}_consoleMethod(e){return(console[e]||console.log).bind(console)}_enabled(e){return e>=this._levelRef.value&&this._levelRef.value!==4}_prefix(e){const i=[];let r="";if(this._name){const n=nn(`name:${this._name}`,this._nameColor);r+=`%c${this._name}%c`,i.push(`background:${n}; color:#fff; padding:1px 4px; border-radius:2px; font-weight:700;`,nl)}if(e&&(r+=` ${e}`),this._groupPath.length){const n=this._groupPath.join("/"),s=nn(`group:${n}`);r+=` %c${n}%c`,i.push(`color:${s}; text-decoration: underline;`,nl)}return[r,i]}};const rl=()=>{},nl="color:inherit; background:transparent; text-decoration:none;",Sh={debug:{level:-1,label:"",method:"debug"},log:{level:0,label:"",method:"log"},info:{level:1,label:"[I]",method:"info"},warn:{level:2,label:"[W]",method:"warn"},error:{level:3,label:"[E]",method:"error"}};function Eh(t){const e=function(i,r){return t.group(i,r)};return new Proxy(e,{get(i,r,n){return t[r]},set(i,r,n){return t[r]=n,!0},apply(i,r,n){return t.group(n[0],n[1])},has(i,r){return r in t}})}function sl(t){return new il(t)}function Ns(t){if(typeof globalThis.structuredClone=="function")try{return globalThis.structuredClone(t)}catch{}return Mi(t,new WeakMap)}function Mi(t,e){if(typeof t!="object"||t===null)return t;const i=e.get(t);if(i)return i;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t.source,t.flags);if(t instanceof URL)return new URL(t.toString());if(t instanceof URLSearchParams)return new URLSearchParams(t.toString());if(t instanceof ArrayBuffer)return t.slice(0);if(ArrayBuffer.isView(t)){if(t instanceof DataView)return new DataView(t.buffer.slice(0),t.byteOffset,t.byteLength);const o=t,a=o.constructor;return new a(o.buffer.slice(0),o.byteOffset,o.length)}if(t instanceof Map){const o=new Map;return e.set(t,o),t.forEach((a,c)=>{o.set(Mi(c,e),Mi(a,e))}),o}if(t instanceof Set){const o=new Set;return e.set(t,o),t.forEach(a=>o.add(Mi(a,e))),o}if(Array.isArray(t)){const o=new Array(t.length);e.set(t,o);for(let a=0;a<o.length;a++)o[a]=Mi(t[a],e);return o}const r=Object.getPrototypeOf(t),n=Object.create(r);e.set(t,n);const s=Object.getOwnPropertyDescriptors(t);for(const o of Reflect.ownKeys(s)){const a=s[o];"value"in a&&(a.value=Mi(a.value,e)),Object.defineProperty(n,o,a)}return n}function Vt(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}const ol=function(t){const e=this.constructor.prototype,i=Reflect.get(e,t,e);function r(...n){return Reflect.apply(i,r,n)}Reflect.setPrototypeOf(r,e);for(const n of Reflect.ownKeys(i)){const s=Reflect.getOwnPropertyDescriptor(i,n);s&&Reflect.defineProperty(r,n,s)}return r};ol.prototype=Object.create(Function.prototype);const $h=ol;function At(t,...e){const i=Ns(t||{});for(const r of e)if(r!=null)for(const n of Reflect.ownKeys(r)){const s=r[n];if(typeof s>"u")continue;if(s===null){delete i[n];continue}const o=i[n];Vt(o)&&Vt(s)?i[n]=At(o,s):i[n]=Ns(s)}return i}var ot=(t=>(t.BODY_USED="BODY_USED",t.NO_BODY_READER="NO_BODY_READER",t.TIMEOUT="TIMEOUT",t.NETWORK_ERROR="NETWORK_ERROR",t.BODY_NOT_ALLOWED="BODY_NOT_ALLOWED",t.HOOK_CONTEXT_CHANGED="HOOK_CONTEXT_CHANGED",t.ABORTED_BY_HOOK="ABORTED_BY_HOOK",t.INVALID_HOOK_CALLBACK="INVALID_HOOK_CALLBACK",t.UNEXPECTED_HOOK_RETURN="UNEXPECTED_HOOK_RETURN",t.UNSUPPORTED_RESPONSE_TYPE="UNSUPPORTED_RESPONSE_TYPE",t.FEATURE_MOVED_TO_PLUGIN="FEATURE_MOVED_TO_PLUGIN",t.BODY_TRANSFORM_ERROR="BODY_TRANSFORM_ERROR",t))(ot||{});class Ve extends Error{constructor(i,r,n,s){super(r,s);j(this,"name","FexiosError");this.code=i,this.context=n}static is(i,r){return!(i instanceof Ve)||i instanceof sn?!1:r?i.code===r:!0}}class sn extends Ve{constructor(i,r,n){super(r.statusText,i,void 0,n);j(this,"name","FexiosResponseError");this.response=r}static is(i){return i instanceof sn}}var pt;(t=>{t.makeSearchParams=r=>{if(!r)return new URLSearchParams;if(r instanceof URLSearchParams)return r;if(typeof r!="object"||r?.constructor!==Object)throw new TypeError("only plain object is supported");const n=new URLSearchParams,s=(c,l)=>{l!=null&&n.append(c,l)},o=(c,l)=>{l!=null&&n.set(c,l)},a=(c,l)=>{if(l!=null){if(Array.isArray(l)){for(const u of l)s(c,u?.toString());return}if(typeof l=="object"&&l.constructor===Object){for(const[u,d]of Object.entries(l)){if(d==null)continue;const y=u.endsWith("[]"),p=y?u.slice(0,-2):u,h=`${c}[${p}]`;if(y){const _=`${h}[]`;if(Array.isArray(d))for(const k of d)s(_,k?.toString());else typeof d=="object"&&d!==null&&d.constructor===Object?a(`${h}[]`,d):s(_,d?.toString())}else if(Array.isArray(d))for(const _ of d)s(h,_?.toString());else typeof d=="object"&&d!==null&&d.constructor===Object?a(h,d):o(h,d?.toString())}return}o(c,l?.toString())}};for(const[c,l]of Object.entries(r))a(c,l);return n},t.makeQueryString=r=>(0,t.makeSearchParams)(r).toString(),t.makeURL=(r,n,s,o)=>{const a=typeof window<"u"&&window.location?.origin||"http://localhost",c=typeof r=="string"?new URL(r,o??a):new URL(r),l=(0,t.toQueryRecord)(c.searchParams),u=(0,t.mergeQueries)(l,n||{}),d=(0,t.makeSearchParams)(u);return c.search=d.toString(),typeof s<"u"&&(c.hash=s),c},t.toQueryRecord=r=>{typeof r=="string"&&(r=(0,t.fromString)(r));const n={},s=a=>{if(!a.includes("["))return{path:[a],forceArray:!1};const l=[a.slice(0,a.indexOf("["))],u=/\[([^\]]*)\]/g;let d,y=!1,p=!1;for(;d=u.exec(a);)d[1]===""?(y=!0,p=!0):(l.push(d[1]),p=!1);return y&&p&&(l[l.length-1]=l[l.length-1]+"[]"),{path:l,forceArray:y}},o=(a,c,l,u)=>{let d=a;for(let y=0;y<c.length;y++){const p=c[y];y===c.length-1?u?d[p]===void 0?d[p]=[l]:Array.isArray(d[p])?d[p].push(l):d[p]=[d[p],l]:d[p]===void 0?d[p]=l:Array.isArray(d[p])?d[p].push(l):d[p]=[d[p],l]:((d[p]===void 0||typeof d[p]!="object"||Array.isArray(d[p]))&&(d[p]={}),d=d[p])}};for(const[a,c]of r.entries()){const{path:l,forceArray:u}=s(String(a));o(n,l,c?.toString(),u)}return n},t.fromString=r=>{const n=r.trim();if(!n)return new URLSearchParams;if(n.startsWith("?"))return new URLSearchParams(n.slice(1));const s=n.indexOf("?");if(s>=0){const o=n.indexOf("#",s+1),a=n.slice(s+1,o>=0?o:void 0);return new URLSearchParams(a)}return new URLSearchParams(n)},t.mergeQueries=(...r)=>{const n={};for(const s of r)s!=null&&i(n,e(s));return n};function e(r){if(!r)return{};if(r instanceof URLSearchParams||r instanceof FormData||r instanceof Map)return(0,t.toQueryRecord)(r);if(typeof r=="string")return(0,t.toQueryRecord)((0,t.fromString)(r));if(Vt(r))return r;throw new TypeError(`unsupported type transformation, got: ${Object.prototype.toString.call(r)}`)}function i(r,n){for(const[s,o]of Object.entries(n)){if(o===void 0)continue;if(o===null){delete r[s];continue}const a=r[s];Vt(a)&&Vt(o)?i(a,o):r[s]=Ns(o)}}})(pt||(pt={}));class Ph{constructor(e,i,r){j(this,"ok");j(this,"status");j(this,"statusText");j(this,"headers");j(this,"url");j(this,"redirected");this.rawResponse=e,this.data=i,this.responseType=r,["ok","status","statusText","headers","url","redirected"].forEach(n=>{Reflect.defineProperty(this,n,{get:()=>e[n]})})}}const al=t=>{const e=t.reduce((n,s)=>n+s.length,0),i=new Uint8Array(e);let r=0;for(const n of t)i.set(n,r),r+=n.length;return i};async function Ch(t,e,i){const r=t.getReader();if(!r)throw new Ve(ot.NO_BODY_READER,"Failed to get ReadableStream from response body");const n=[];let s=0;try{for(;;){const{done:a,value:c}=await r.read();if(a)break;n.push(c),s+=c.length,i&&e>0&&i(s/e,al(n))}}finally{r.releaseLock?.()}const o=al(n);return i?.(1,o),o}const Ih=t=>{if(t){if(t.includes("application/json")||t.endsWith("+json"))return"json";if(t.startsWith("text/"))return"text";if(t.includes("multipart/form-data")||t.includes("application/x-www-form-urlencoded"))return"form";if(/^image\//.test(t)||/^video\//.test(t)||/^audio\//.test(t)||t.includes("application/pdf"))return"blob";if(t.includes("application/octet-stream")||t.includes("application/zip")||t.includes("application/x-tar")||t.includes("application/x-7z-compressed")||t.includes("application/x-gzip"))return"arrayBuffer"}};async function ll(t,e,i,r,n){const s=t.clone(),o=t.headers.get("content-type")?.toLowerCase()??"",a=t.headers.get("content-length"),c=a?Number(a):0,l=t.headers.get("upgrade")?.toLowerCase(),u=t.headers.get("connection")?.toLowerCase();if(e==="ws"||e==="stream")throw new Ve(ot.FEATURE_MOVED_TO_PLUGIN,`responseType "${String(e)}" has been moved to plugins. Use "fexios/plugins" (fx.plugin(pluginWebSocket) / fx.plugin(pluginSSE)) and call fx.ws()/fx.sse() instead.`);if(l==="websocket"&&u==="upgrade")throw new Ve(ot.FEATURE_MOVED_TO_PLUGIN,'WebSocket upgrade response detected. WebSocket support has been moved to plugins. Please use "fexios/plugins" and call fx.ws().');if(o.includes("text/event-stream"))throw new Ve(ot.FEATURE_MOVED_TO_PLUGIN,'SSE (text/event-stream) response detected. SSE support has been moved to plugins. Please use "fexios/plugins" and call fx.sse().');let d=e??Ih(o)??"text";const y=/\bcharset=([^;]+)/i.exec(o)?.[1]?.trim()||"utf-8",p=new TextDecoder(y);let h;try{if(d==="form")h=await s.formData();else{const P=await Ch(s.body,c,i);if(d==="arrayBuffer")h=P.buffer.slice(P.byteOffset,P.byteOffset+P.byteLength);else if(d==="blob")h=new Blob([P],{type:o||"application/octet-stream"});else if(d==="text"){const b=p.decode(P);if(e)h=b;else{const m=b.trim();if(m.startsWith("{")&&m.endsWith("}")||m.startsWith("[")&&m.endsWith("]"))try{h=JSON.parse(m),d="json"}catch{h=b}else h=b}}else if(d==="json"){const b=p.decode(P);h=b.length?JSON.parse(b):null}else h=P}}catch(P){if(!(P instanceof Error))throw P;try{h=await s.text(),d="text"}catch{throw new Ve(ot.BODY_TRANSFORM_ERROR,`Failed to transform response body to ${d}`,void 0,{cause:P})}}const _=new Ph(t,h,d),k=r?.(_);if(typeof k=="boolean"?k:!_.ok)throw new sn(_.statusText,_);return _}var dr;(t=>{t.makeHeaders=e=>{if(!e)return new Headers;if(e instanceof Headers)return new Headers(e);const i=new Headers;if(e instanceof Map){for(const[r,n]of e.entries())if(n!=null)if(Array.isArray(n))for(const s of n)s!=null&&i.append(r,String(s));else i.append(r,String(n));return i}if(Vt(e)){for(const[r,n]of Object.entries(e))if(n!=null)if(Array.isArray(n))for(const s of n)s!=null&&i.append(r,String(s));else i.append(r,String(n));return i}throw new TypeError("only plain object, Map/ReadonlyMap, or Headers is supported")},t.toHeaderRecord=e=>{if(e instanceof Headers){const i={};return e.forEach((r,n)=>{i[n]=i[n]?[...i[n],r]:[r]}),i}if(e instanceof Map){const i={};for(const[r,n]of e.entries())if(n!=null)if(Array.isArray(n)){const s=n.filter(o=>o!=null).map(o=>String(o));s.length&&(i[r]=(i[r]??[]).concat(s))}else{const s=String(n);i[r]=i[r]?[...i[r],s]:[s]}return i}throw new TypeError(`unsupported type transformation, got: ${Object.prototype.toString.call(e)}`)},t.mergeHeaders=(...e)=>{const i=new Headers,r=n=>{for(const[s,o]of Object.entries(n))if(o!==void 0){if(o===null){i.delete(s);continue}if(Array.isArray(o)){i.delete(s);for(const a of o)a!=null&&i.append(s,String(a))}else i.set(s,String(o))}};for(const n of e){if(n==null)continue;if(n instanceof Headers){n.forEach((o,a)=>{i.set(a,o)});continue}if(Vt(n)){r(n);continue}const s=(0,t.toHeaderRecord)(n);for(const[o,a]of Object.entries(s)){i.delete(o);for(const c of a)i.append(o,c)}}return i}})(dr||(dr={}));const $e=class $e extends $h{constructor(i={}){super("request");j(this,"baseConfigs");j(this,"hooks",[]);j(this,"mergeQueries",pt.mergeQueries);j(this,"mergeHeaders",dr.mergeHeaders);j(this,"interceptors",{request:this.createInterceptor("beforeRequest"),response:this.createInterceptor("afterResponse")});j(this,"create",$e.create);j(this,"_plugins",new Map);j(this,"mergeQuery",this.mergeQueries);this.baseConfigs=At($e.DEFAULT_CONFIGS,i),$e.ALL_METHODS.forEach(r=>this.createMethodShortcut(r.toLowerCase()))}get defaults(){return this.baseConfigs}set defaults(i){this.baseConfigs=i}attachLegacyAliases(i){const r=()=>i.request,n=()=>i.runtime,s=(o,a)=>{try{Object.defineProperty(i,o,{configurable:!0,...a})}catch{}};s("url",{get:()=>r().url,set:o=>{r().url=o?.toString?.()??String(o)}}),s("method",{get:()=>r().method,set:o=>r().method=o}),s("headers",{get:()=>r().headers,set:o=>r().headers=o}),s("query",{get:()=>r().query,set:o=>r().query=o}),s("body",{get:()=>r().body,set:o=>r().body=o}),s("baseURL",{get:()=>r().baseURL,set:o=>r().baseURL=o}),s("timeout",{get:()=>r().timeout,set:o=>r().timeout=o}),s("credentials",{get:()=>r().credentials,set:o=>r().credentials=o}),s("cache",{get:()=>r().cache,set:o=>r().cache=o}),s("mode",{get:()=>r().mode,set:o=>r().mode=o}),s("fetch",{get:()=>r().fetch,set:o=>r().fetch=o}),s("shouldThrow",{get:()=>r().shouldThrow,set:o=>r().shouldThrow=o}),s("responseType",{get:()=>r().responseType,set:o=>r().responseType=o}),s("abortController",{get:()=>n().abortController,set:o=>n().abortController=o}),s("onProgress",{get:()=>n().onProgress,set:o=>n().onProgress=o}),s("customEnv",{get:()=>n().customEnv,set:o=>n().customEnv=o}),s("rawRequest",{get:()=>r().rawRequest,set:o=>r().rawRequest=o}),s("data",{get:()=>i.response?i.response.data:void 0,set:o=>{i.response&&(i.response.data=o)}})}finalizeContext(i,r){const n=i.response,s=n?.rawResponse??i.rawResponse,o=i.request;Object.defineProperties(i,{url:{get:()=>s?.url||r},data:{get:()=>n.data},headers:{get:()=>s.headers},responseType:{get:()=>n.responseType},rawRequest:{get:()=>o.rawRequest}})}async request(i,r){const n=this;let s=r||{};typeof i=="string"||i instanceof URL?s={...r||{},url:i}:typeof i=="object"&&(s=i);const{abortController:o,onProgress:a,customEnv:c,...l}=s;let u={get app(){return n},request:{...l,url:s.url?.toString?.()??String(s.url)},runtime:{abortController:o,onProgress:a,customEnv:c},response:void 0,rawResponse:void 0,url:"",headers:{},query:{}};if(this.attachLegacyAliases(u),u=await this.emit("beforeInit",u),u[$e.FINAL_SYMBOL])return u;if("customEnv"in this.baseConfigs&&(u.runtime.customEnv=At({},this.baseConfigs.customEnv,u.runtime.customEnv)),u.request=this.applyDefaults(u.request),$e.METHODS_WITHOUT_BODY.includes(u.request.method?.toLocaleLowerCase?.())&&u.request.body)throw new Ve(ot.BODY_NOT_ALLOWED,`Request method "${u.request.method}" does not allow body`);if(u=await this.emit("beforeRequest",u),u[$e.FINAL_SYMBOL])return u;let d;const y={},p=u.request;if(typeof p.body<"u"&&p.body!==null&&(p.body instanceof Blob||p.body instanceof FormData||p.body instanceof URLSearchParams?d=p.body:typeof p.body=="object"&&p.body!==null?(d=JSON.stringify(p.body),p.headers=this.mergeHeaders(p.headers,{"Content-Type":"application/json"})):d=p.body),!dr.makeHeaders(p.headers||{}).get("content-type")&&d&&(d instanceof FormData||d instanceof URLSearchParams?y["content-type"]=null:typeof d=="string"&&typeof p.body=="object"?y["content-type"]="application/json":d instanceof Blob&&(y["content-type"]=d.type||"application/octet-stream")),p.body=d,u=await this.emit("afterBodyTransformed",u),u[$e.FINAL_SYMBOL])return u;const _=u.runtime.abortController??(globalThis.AbortController?new AbortController:void 0),k=globalThis.location?.href||"http://localhost",P=new URL(u.request.baseURL||this.baseConfigs.baseURL||k,k),b=new URL(u.request.url,P),m=pt.makeURL(b,u.request.query,b.hash).toString(),g=new Request(m,{method:u.request.method||"GET",credentials:u.request.credentials,cache:u.request.cache,mode:u.request.mode,headers:dr.mergeHeaders(this.baseConfigs.headers,u.request.headers||{},y),body:u.request.body,signal:_?.signal});if(u.request.rawRequest=g,u=await this.emit("beforeActualFetch",u),u[$e.FINAL_SYMBOL])return u;const w=u.request.timeout??this.baseConfigs.timeout??60*1e3,S=u.request.shouldThrow??this.baseConfigs.shouldThrow;if(u.request.url.startsWith("ws")||u.request.responseType==="ws")throw new Ve(ot.FEATURE_MOVED_TO_PLUGIN,'WebSocket support has been moved to plugins. Use "fexios/plugins" and call fx.ws() instead.',u);if(u.request.responseType==="stream")throw new Ve(ot.FEATURE_MOVED_TO_PLUGIN,'SSE support has been moved to plugins. Use "fexios/plugins" and call fx.sse() instead.',u);let I;try{_&&(I=w>0?setTimeout(()=>{_.abort()},w):void 0);const N=await(u.request.fetch||this.baseConfigs.fetch||globalThis.fetch)(u.request.rawRequest).catch(G=>{throw I&&clearTimeout(I),_?.signal.aborted?new Ve(ot.TIMEOUT,`Request timed out after ${w}ms`,u):new Ve(ot.NETWORK_ERROR,G.message,u)});return I&&clearTimeout(I),u.rawResponse=N,await this.emit("afterRawResponse",u),u[$e.FINAL_SYMBOL]?u:(u.response=await ll(N,u.request.responseType,(G,K)=>{u.runtime.onProgress?.(G,K)},S,w),u.rawResponse=u.response.rawResponse,this.finalizeContext(u,m),this.emit("afterResponse",u))}catch(F){throw I&&clearTimeout(I),F}}applyDefaults(i){const r=i,n=globalThis.location?.href||"http://localhost",s=r.baseURL||this.baseConfigs.baseURL||n,o=new URL(s,n),a=new URL(r.url.toString(),o),c=pt.toQueryRecord(o.searchParams),l=pt.toQueryRecord(a.searchParams),u=pt.mergeQueries(c,l);a.search=pt.makeSearchParams(u).toString(),r.url=a.toString();const d=pt.mergeQueries(this.baseConfigs.query,r.query);return r.query&&this.restoreNulls(d,r.query),r.query=d,r}restoreNulls(i,r){if(!(!r||typeof r!="object"))for(const[n,s]of Object.entries(r))s===null?i[n]=null:Vt(s)&&((!i[n]||typeof i[n]!="object")&&(i[n]={}),this.restoreNulls(i[n],s))}async emit(i,r,n={shouldHandleShortCircuitResponse:!0}){const s=this.hooks.filter(a=>a.event===i);if(s.length===0)return r;const o=async(a,c)=>{const l=a;if(l.rawResponse=c,!l.request?.rawRequest)try{l.request.rawRequest=new Request(l.request.url,{method:l.request.method||"GET",headers:l.request.headers,body:l.request.body})}catch{}const u=await ll(c,a.request?.responseType,(d,y)=>a.runtime?.onProgress?.(d,y),a.request?.shouldThrow??this.baseConfigs.shouldThrow,a.request?.timeout??this.baseConfigs.timeout??60*1e3);if(l.response=u,l.rawResponse=u.rawResponse,this.finalizeContext(l,c.url||""),i!=="afterResponse"){const d=await this.emit("afterResponse",l);return d[$e.FINAL_SYMBOL]=!0,d}else return l[$e.FINAL_SYMBOL]=!0,l};for(let a=0;a<s.length;a++){const c=s[a],l=`${String(i)}#${c.action.name||`anonymous#${a}`}`,u=Symbol("FEXIOS_HOOK_CTX_MARK");try{r[u]=u}catch{}const d=await c.action.call(this,r);try{delete r[u]}catch{}if(d===!1)throw new Ve(ot.ABORTED_BY_HOOK,`Request aborted by hook "${l}"`,r);if(d instanceof Response){if(n.shouldHandleShortCircuitResponse!==!1)return o(r,d);r.rawResponse=d}else d&&typeof d=="object"&&d[u]===u&&(r=d)}return r}on(i,r,n=!1){if(typeof r!="function")throw new Ve(ot.INVALID_HOOK_CALLBACK,`Hook should be a function, but got "${typeof r}"`);return this.hooks[n?"unshift":"push"]({event:i,action:r}),this}off(i,r){return i==="*"||!i?this.hooks=this.hooks.filter(n=>n.action!==r):this.hooks=this.hooks.filter(n=>n.event!==i||n.action!==r),this}createInterceptor(i){return{handlers:()=>this.hooks.filter(r=>r.event===i).map(r=>r.action),use:(r,n=!1)=>this.on(i,r,n),clear:()=>{this.hooks=this.hooks.filter(r=>r.event!==i)}}}createMethodShortcut(i){return Reflect.defineProperty(this,i,{get:()=>(r,n,s)=>($e.METHODS_WITHOUT_BODY.includes(i.toLocaleLowerCase())?s=n:(s=s||{},s.body=n),this.request(r,{...s,method:i}))}),this}extends(i){const r=new $e(At(this.baseConfigs,i));return r.hooks=[...this.hooks],r._plugins=new Map(this._plugins),r._plugins.forEach(async n=>{await r.plugin(n)}),r}static create(i){return new $e(i)}plugin(i){if(typeof i?.name=="string"&&typeof i?.install=="function"){if(this._plugins.has(i.name))return this;const r=i.install(this);if(this._plugins.set(i.name,i),r instanceof $e)return r}return this}uninstall(i){return typeof i=="string"&&(i=this._plugins.get(i)),i&&(i?.uninstall?.(this),this._plugins.delete(i.name)),this}};j($e,"version","6.1.1"),j($e,"FINAL_SYMBOL",Symbol("FEXIOS_FINAL_CONTEXT")),j($e,"DEFAULT_CONFIGS",{baseURL:"",timeout:0,credentials:void 0,headers:{},query:{},responseType:void 0,shouldThrow(i){return!i.ok},fetch:globalThis.fetch}),j($e,"ALL_METHODS",["get","post","put","patch","delete","head","options","trace"]),j($e,"METHODS_WITHOUT_BODY",["get","head","options","trace"]);let fr=$e;const Ah=fr.create;Ah();var on;(t=>{function e(r){return Array.isArray(r)?r.join("|"):typeof r=="boolean"||r===null?r?"1":void 0:typeof r=="number"?""+r:r}t.normalizeParamValue=e;function i(r){const n=o=>o&&(o instanceof URLSearchParams||o instanceof FormData);if(r==null)return;const s=new FormData;if(n(r))return r.forEach((o,a)=>{const c=e(o);c!=null&&s.append(a,c)}),s;if(Vt(r))return Object.entries(r).forEach(([o,a])=>{const c=e(a);c!=null&&s.append(o,c)}),s}t.normalizeBody=i})(on||(on={}));var hr=(t=>(t.HTTP_ERROR="HTTP_ERROR",t.LOGIN_FAILED="LOGIN_FAILED",t.LOGIN_RETRY_LIMIT_EXCEEDED="LOGIN_RETRY_LIMIT_EXCEEDED",t.TOKEN_RETRY_LIMIT_EXCEEDED="TOKEN_RETRY_LIMIT_EXCEEDED",t))(hr||{});class et extends Error{constructor(i,r="",n){super();j(this,"name","WikiSaikouError");this.code=i,this.message=r,this.cause=n}static is(i,r){return i instanceof this&&(r===void 0||i.code===r)}}class Rt extends Error{constructor(i,r){super();j(this,"name","MediaWikiApiError");j(this,"code");this.errors=i,this.cause=r,this.errors=Rt.normalizeErrors(i),this.message=i.map(n=>n.text).filter(Boolean).join(`
4
+ `),this.code=this.isBadTokenError()?"badtoken":this.errors[0]?.code||"Unknown Error"}get firstError(){return this.errors[0]}isBadTokenError(){return this.errors.some(i=>i.code==="badtoken")||["NeedToken","WrongToken"].includes(this.cause?.data?.login?.result)}toString(){return`[${this.name} ${this.code}]`}static is(i){return i instanceof this}static normalizeErrors(i){return Array.isArray(i)===!1?[]:i.filter(r=>typeof r=="object"&&!!r?.code).map(r=>r.text?r:r.info?{...r,text:r.info}:r["*"]?{...r,text:r["*"]}:{...r,text:""})}}(t=>{function e(s){if(s==null)return;if(s?.response?.data!==void 0)return s.response.data;if(s?.data!==void 0)return s.data;const o=s instanceof Error?s.cause:void 0;return o?.response?.data!==void 0?o.response.data:o?.data!==void 0?o.data:s||void 0}function i(s){return r(s).length>0}t.includesMediaWikiApiError=i,t.normalizeMwApiErrors=Rt.normalizeErrors;function r(s){let o=e(s);if(typeof o!="object"||o===null)return[];const a=o?.error,c=o?.errors,l=[];return a&&l.push(a),Array.isArray(c)&&l.push(...c),(0,t.normalizeMwApiErrors)(l)}t.extractMediaWikiApiErrors=r;function n(s){if(Rt.is(s))return s.isBadTokenError();{const o=r(s);return new Rt(o).isBadTokenError()}}t.isBadTokenError=n})(et||(et={}));const cl=Symbol.for("__FEXIOS_SAIKOU__");function ul(t){const e=t instanceof fr?t:new fr({baseURL:t instanceof URL?t.toString():String(t),responseType:"json"});return e[cl]||(Reflect.defineProperty(e,cl,{get:()=>!0,enumerable:!1,configurable:!1}),e.on("beforeInit",i=>{if(i.request.method?.toLowerCase()!=="post")return i;if(i.request.body===void 0||i.request.body===null)return i.request.body=void 0,i;const r=i.request.body=on.normalizeBody(i.request.body),n=new URLSearchParams(i.request.query);return r.has("format")&&n.delete("format"),r.has("formatversion")&&n.delete("formatversion"),r.has("action")&&n.delete("action"),r.has("origin")&&(n.set("origin",""+r.get("origin")),r.delete("origin")),i.request.query=Object.fromEntries(n.entries()),i}),e.on("beforeInit",i=>(i.request.query=pt.mergeQueries({},on.normalizeBody(i.request.query)),i)),e.on("beforeRequest",i=>{const r=new URL(i.request.url),n=pt.mergeQueries(r.searchParams,i.query);if(globalThis.location&&(!n.origin&&location.origin!==r.origin?(n.origin=location.origin,e.baseConfigs.credentials="include",e.baseConfigs.mode="cors"):location.origin===r.origin&&(delete n.origin,e.baseConfigs.credentials=void 0,e.baseConfigs.mode=void 0)),n.origin){const s=encodeURIComponent(n.origin).replace(/\./g,"%2E");delete n.origin,i.request.query=n,i.request.url=`${r.origin}${r.pathname}?origin=${s}`}else i.request.query=n;return i}),e._tokens=new Map,e.on("afterResponse",i=>{const{data:r}=i,n=i.runtime.customEnv?.mwTokenName;n&&et.isBadTokenError(r)&&e._tokens.delete(n);const s=r?.query?.tokens;s&&typeof s=="object"&&Object.entries(s).forEach(([a,c])=>{typeof c=="string"&&e._tokens.set(a.replace(/token$/i,"").toLowerCase(),c)});const o=r?.login?.token;return typeof o=="string"&&e._tokens.set("login",o),i})),e}const dl=(t,e,i)=>{let r={...an.DEFAULT_CONFIGS};if(typeof t=="string"?r=At(r,{baseURL:t,fexiosConfigs:e||{},defaultParams:i||{},throwOnApiError:!1}):typeof t=="object"&&t!==null&&(r=At(r,t)),!r.baseURL&&typeof window=="object"&&window.mediaWiki){const{wgServer:n,wgScriptPath:s}=window.mediaWiki?.config?.get(["wgServer","wgScriptPath"])||{};typeof n=="string"&&typeof s=="string"&&(r.baseURL=`${n}${s}/api.php`)}if(typeof r.baseURL!="string")throw new Error("baseURL is required");return r},Rh=()=>{},Th=async(t,e)=>{let i=0;const{retry:r=3,onRetry:n=Rh,shouldRetry:s=()=>!0}=e;let o;do try{return await t()}catch(a){if(o=a,s(a,i))n(a,i),i++;else throw a}while(i<r);throw o||new Error("Retry failed")};const sr=class sr{constructor(e,i,r){j(this,"config");j(this,"version","7.5.0");j(this,"request");j(this,"token",this.getToken);const n=this.config=dl(e,i,r);this.request=ul(n.baseURL)}setBaseURL(e){return this.config.baseURL=e,this.request.baseConfigs.baseURL=e,this}async get(e,i){const r=At({},this.config.fexiosConfigs,{query:pt.mergeQueries(this.config.defaultParams,e)},i);return this.runRequestWithApiErrorMapping(()=>this.request.get("",r))}async post(e,i){return this.runRequestWithApiErrorMapping(()=>this.request.post("",e,At({},this.config.fexiosConfigs,{query:this.config.defaultParams},i)))}async runRequestWithApiErrorMapping(e){try{const i=await e();return this.handleApiResponse(i)}catch(i){throw this.config.throwOnApiError&&et.includesMediaWikiApiError(i)?new Rt(et.extractMediaWikiApiErrors(i),i):i}}throwIfApiError(e){const i=et.extractMediaWikiApiErrors(e);if(i.length>0)throw new Rt(i,e)}handleApiResponse(e){return this.config.throwOnApiError&&this.throwIfApiError(e.data),e}get tokens(){return this.request._tokens}async fetchTokens(e=["csrf"]){return this.config.fexiosConfigs.credentials="include",await this.get({action:"query",meta:"tokens",type:e}),this.tokens}async getToken(e="csrf",i=!1){return(!this.tokens.get(e)||i)&&(this.tokens.delete(e),await this.fetchTokens([e])),this.tokens.get(e)}badToken(e){return this.tokens.delete(e),this.tokens}async postWithToken(e,i,r){const{tokenName:n="token",retry:s=3,noCache:o=!1,fexiosOptions:a}=r||{};if(s<1)throw new et(hr.TOKEN_RETRY_LIMIT_EXCEEDED,"The limit of the number of times to automatically re-acquire the token has been exceeded");let c=0;return Th(async()=>{const l=await this.getToken(e,o||c>0);try{const u=await this.post({[n]:l,...i},At(a||{},{customEnv:{mwTokenName:e}}));if(et.isBadTokenError(u.data))throw u;return u}catch(u){throw et.isBadTokenError(u)||u?.ok===!1||Rt.is(u)?u:new et(hr.HTTP_ERROR,"Network/transport or SDK-internal error (not a MediaWiki API error)",u)}},{retry:s,onRetry:(l,u)=>{c=u+1},shouldRetry:l=>et.isBadTokenError(l)||l?.ok===!1}).catch(l=>{throw et.isBadTokenError(l)||l?.ok===!1?new et(hr.TOKEN_RETRY_LIMIT_EXCEEDED,"Retry attempts for acquiring/using token exhausted",l):l})}postWithEditToken(e){return this.postWithToken("csrf",e)}get baseURL(){return this.config.baseURL}get defaultParams(){return this.config.defaultParams}get defaultOptions(){return this.config.fexiosConfigs}};j(sr,"INIT_DEFAULT_PARAMS",{action:"query",errorformat:"plaintext",format:"json",formatversion:2}),j(sr,"DEFAULT_CONFIGS",{baseURL:void 0,fexiosConfigs:{responseType:"json"},defaultParams:sr.INIT_DEFAULT_PARAMS,throwOnApiError:!1}),j(sr,"createRequestHandler",ul);let an=sr;class Ms extends an{async clientLogin(e,i,r){r||(r={}),!r.logincontinue&&!r.loginreturnurl&&(r.loginreturnurl=location?.origin);const n=await this.postWithToken("login",{action:"clientlogin",username:e,password:i,...r},{tokenName:"logintoken"});if(n?.data?.clientlogin?.status==="PASS")return n.data.clientlogin;throw new et(hr.LOGIN_FAILED,n.data.clientlogin.message,n)}}class Oh extends Ms{constructor(e,i,r){const n=dl(e,{credentials:"include",mode:"cors",...i},{origin:location.origin,...r});super(n)}}class Lh{constructor(e,i={}){this.ctx=e,this.options=i,this._apiClients=new Map,location?.href&&i?.baseURL?.toString()?.startsWith("/")&&(i.baseURL=new URL(i.baseURL,location.origin));const r=this.api=new Ms({baseURL:i.baseURL.toString(),fexiosConfigs:{headers:{"x-api-user-agent":`InPageEdit-NEXT ${e.version}`,...i.headers},...i},throwOnApiError:!0});e.set("api",r),e.set("apiService",this)}getClientByFileRepo(e){const i=new URL(`${e.scriptDirUrl}/api.php`,location.origin),r=i.toString();if(r===this.ctx.root.config.apiConfigs.baseURL?.toString())return this.ctx.api;if(!this._apiClients.has(r)){const n=i.origin===location.origin,s={baseURL:i.toString(),throwOnApiError:!0},o=n?new Ms(s):new Oh(s);o.request.on("beforeRequest",a=>{a.headers=o.request.mergeHeaders(a.headers,{"x-api-user-agent":null,"x-mw-token-name":null})}),this._apiClients.set(r,o)}return this._apiClients.get(r)}}const Ds=(t,e=document)=>e.querySelector(t),Nh=(t,e=document)=>e.querySelectorAll(t);var Mh=Object.create,js=Object.defineProperty,Dh=Object.getOwnPropertyDescriptor,fl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),hl=t=>{throw TypeError(t)},jh=(t,e,i)=>e in t?js(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Uh=(t,e)=>js(t,"name",{value:e,configurable:!0}),Fh=t=>[,,,Mh(t?.[fl("metadata")]??null)],qh=["class","method","getter","setter","accessor","field","value","get","set"],pl=t=>t!==void 0&&typeof t!="function"?hl("Function expected"):t,Bh=(t,e,i,r,n)=>({kind:qh[t],name:e,metadata:r,addInitializer:s=>i._?hl("Already initialized"):n.push(pl(s||null))}),Hh=(t,e)=>jh(e,fl("metadata"),t[3]),zh=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Wh=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&Dh(n,i));Uh(n,i);for(var h=r.length-1;h>=0;h--)c=Bh(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,pl(o)&&(n=o);return Hh(t,n),p&&js(n,i,p),u?l^4?s:p:n},gl,Us,ml;gl=[xe(["wiki","wikiTitle"])];let ln=(bt=class extends(ml=ht){constructor(i){super(i,"currentPage",!1);Ni(this,dt);Ni(this,or);this.ctx=i,je(this,or,wt(this,dt,zf).bind(this)),this.url=new URL(window.location.href),this.isMainPage=void 0,this.wikiTitle=void 0}get logger(){return this.ctx.logger("CURRENT_PAGE")}async start(){await wt(this,dt,Ba).call(this),wt(this,dt,Hf).call(this),window.addEventListener(bt.HISTORY_CHANGE_EVENT,ce(this,or)),this.ctx.emit("current-page/popstate"),this.logger.info("initialized",this.wikiTitle)}stop(){window.removeEventListener(bt.HISTORY_CHANGE_EVENT,ce(this,or))}get params(){return this.url.searchParams}get canonicalUrl(){const i=(Ds('link[rel="alternate"][hreflang="x-default"]')||Ds('link[rel="canonical"]'))?.href;let r=null;return i&&(r=new URL(i,location.origin)),Reflect.defineProperty(this,"canonicalUrl",{get:()=>r}),r}get wikiAction(){const i=this.params.get("action")||"view";return this.ctx.bail("current-page/resolve-action",i)??i}},dt=new WeakSet,Ba=async function(){await wt(this,dt,Kf).call(this),await wt(this,dt,Wf).call(this)},Hf=function(){const i=bt.POPSTATE_INJECTION_KEY;if(window[i])return;const r=history.pushState,n=history.replaceState;history.pushState=function(s,o,a){r.apply(this,[s,o,a]),window.dispatchEvent(new CustomEvent(bt.HISTORY_CHANGE_EVENT))},history.replaceState=function(s,o,a){n.apply(this,[s,o,a]),window.dispatchEvent(new CustomEvent(bt.HISTORY_CHANGE_EVENT))},window[i]=!0},zf=async function(){const i=this.url,r=new URL(window.location.href);this.url=r,(i.pathname!==r.pathname||i.searchParams.get("title")!==r.searchParams.get("title")||i.searchParams.get("curid")!==r.searchParams.get("curid"))&&(await wt(this,dt,Ba).call(this),this.ctx.emit("current-page/popstate"),this.logger.info("location changed",r,this.wikiTitle))},or=new WeakMap,Wf=async function(){let r=this.wikiTitle?.getMainDBKey()===this.ctx.wiki.mainPageName;return r=this.ctx.bail("current-page/resolve-main-page",r)??r,Reflect.defineProperty(this,"isMainPage",{get:()=>r}),r},Kf=async function(){let i=null;return this.canonicalUrl?i=await this.ctx.wikiTitle.newTitleFromUrl(this.canonicalUrl):i=await this.ctx.wikiTitle.newTitleFromUrl(this.url),i=this.ctx.bail("current-page/resolve-title",i)??i,Object.freeze(i),Reflect.defineProperty(this,"wikiTitle",{get:()=>i}),i},bt.HISTORY_CHANGE_EVENT="inpageedit:historychange",bt.POPSTATE_INJECTION_KEY=Symbol.for("inpageedit:currentpage:popstateinjection"),bt);Us=Fh(ml),ln=Wh(Us,0,"CurrentPageService",gl,ln),zh(Us,1,ln);let Kh=ln;class Vh extends ht{constructor(e){super(e,"resourceLoader",!0),this.ctx=e}stop(){this.removeAll()}loadScript(e,i){if(!e)return Promise.resolve(null);const r=`script:${e}`,n=document.querySelector(`[data-ipe="${r}"]`);return n?Promise.resolve(n):new Promise((o,a)=>{const c=document.createElement("script");c.src=e,c.dataset.ipe=r,i&&Object.entries(i).forEach(([l,u])=>{typeof u>"u"||u===!1||u===null?c.removeAttribute(l):c.setAttribute(l,u)}),document.body.appendChild(c),c.onload=()=>o(c),c.onerror=l=>a(l)})}loadStyle(e,i){if(!e)return Promise.resolve(null);const r=`style:${e}`,n=document.querySelector(`[data-ipe="${r}"]`);return n?Promise.resolve(n):new Promise((o,a)=>{const c=document.createElement("link");c.rel="stylesheet",c.href=e,c.dataset.ipe=r,i&&Object.entries(i).forEach(([u,d])=>{typeof d>"u"||d===!1||d===null?c.removeAttribute(u):c.setAttribute(u,d)}),(document.querySelector('meta[name="ipe-styles"]')||(()=>{const u=document.createElement("meta");return u.id="ipe-styles",u.name="ipe-styles",document.head.insertAdjacentElement("afterbegin",u),u})()).before(c),c.onload=()=>o(c),c.onerror=u=>a(u)})}removeStyle(e){const i=`style:${e}`,r=document.querySelector(`[data-ipe="${i}"]`);r&&r.remove()}removeScript(e){const i=`script:${e}`,r=document.querySelector(`[data-ipe="${i}"]`);r&&r.remove()}removeAll(){document.querySelectorAll("[data-ipe]").forEach(e=>{e.remove()})}resolveImportPath(e){if(e.startsWith("http")||e.startsWith("//"))return e;const i=document.currentScript?.src;if(!i)return`https://unpkg.com/mediawiki-inpageedit@latest/dist/${e}`;const r=new URL(i);return r.pathname.endsWith(".js")||(r.pathname=r.pathname+"/"),new URL(e,r.toString()).toString()}}const cn=Object.keys;function Gh(t){return typeof t=="boolean"}function Qh(t){return t&&typeof t.nodeType=="number"}function un(t){return typeof t=="string"}function yl(t){return typeof t=="number"}function yi(t){return typeof t=="object"?t!==null:pr(t)}function pr(t){return typeof t=="function"}function Yh(t){return!!(t&&t.isComponent)}function Xh(t){return yi(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function Fs(t,e){if(t)for(const i of cn(t))e(t[i],i)}function Jh(t){return yi(t)&&"current"in t}const qs={animationIterationCount:0,borderImageOutset:0,borderImageSlice:0,borderImageWidth:0,boxFlex:0,boxFlexGroup:0,boxOrdinalGroup:0,columnCount:0,columns:0,flex:0,flexGrow:0,flexPositive:0,flexShrink:0,flexNegative:0,flexOrder:0,gridArea:0,gridRow:0,gridRowEnd:0,gridRowSpan:0,gridRowStart:0,gridColumn:0,gridColumnEnd:0,gridColumnSpan:0,gridColumnStart:0,fontWeight:0,lineClamp:0,lineHeight:0,opacity:0,order:0,orphans:0,tabSize:0,widows:0,zIndex:0,zoom:0,fillOpacity:0,floodOpacity:0,stopOpacity:0,strokeDasharray:0,strokeDashoffset:0,strokeMiterlimit:0,strokeOpacity:0,strokeWidth:0};function Zh(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const ep=["Webkit","ms","Moz","O"];cn(qs).forEach(t=>{ep.forEach(e=>{qs[Zh(e,t)]=0})});const tp=Symbol.for("jsx-dom:type");var bl=(function(t){return t.ShadowRoot="ShadowRoot",t})(bl||{});function ip(t){return t!=null&&t[tp]===bl.ShadowRoot}const rp="http://www.w3.org/2000/svg",np="http://www.w3.org/1999/xlink",sp="http://www.w3.org/XML/1998/namespace";function vl(t){return!Gh(t)&&t!=null}function Bs(t){return Array.isArray(t)?t.map(Bs).filter(Boolean).join(" "):yi(t)?Symbol.iterator in t?Bs(Array.from(t)):cn(t).filter(e=>t[e]).join(" "):vl(t)?""+t:""}const op={animate:0,circle:0,clipPath:0,defs:0,desc:0,ellipse:0,feBlend:0,feColorMatrix:0,feComponentTransfer:0,feComposite:0,feConvolveMatrix:0,feDiffuseLighting:0,feDisplacementMap:0,feDistantLight:0,feFlood:0,feFuncA:0,feFuncB:0,feFuncG:0,feFuncR:0,feGaussianBlur:0,feImage:0,feMerge:0,feMergeNode:0,feMorphology:0,feOffset:0,fePointLight:0,feSpecularLighting:0,feSpotLight:0,feTile:0,feTurbulence:0,filter:0,foreignObject:0,g:0,image:0,line:0,linearGradient:0,marker:0,mask:0,metadata:0,path:0,pattern:0,polygon:0,polyline:0,radialGradient:0,rect:0,stop:0,svg:0,switch:0,symbol:0,text:0,textPath:0,tspan:0,use:0,view:0},ap=/^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/;function bi(t){const e=document.createDocumentFragment();return dn(t.children,e),e}function lp(t,e,i){e={...e,children:i};const r=new t(e),n=r.render();return"ref"in e&&Hs(e.ref,r),n}function f(t,e){let{children:i,...r}=e;!r.namespaceURI&&op[t]===0&&(r={...r,namespaceURI:rp});let n;if(un(t)){if(n=r.namespaceURI?document.createElementNS(r.namespaceURI,t):document.createElement(t),dp(r,n),dn(i,n),n instanceof window.HTMLSelectElement&&r.value!=null)if(r.multiple===!0&&Array.isArray(r.value)){const s=r.value.map(o=>String(o));n.querySelectorAll("option").forEach(o=>o.selected=s.includes(o.value))}else n.value=r.value;Hs(r.ref,n)}else if(pr(t))yi(t.defaultProps)&&(r={...t.defaultProps,...r}),n=Yh(t)?lp(t,r,i):t({...r,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return n}function gr(t,e){for(var i=arguments.length,r=new Array(i>2?i-2:0),n=2;n<i;n++)r[n-2]=arguments[n];return(un(e)||Array.isArray(e))&&(r.unshift(e),e={}),e=e||{},e.children!=null&&!r.length&&({children:r,...e}=e),f(t,{...e,children:r},e.key)}function Hs(t,e){Jh(t)?t.current=e:pr(t)&&t(e)}function dn(t,e){if(Xh(t))cp(t,e);else if(un(t)||yl(t))zs(document.createTextNode(t),e);else if(t===null)zs(document.createComment(""),e);else if(Qh(t))zs(t,e);else if(ip(t)){const i=e.attachShadow(t.attr);dn(t.children,i),Hs(t.ref,i)}}function cp(t,e){for(const i of[...t])dn(i,e);return e}function zs(t,e){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}function fn(t,e){return t.replace(/[A-Z]/g,i=>e+i.toLowerCase())}function wl(t,e){e==null||e===!1||(Array.isArray(e)?e.forEach(i=>wl(t,i)):un(e)?t.setAttribute("style",e):yi(e)&&Fs(e,(i,r)=>{r.indexOf("-")===0?t.style.setProperty(r,i):yl(i)&&qs[r]!==0?t.style[r]=i+"px":t.style[r]=i}))}function up(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":_l(i,np,fn(t,":"),e);return;case"xmlnsXlink":Di(i,fn(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":_l(i,sp,fn(t,":"),e);return}switch(t){case"htmlFor":Di(i,"for",e);return;case"dataset":Fs(e,(r,n)=>{r!=null&&(i.dataset[n]=r)});return;case"innerHTML":case"innerText":case"textContent":vl(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":yi(e)&&(i.innerHTML=e.__html);return;case"value":if(e==null||i instanceof window.HTMLSelectElement)return;if(i instanceof window.HTMLTextAreaElement){i.value=e;return}break;case"spellCheck":i.spellcheck=e;return;case"class":case"className":pr(e)?e(i):Di(i,"class",Bs(e));return;case"ref":case"namespaceURI":return;case"style":wl(i,e);return;case"on":case"onCapture":Fs(e,(r,n)=>{i.addEventListener(n,r,t==="onCapture")});return}if(pr(e)){if(t[0]==="o"&&t[1]==="n"){let r=t.toLowerCase();const n=r.endsWith("capture");if(r==="ondoubleclick"?r="ondblclick":n&&r==="ondoubleclickcapture"&&(r="ondblclickcapture"),!n&&i[r]===null)i[r]=e;else if(n)i.addEventListener(r.substring(2,r.length-7),e,!0);else{let s;r in window?s=r.substring(2):s=r[2]+t.slice(3),i.addEventListener(s,e)}}}else yi(e)?i[t]=e:e===!0?Di(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!ap.test(t)?Di(i,fn(t,"-"),e):Di(i,t,e))}function Di(t,e,i){t.setAttribute(e,i)}function _l(t,e,i,r){t.setAttributeNS(e,i,r)}function dp(t,e){for(const i of cn(t))up(i,t[i],e);return e}const hn=Object.keys;function fp(t){return typeof t=="boolean"}function hp(t){return t&&typeof t.nodeType=="number"}function Ws(t){return typeof t=="string"}function xl(t){return typeof t=="number"}function vi(t){return typeof t=="object"?t!==null:mr(t)}function mr(t){return typeof t=="function"}function pp(t){return!!(t&&t.isComponent)}function gp(t){return vi(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function Ks(t,e){if(t)for(const i of hn(t))e(t[i],i)}function mp(t){return vi(t)&&"current"in t}const Vs={animationIterationCount:0,borderImageOutset:0,borderImageSlice:0,borderImageWidth:0,boxFlex:0,boxFlexGroup:0,boxOrdinalGroup:0,columnCount:0,columns:0,flex:0,flexGrow:0,flexPositive:0,flexShrink:0,flexNegative:0,flexOrder:0,gridArea:0,gridRow:0,gridRowEnd:0,gridRowSpan:0,gridRowStart:0,gridColumn:0,gridColumnEnd:0,gridColumnSpan:0,gridColumnStart:0,fontWeight:0,lineClamp:0,lineHeight:0,opacity:0,order:0,orphans:0,tabSize:0,widows:0,zIndex:0,zoom:0,fillOpacity:0,floodOpacity:0,stopOpacity:0,strokeDasharray:0,strokeDashoffset:0,strokeMiterlimit:0,strokeOpacity:0,strokeWidth:0};function yp(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const bp=["Webkit","ms","Moz","O"];hn(Vs).forEach(t=>{bp.forEach(e=>{Vs[yp(e,t)]=0})});const vp=Symbol.for("jsx-dom:type");var kl=(function(t){return t.ShadowRoot="ShadowRoot",t})(kl||{});function wp(t){return t!=null&&t[vp]===kl.ShadowRoot}const _p="http://www.w3.org/2000/svg",xp="http://www.w3.org/1999/xlink",kp="http://www.w3.org/XML/1998/namespace";function Sl(t){return!fp(t)&&t!=null}function Gs(t){return Array.isArray(t)?t.map(Gs).filter(Boolean).join(" "):vi(t)?Symbol.iterator in t?Gs(Array.from(t)):hn(t).filter(e=>t[e]).join(" "):Sl(t)?""+t:""}const Sp={animate:0,circle:0,clipPath:0,defs:0,desc:0,ellipse:0,feBlend:0,feColorMatrix:0,feComponentTransfer:0,feComposite:0,feConvolveMatrix:0,feDiffuseLighting:0,feDisplacementMap:0,feDistantLight:0,feFlood:0,feFuncA:0,feFuncB:0,feFuncG:0,feFuncR:0,feGaussianBlur:0,feImage:0,feMerge:0,feMergeNode:0,feMorphology:0,feOffset:0,fePointLight:0,feSpecularLighting:0,feSpotLight:0,feTile:0,feTurbulence:0,filter:0,foreignObject:0,g:0,image:0,line:0,linearGradient:0,marker:0,mask:0,metadata:0,path:0,pattern:0,polygon:0,polyline:0,radialGradient:0,rect:0,stop:0,svg:0,switch:0,symbol:0,text:0,textPath:0,tspan:0,use:0,view:0},Ep=/^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/;function $p(t){const e=document.createDocumentFragment();return pn(t.children,e),e}function Pp(t,e,i){e={...e,children:i};const r=new t(e),n=r.render();return"ref"in e&&Qs(e.ref,r),n}function Ee(t,e){let{children:i,...r}=e;!r.namespaceURI&&Sp[t]===0&&(r={...r,namespaceURI:_p});let n;if(Ws(t)){if(n=r.namespaceURI?document.createElementNS(r.namespaceURI,t):document.createElement(t),Ap(r,n),pn(i,n),n instanceof window.HTMLSelectElement&&r.value!=null)if(r.multiple===!0&&Array.isArray(r.value)){const s=r.value.map(o=>String(o));n.querySelectorAll("option").forEach(o=>o.selected=s.includes(o.value))}else n.value=r.value;Qs(r.ref,n)}else if(mr(t))vi(t.defaultProps)&&(r={...t.defaultProps,...r}),n=pp(t)?Pp(t,r,i):t({...r,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return n}function Qs(t,e){mp(t)?t.current=e:mr(t)&&t(e)}function pn(t,e){if(gp(t))Cp(t,e);else if(Ws(t)||xl(t))Ys(document.createTextNode(t),e);else if(t===null)Ys(document.createComment(""),e);else if(hp(t))Ys(t,e);else if(wp(t)){const i=e.attachShadow(t.attr);pn(t.children,i),Qs(t.ref,i)}}function Cp(t,e){for(const i of[...t])pn(i,e);return e}function Ys(t,e){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}function gn(t,e){return t.replace(/[A-Z]/g,i=>e+i.toLowerCase())}function El(t,e){e==null||e===!1||(Array.isArray(e)?e.forEach(i=>El(t,i)):Ws(e)?t.setAttribute("style",e):vi(e)&&Ks(e,(i,r)=>{r.indexOf("-")===0?t.style.setProperty(r,i):xl(i)&&Vs[r]!==0?t.style[r]=i+"px":t.style[r]=i}))}function Ip(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":$l(i,xp,gn(t,":"),e);return;case"xmlnsXlink":ji(i,gn(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":$l(i,kp,gn(t,":"),e);return}switch(t){case"htmlFor":ji(i,"for",e);return;case"dataset":Ks(e,(r,n)=>{r!=null&&(i.dataset[n]=r)});return;case"innerHTML":case"innerText":case"textContent":Sl(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":vi(e)&&(i.innerHTML=e.__html);return;case"value":if(e==null||i instanceof window.HTMLSelectElement)return;if(i instanceof window.HTMLTextAreaElement){i.value=e;return}break;case"spellCheck":i.spellcheck=e;return;case"class":case"className":mr(e)?e(i):ji(i,"class",Gs(e));return;case"ref":case"namespaceURI":return;case"style":El(i,e);return;case"on":case"onCapture":Ks(e,(r,n)=>{i.addEventListener(n,r,t==="onCapture")});return}if(mr(e)){if(t[0]==="o"&&t[1]==="n"){let r=t.toLowerCase();const n=r.endsWith("capture");if(r==="ondoubleclick"?r="ondblclick":n&&r==="ondoubleclickcapture"&&(r="ondblclickcapture"),!n&&i[r]===null)i[r]=e;else if(n)i.addEventListener(r.substring(2,r.length-7),e,!0);else{let s;r in window?s=r.substring(2):s=r[2]+t.slice(3),i.addEventListener(s,e)}}}else vi(e)?i[t]=e:e===!0?ji(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!Ep.test(t)?ji(i,gn(t,"-"),e):ji(i,t,e))}function ji(t,e,i){t.setAttribute(e,i)}function $l(t,e,i,r){t.setAttributeNS(e,i,r)}function Ap(t,e){for(const i of hn(t))Ip(i,t[i],e);return e}var Xs=(t=>(t.Init="modal.init",t.BeforeShow="modal.beforeShow",t.Show="modal.show",t.BeforeClose="modal.beforeClose",t.Close="modal.close",t.Destroy="modal.destroy",t.ToastShow="toast.show",t.ToastClose="toast.close",t))(Xs||{});let Rp=0;const Pl=t=>`${t}-${++Rp}`;function yr(t){return t instanceof Node?t:document.createTextNode(String(t))}function Gt(t,e){if(!t)throw new Error(`${e??"Element"} not found`);return t}function Cl(t){const e=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");return Array.from(t.querySelectorAll(e)).filter(i=>!!(i.offsetWidth||i.offsetHeight||i.getClientRects().length))}function Ge(t,e={}){const i=document.createElement(t);if(e.className&&(i.className=e.className),e.html!=null&&(i.innerHTML=e.html),e.text!=null&&(i.textContent=e.text),e.attrs)for(const[r,n]of Object.entries(e.attrs))i.setAttribute(r,n);return i}const Tp=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/i.test(navigator.platform),Il=["ctrl","alt","shift","meta"];function Op(t){if(!t)return null;const e=String(t).trim().toLowerCase().split(/[+\-\s]+/g).filter(Boolean),i=[];let r=null;const n=o=>{i.includes(o)||i.push(o)};for(const o of e){let a=o;if(a==="control"||a==="ctrl"){n("ctrl");continue}if(a==="alt"||a==="option"){n("alt");continue}if(a==="shift"){n("shift");continue}if(a==="meta"||a==="cmd"||a==="command"||a==="super"){n("meta");continue}if(a==="mod"){n(Tp?"meta":"ctrl");continue}a==="esc"&&(a="escape"),a==="return"&&(a="enter"),(a==="space"||a==="spacebar")&&(a="space"),r=a}const s=Il.filter(o=>i.includes(o));return!r||r===""?s.length?s.join("+"):null:s.length?`${s.join("+")}+${r}`:r}function Lp(t){const e=[];t.ctrlKey&&e.push("ctrl"),t.altKey&&e.push("alt"),t.shiftKey&&e.push("shift"),t.metaKey&&e.push("meta");let i=t.key;i===" "&&(i="space");const r=(i.length,i.toLowerCase()),n=Il.filter(s=>e.includes(s));return n.length?`${n.join("+")}+${r}`:r}class Np{constructor(){this.zBase=1e3,this.stack=[]}push(e){this.stack.push(e),this.syncZ()}remove(e){this.stack=this.stack.filter(i=>i!==e),this.syncZ()}top(){return this.stack[this.stack.length-1]}closeAll(e,i){const r=new Set((Array.isArray(i)?i:i?[i]:[]).map(String)),n=new Set((Array.isArray(e)?e:e?[e]:[]).map(String));[...this.stack].reverse().forEach(s=>{const o=s.modalId,a=n.size?n.has(s.pluginName):!0,c=r.has(o);a&&!c&&s.close()})}removeAll(){[...this.stack].forEach(e=>e.destroy()),this.stack=[]}syncZ(){this.stack.forEach((e,i)=>e.setZIndex(this.zBase+i*2))}lockBodyScroll(){document.body.classList.add("ipe-modal-no-scroll")}unlockBodyScroll(){document.body.classList.remove("ipe-modal-no-scroll")}}const tt=new Np,Kr=class Kr{constructor(e={}){this.backdropId=Pl("ipe-modal-backdrop"),this.modalId=Pl("ipe-modal"),this.numberId=this.modalId.split("-")[1],this._isDestroyed=!1,this.pluginName="normalModal",this.buttonElsLeft=[],this.buttonElsRight=[],this.keyMap=new Map,this.isOpen=!1,this.isToast=!1,this.isDragging=!1,this.dragStartX=0,this.dragStartY=0,this.modalStartX=0,this.modalStartY=0,this.Event=Xs,this._hooks=[],this.startCloseTimer=i=>{this.stopCloseTimer(),this.closeTimer=window.setTimeout(()=>this.close(),i)},this.stopCloseTimer=()=>{this.closeTimer&&window.clearTimeout(this.closeTimer),this.closeTimer=void 0},this.onDragMove=i=>{if(!this.isDragging)return;i.preventDefault();const r=i.clientX-this.dragStartX,n=i.clientY-this.dragStartY,s=this.get$modal(),o=this.modalStartX+r,a=this.modalStartY+n;s.style.left=`${o}px`,s.style.top=`${a}px`},this.onDragEnd=()=>{if(!this.isDragging)return;this.isDragging=!1,document.removeEventListener("pointermove",this.onDragMove),document.removeEventListener("pointerup",this.onDragEnd);const i=this.get$modal(),r=this.get$window();i.classList.remove("is-dragging"),r.style.animation="none",requestAnimationFrame(()=>{this.applyAnimation(!0)})},this.options={...Kr.DEFAULT_OPTIONS,...e},this.options.backdrop===!1&&e.bodyScroll===void 0&&(this.options.bodyScroll=!0)}get isDestroyed(){return this._isDestroyed}static extends(e={}){return class extends this{constructor(i={}){super({...e,...i})}}}init(){if(this.$modal)return this;const e=this.options.backdrop!==!1;let i;e&&(i=Ge("div",{className:"ipe-modal-backdrop",attrs:{id:this.backdropId,"data-modal-id":this.modalId}}));const r=Ge("div",{className:"ipe-modal-modal",attrs:{id:this.modalId,role:"dialog","aria-modal":"true",tabindex:"-1"}});if(r.modal=this,!e){r.classList.add("no-backdrop");const p=window.pageYOffset||document.documentElement.scrollTop,h=window.pageXOffset||document.documentElement.scrollLeft,_=window.innerWidth;r.style.top=`${p+60}px`,this.once("modal.show",()=>{r.style.left=`${h+_/2-r.offsetWidth/2}px`})}const n=Ge("div",{className:`ipe-modal-modal__window size--${this.options.sizeClass||"auto"} plugin--${this.pluginName}`});n.modal=this;const s=Ge("div",{className:"ipe-modal-modal__header"}),o=`${this.modalId}-title`,a=Ge("h2",{className:"ipe-modal-modal__title",attrs:{id:o,role:"heading","aria-level":"2"}});r.setAttribute("aria-labelledby",o);const c=Ge("div",{className:"ipe-modal-modal__icons"});if(this.options.closeIcon){const p=Ge("button",{className:"ipe-modal-modal__close",attrs:{type:"button","aria-label":"Close"},html:"&times;"});p.addEventListener("click",()=>{let h=!0;typeof this.options.onClickClose=="function"?this.options.onClickClose(this)===!1&&(h=!1):this.options.onClickClose===!1&&(h=!1),h&&this.close()}),c.appendChild(p)}s.append(a,c),this.options.draggable&&e&&(this.options.draggable=!1),this.options.draggable&&(s.style.cursor="move",s.style.userSelect="none",s.addEventListener("pointerdown",this.onDragStart.bind(this)),r.classList.add("is-draggable"));const l=Ge("div",{className:"ipe-modal-modal__content"}),u=Ge("div",{className:"ipe-modal-modal__footer"}),d=Ge("div",{className:"ipe-modal-modal__buttons ipe-modal-modal__buttons--left"}),y=Ge("div",{className:"ipe-modal-modal__buttons ipe-modal-modal__buttons--right"});return u.append(d,y),n.append(s,l,u),r.appendChild(n),this.$backdrop=i,this.$modal=r,this.$window=n,this.$header=s,this.$title=a,this.$icons=c,this.$content=l,this.$footer=u,this.$buttonsLeft=d,this.$buttonsRight=y,this.options.title&&this.setTitle(this.options.title),this.options.content&&this.setContent(this.options.content),this.options.buttons?.length?this.setButtons(this.options.buttons):u.style.display="none",this.options.center&&this.$modal.classList.add("is-centered"),this.options.fitScreen&&this.$modal.classList.add("is-fullscreen"),this.options.iconButtons&&this.$header.classList.add("has-icon-buttons"),this.options.className&&this.$window.classList.add(...this.options.className.split(/[\s\.#+]+/g).filter(Boolean)),typeof this.options.fixedHeight=="number"?this.$window.style.height=`${Math.max(0,this.options.fixedHeight)}px`:this.options.fixedHeight===!0&&this.$window.classList.add("is-fixed-height"),i&&i.addEventListener("pointerup",p=>{this.options.outSideClose&&p.target===i&&this.close()}),this.options.draggable&&n.addEventListener("pointerdown",p=>{p.target&&n.contains(p.target)&&this.bringToFront()}),this.onKeyDown=this.onKeyDown.bind(this),this.emit("modal.init"),this}show(){if(this.$modal||this.init(),!this.$modal)throw new Error("Failed to initialize modal");if(this.isOpen)return this;{const r=this.emit("modal.beforeShow",!0),n=this.options.beforeShow?this.options.beforeShow(this)!==!1:!0;if(!r||!n)return this}this.lastFocused=document.activeElement??null,this.$backdrop&&document.body.appendChild(this.$backdrop),document.body.appendChild(this.$modal),this.shouldLockBodyOnOpen()&&tt.lockBodyScroll(),requestAnimationFrame(()=>{this.$backdrop?.classList.add("is-open"),this.$modal.classList.add("is-open"),this.applyAnimation(!0),this.focusFirst()}),document.addEventListener("keydown",this.onKeyDown),tt.push(this),this.isOpen=!0,this.options.onShow?.(this),this.emit("modal.show");const e=typeof this.options.closeAfter=="number"?this.options.closeAfter:this.options.closeAfter?.time,i=typeof this.options.closeAfter=="number"?!0:this.options.closeAfter?.resetOnHover;return e&&(this.startCloseTimer(e),i&&(this.$window?.addEventListener("mouseenter",this.stopCloseTimer),this.$window?.addEventListener("mouseleave",()=>this.startCloseTimer(e)))),this}close(){if(!this.isOpen)return this;{const s=this.emit("modal.beforeClose",!0),o=this.options.beforeClose?this.options.beforeClose(this)!==!1:!0;if(!s||!o)return this}if(this.isToast){this.applyAnimation(!1),this.emit("modal.close"),this.emit("toast.close");const s=this.isAnimationDisabled()?0:this.options.animationSpeed??200;let o=!1;const a=()=>{o||(o=!0,this.destroy(),this.options.onClose?.(this))},c=(l,u)=>{const d=()=>{l.removeEventListener(u,d),a()};l.addEventListener(u,d,{once:!0})};return s>0&&this.$window?(c(this.$window,"transitionend"),c(this.$window,"animationend"),window.setTimeout(a,s+20)):window.setTimeout(a,s),this}this.applyAnimation(!1),this.$backdrop?.classList.remove("is-open"),this.$modal?.classList.remove("is-open"),this.emit("modal.close");const e=this.isAnimationDisabled()?0:this.options.animationSpeed??200;let i=!1;const r=()=>{i||(i=!0,this.destroy(),this.options.onClose?.(this))},n=(s,o)=>{const a=()=>{s.removeEventListener(o,a),r()};s.addEventListener(o,a,{once:!0})};return e>0&&this.$window?(n(this.$window,"transitionend"),n(this.$window,"animationend"),window.setTimeout(r,e+20)):window.setTimeout(r,e),this}destroy(){if(this._isDestroyed)return this;if(this.stopCloseTimer(),document.removeEventListener("keydown",this.onKeyDown),this.isDragging&&this.onDragEnd(),this.$window?.removeEventListener("mouseenter",this.stopCloseTimer),this.isToast){this.$window?.parentElement&&this.$window.parentElement.removeChild(this.$window);const e=wi.indexOf(this);e!==-1&&wi.splice(e,1)}else this.$backdrop?.parentElement&&this.$backdrop.parentElement.removeChild(this.$backdrop),this.$modal?.parentElement&&this.$modal.parentElement.removeChild(this.$modal),tt.remove(this),this.shouldUnlockBodyOnClose()&&tt.unlockBodyScroll();return this.isOpen=!1,this.lastFocused?.focus?.(),this.emit("modal.destroy"),this._isDestroyed=!0,this}get$backdrop(){return this.$backdrop}get$modal(){return Gt(this.$modal,"modal")}get$window(){return Gt(this.$window,"window")}get$header(){return Gt(this.$header,"header")}get$title(){return Gt(this.$title,"title")}get$content(){return Gt(this.$content,"content")}get$icons(){return Gt(this.$icons,"icons")}get$buttons(e){return e==="leftButtons"?Gt(this.$buttonsLeft,"leftButtons"):e==="rightButtons"?Gt(this.$buttonsRight,"rightButtons"):Gt(this.$footer,"buttons")}setTitle(e){const i=this.get$title();return i.innerHTML="",i.append(yr(e)),this}setContent(e,i="replace"){const r=this.get$content();return i==="replace"?(r.innerHTML="",r.append(yr(e))):i==="append"?r.append(yr(e)):r.prepend(yr(e)),this}setIcons(e){const i=this.get$icons();i.innerHTML="";for(const r of e){const n=Ge("button",{className:`ipe-modal-modal__icon ${r.className}`,attrs:{type:"button"}});n.addEventListener("click",r.method),i.appendChild(n)}return this}setButtons(e,i){const r=this.$buttonsLeft,n=this.$buttonsRight;[r,n].forEach(o=>o.innerHTML=""),this.buttonElsLeft=[],this.buttonElsRight=[],this.keyMap.clear();const s=i??this.$footer;if(s===this.$footer)e.forEach(o=>this.addButton(o)),e.length===0&&(this.$footer.style.display="none");else{s.innerHTML="";for(const o of e){const a=this.generateButton(o);s.appendChild(a)}}return this}generateButton(e){const i=e.type??"button",r=i==="link"?Ge("a"):Ge("button",{attrs:{type:"button"}});e.id&&(r.id=e.id),r.className=`ipe-modal-btn ${e.className??""}`.trim();const n=yr(e.label??"OK");if(r.append(n),i==="link"&&e.href&&(r.href=e.href),e.method&&r.addEventListener("click",s=>{if(r._ipe_tmpDisabled){s.preventDefault(),s.stopPropagation();return}e.method.call(r,s,this)}),typeof e.closeAfter=="number"&&e.closeAfter>=0&&r.addEventListener("click",()=>{window.setTimeout(()=>this.close(),e.closeAfter)}),typeof e.enableAfter=="number"&&e.enableAfter>0){i==="button"&&r.setAttribute("disabled","true"),r._ipe_tmpDisabled=!0,r.setAttribute("aria-disabled","true");const s=()=>{i==="button"&&r.removeAttribute("disabled"),delete r._ipe_tmpDisabled,r.removeAttribute("aria-disabled")};window.setTimeout(s,e.enableAfter)}if(e.keyPress){const s=String(e.keyPress).split(/[\,\|]+/g).map(o=>o.trim()).filter(Boolean);for(const o of s){const a=Op(o);a&&this.keyMap.set(a,r)}}return r}addButton(e,i){this.$footer&&(this.$footer.style.display="");const r=e.side??"right",n=r==="left"?this.$buttonsLeft:this.$buttonsRight,s=r==="left"?this.buttonElsLeft:this.buttonElsRight,o=this.generateButton(e),a=Math.max(0,Math.min(i??s.length,s.length));return a>=n.children.length?n.appendChild(o):n.insertBefore(o,n.children[a]),s.splice(a,0,o),this}removeButton(e){const i=this.buttonElsLeft,r=this.buttonElsRight,n=[...i,...r];let s=null;if(e==="*")return n.forEach(a=>{this.keyMap.delete(a.id),a.parentElement?.removeChild(a)}),this.$footer&&(this.$footer.style.display="none"),this;if(typeof e=="number"?s=n[e]??null:typeof e=="string"?s=n.find(a=>a.id===e)??null:e instanceof HTMLElement&&(s=n.find(a=>a===e)??null),!s)return this;for(const[a,c]of this.keyMap.entries())c===s&&this.keyMap.delete(a);let o=i.indexOf(s);return o!==-1?(i.splice(o,1),s.parentElement?.removeChild(s)):(o=r.indexOf(s),o!==-1&&(r.splice(o,1),s.parentElement?.removeChild(s))),i.length===0&&r.length===0&&this.$footer&&(this.$footer.style.display="none"),this}changePreviewState(){return this.get$modal().classList.toggle("is-fullscreen"),this}setModalHeight(e,i="height"){const r=this.get$window(),n=Math.max(0,window.innerHeight-e);return r.style[i]=`${n}px`,n}setOptions(e,i){return typeof e=="string"?this.options[e]=i:Object.assign(this.options,e),this}setPluginName(e){return this.$window&&(this.$window.className=this.$window.className.replace(`plugin--${this.pluginName}`,`plugin--${e}`)),this.pluginName=e,this}applyAnimation(e){const i=this.get$modal(),r=this.get$window(),n=this.$backdrop,s=this.options.modalAnimation??this.options.animation,o=typeof s=="string"?s:s&&(e?s.show:s.hide),a=this.options.backdropAnimation??this.options.animation,c=typeof a=="string"?a:a&&(e?a.show:a.hide);!o||o===!1?(i.style.transition="none",r.style.animation="none",r.style.removeProperty("--ipe-modal-anim")):(i.style.removeProperty("transition"),r.style.setProperty("--ipe-modal-anim",o)),n&&(!c||c===!1?n.style.transition="none":n.style.removeProperty("transition"))}on(e,i){return this._hooks.push({type:e,listener:i}),()=>this.off(e,i)}off(e,i){return this._hooks=this._hooks.filter(r=>r.type!==e&&(i?r.listener!==i:!0)),this}once(e,i){const r=this.on(e,n=>(r(),i(n)));return r}emit(e,i){const r=this._hooks.filter(a=>a.type===e);let n=!0;for(const a of r){const c=new CustomEvent(e,{detail:this,cancelable:i}),l=a.listener(c);if(c.defaultPrevented&&(n=!1),l===!1&&(n=!1),!n)break}const s=this.$modal??document.body,o=new CustomEvent(e,{detail:this,cancelable:i});return(!s.dispatchEvent(o)||o.defaultPrevented)&&(n=!1),n}focusFirst(){const e=this.get$modal(),i=Cl(e);i.length?i[0].focus():e.focus({preventScroll:!0})}onKeyDown(e){if(tt.top()!==this)return;if(e.key==="Escape"){e.preventDefault(),this.close();return}const i=this.get$modal();if(!i.contains(document.activeElement))return;if(e.key==="Tab"){const a=Cl(i);if(!a.length)return;const c=a[0],l=a[a.length-1],u=document.activeElement;e.shiftKey&&u===c?(e.preventDefault(),l.focus()):!e.shiftKey&&u===l&&(e.preventDefault(),c.focus())}const r=e.ctrlKey||e.altKey||e.metaKey,n=e.target;if(!r&&(n&&["INPUT","TEXTAREA"].includes(n.tagName)||n.contentEditable==="true"))return;const s=Lp(e),o=this.keyMap.get(s);if(o){e.preventDefault(),o.click();return}}setZIndex(e){this.$backdrop&&(this.$backdrop.style.zIndex=String(e)),this.$modal&&(this.$modal.style.zIndex=String(e+1))}bringToFront(){return tt.remove(this),tt.push(this),this}isAnimationDisabled(){const e=this.options.modalAnimation??this.options.animation;return e===!1||e==null}shouldLockBodyOnOpen(){return this.options.backdrop===!1||this.options.bodyScroll!==!1?!1:!tt.stack.some(e=>e!==this&&e.options.backdrop!==!1&&e.options.bodyScroll===!1)}shouldUnlockBodyOnClose(){return this.options.backdrop===!1||this.options.bodyScroll!==!1?!1:!tt.stack.some(e=>e!==this&&e.options.backdrop!==!1&&e.options.bodyScroll===!1)}onDragStart(e){if(this.options.backdrop!==!1||!this.options.draggable)return;e.preventDefault(),this.isDragging=!0,this.bringToFront(),this.dragStartX=e.clientX,this.dragStartY=e.clientY;const i=this.get$modal(),r=i.getBoundingClientRect();this.modalStartX=r.left+window.pageXOffset,this.modalStartY=r.top+window.pageYOffset,i.style.transform="none",i.style.left=`${this.modalStartX}px`,i.style.top=`${this.modalStartY}px`,document.addEventListener("pointermove",this.onDragMove),document.addEventListener("pointerup",this.onDragEnd),i.classList.add("is-dragging")}showToast(e){this.$window||this.init();const i=Mp(e.position??"top right"),r=this.get$window();this.isToast=!0,r.style.pointerEvents="auto",this.applyAnimation(!0),i.appendChild(r);const n=(typeof this.options.closeAfter=="number"?this.options.closeAfter:this.options.closeAfter?.time)??3e3,s=(typeof this.options.closeAfter=="number"?!0:this.options.closeAfter?.resetOnHover)??!0;return n>0&&(this.startCloseTimer(n),s&&(r.addEventListener("mouseenter",this.stopCloseTimer),r.addEventListener("mouseleave",()=>this.startCloseTimer(n)))),this.isOpen=!0,this.options.onShow?.(this),wi.push(this),this.emit("toast.show"),this.emit("modal.show"),this}static show(e,i){return new this(e).init().show()}static createObject(e,i){return new this(e)}static close(e){if(!e){const s=tt.top();return s?.close(),s}const i=typeof e=="string"?e:e.id,r=tt.stack.find(s=>s.modalId===i);if(r)return r.close(),r;const n=wi.find(s=>s.modalId===i);return n?.close(),n}static closeAll(e,i){const r=new Set((Array.isArray(i)?i:i?[i]:[]).map(String)),n=new Set((Array.isArray(e)?e:e?[e]:[]).map(String));return tt.closeAll(e,i),[...wi].forEach(s=>{const o=s.modalId,a=n.size?n.has(s.pluginName):!0,c=r.has(o);a&&!c&&s.close()}),tt.top()??new Kr}static removeAll(){tt.removeAll(),[...wi].forEach(e=>e.destroy())}static dialog(e,i){const r=new this({sizeClass:"dialog",buttons:[{label:"OK",className:"is-primary is-ghost",method:(n,s)=>{i?.(n,s),n.defaultPrevented||r.close()},keyPress:"Enter"}],...e});return r.init().show()}static confirm(e,i){e.title??(e.title="Confirm"),e.content??(e.content="Are you sure you want to perform this action?");const r=e.okBtn??{label:"OK",className:"is-primary is-ghost"},n=e.cancelBtn??{label:"Cancel",className:"is-danger is-ghost"};return new this({sizeClass:"dialog",...e,buttons:[{label:n.label,className:n.className,keyPress:"n",method:(s,o)=>{i?.(!1,o,s),o.close()}},{label:r.label,className:r.className,keyPress:"y",method:(s,o)=>{i?.(!0,o,s),s.defaultPrevented||o.close()}}]}).init().show()}static getDefaultNotifyIcon(e){switch(e){case"success":return Ee("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-circle-check",children:[Ee("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ee("path",{d:"M17 3.34a10 10 0 1 1 -14.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 14.995 -8.336zm-1.293 5.953a1 1 0 0 0 -1.32 -.083l-.094 .083l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.403 1.403l.083 .094l2 2l.094 .083a1 1 0 0 0 1.226 0l.094 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z"})]});case"error":return Ee("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-alert-triangle",children:[Ee("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ee("path",{d:"M12 1.67c.955 0 1.845 .467 2.39 1.247l.105 .16l8.114 13.548a2.914 2.914 0 0 1 -2.307 4.363l-.195 .008h-16.225a2.914 2.914 0 0 1 -2.582 -4.2l.099 -.185l8.11 -13.538a2.914 2.914 0 0 1 2.491 -1.403zm.01 13.33l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007zm-.01 -7a1 1 0 0 0 -.993 .883l-.007 .117v4l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-4l-.007 -.117a1 1 0 0 0 -.993 -.883z"})]});case"warning":return Ee("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-alert-circle",children:[Ee("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ee("path",{d:"M12 2c5.523 0 10 4.477 10 10a10 10 0 0 1 -19.995 .324l-.005 -.324l.004 -.28c.148 -5.393 4.566 -9.72 9.996 -9.72zm.01 13l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007zm-.01 -8a1 1 0 0 0 -.993 .883l-.007 .117v4l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-4l-.007 -.117a1 1 0 0 0 -.993 -.883z"})]});case"info":return Ee("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-info-circle",children:[Ee("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ee("path",{d:"M12 2c5.523 0 10 4.477 10 10a10 10 0 0 1 -19.995 .324l-.005 -.324l.004 -.28c.148 -5.393 4.566 -9.72 9.996 -9.72zm0 9h-1l-.117 .007a1 1 0 0 0 0 1.986l.117 .007v3l.007 .117a1 1 0 0 0 .876 .876l.117 .007h1l.117 -.007a1 1 0 0 0 .876 -.876l.007 -.117l-.007 -.117a1 1 0 0 0 -.764 -.857l-.112 -.02l-.117 -.006v-3l-.007 -.117a1 1 0 0 0 -.876 -.876l-.117 -.007zm.01 -3l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007z"})]});case"dialog":return Ee("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-message-dots",children:[Ee("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ee("path",{d:"M12 11v.01"}),Ee("path",{d:"M8 11v.01"}),Ee("path",{d:"M16 11v.01"}),Ee("path",{d:"M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3z"})]});case"confirm":return Ee("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-copy-check",children:[Ee("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ee("path",{d:"M18.333 6a3.667 3.667 0 0 1 3.667 3.667v8.666a3.667 3.667 0 0 1 -3.667 3.667h-8.666a3.667 3.667 0 0 1 -3.667 -3.667v-8.666a3.667 3.667 0 0 1 3.667 -3.667zm-3.333 -4c1.094 0 1.828 .533 2.374 1.514a1 1 0 1 1 -1.748 .972c-.221 -.398 -.342 -.486 -.626 -.486h-10c-.548 0 -1 .452 -1 1v9.998c0 .32 .154 .618 .407 .805l.1 .065a1 1 0 1 1 -.99 1.738a3 3 0 0 1 -1.517 -2.606v-10c0 -1.652 1.348 -3 3 -3zm1.293 9.293l-3.293 3.292l-1.293 -1.292a1 1 0 0 0 -1.414 1.414l2 2a1 1 0 0 0 1.414 0l4 -4a1 1 0 0 0 -1.414 -1.414"})]});default:return null}}static notify(e,i,r){var a,c,l,u;if(i?.overrideOther&&[...wi].forEach(d=>d.close()),typeof i.title>"u"){const d=e||"Notification";i.title=d[0].toUpperCase()+d.slice(1).toLowerCase()}const n=i.icon??this.getDefaultNotifyIcon(e);n&&(n instanceof Element&&n.classList.add("ipe-modal-notify-icon"),i.title=Ee($p,{children:[n,i.title]})),e==="confirm"&&(typeof i.closeAfter>"u"&&(i.closeAfter=0),i.okBtn||(i.okBtn={label:"OK"})),i.okBtn&&(typeof i.okBtn!="object"&&(i.okBtn={label:"OK"}),(a=i.okBtn).label??(a.label="OK"),(c=i.okBtn).className??(c.className="is-primary is-text ok-btn"),i.okBtn.method=(d,y)=>{r?.(!0,y,d),y.close()}),i.cancelBtn&&(typeof i.cancelBtn!="object"&&(i.cancelBtn={label:"Cancel"}),(l=i.cancelBtn).label??(l.label="Cancel"),(u=i.cancelBtn).className??(u.className="is-danger is-text cancel-btn"),i.cancelBtn.method=(d,y)=>{r?.(!1,y,d),y.close()}),i.buttons=[i.cancelBtn,i.okBtn,...i.buttons??[]].filter(Boolean);const s=`is-notify type-${e||"default"} ${i.className??""}`,o=new this({...i,className:s,sizeClass:"auto",center:!1,fitScreen:!1,closeIcon:!0,outSideClose:!1,bodyScroll:!0,buttons:i.buttons??[]});return o.setPluginName("toast"),o.showToast({position:i.position??"top right"})}};Kr.DEFAULT_OPTIONS={className:"",sizeClass:"auto",center:!0,fitScreen:!1,closeIcon:!0,bodyScroll:!1,outSideClose:!0,backdrop:!0,animation:{show:"ipe-modal-fade-in",hide:"ipe-modal-fade-out"},animationSpeed:200};let Js=Kr;const wi=[];function Mp(t="top right"){const e="ipe-modal-toast-container",i=`${e}-${t.replace(/[\s-\.|\/]+/g,"-")}`;let r=document.getElementById(i);return r||(r=Ge("div",{className:`${e} ${t}`,attrs:{id:i,"data-position":t}}),document.body.appendChild(r)),r}const Dp={ipe_progress:"_ipe_progress_so6hn_1"},_i=t=>{const e=t.indeterminate??!0,i=f("div",{class:`${Dp.ipe_progress}`,"data-indeterminate":`${e}`,style:{width:"100%","--progress":t.progress?`${t.progress}%`:"0%"},...t});return i.setProgress=r=>{typeof r=="number"?(i.dataset.indeterminate="false",i.style.setProperty("--progress",`${r}%`)):(i.dataset.indeterminate="true",i.style.setProperty("--progress","0%"))},i};class Me extends Js{constructor(e={}){e.className||(e.className=""),e.className+=" theme-ipe",e.modalAnimation||(e.modalAnimation={show:"ipe-modal-fade-in",hide:"ipe-modal-fade-out"}),super(e)}setLoadingState(e){if(this.get$window().classList.toggle("loading",e),e){const i=this.get$window().querySelectorAll("input:not([disabled]),button:not([disabled])");this._tmpDisabledActiveInputs=i,i.forEach(r=>{r.disabled=!0}),this.get$content().append(f("div",{id:"ipe-modalLoadingWrapper",style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"rgba(255, 255, 255, 0.5)",zIndex:2e3},children:f(_i,{style:{width:"80%",maxWidth:"800px"}})}))}else{this.get$window().querySelector("#ipe-modalLoadingWrapper")?.remove();const i=this._tmpDisabledActiveInputs;i&&i.forEach(r=>{r.disabled=!1})}}}class jp{constructor(e){this.ctx=e,this.IPEModal=Me,this.IPEModalEvent=Xs,this.show=Me.show.bind(Me),this.createObject=Me.createObject.bind(Me),this.close=Me.close.bind(Me),this.closeAll=Me.closeAll.bind(Me),this.removeAll=Me.removeAll.bind(Me),this.dialog=Me.dialog.bind(Me),this.confirm=Me.confirm.bind(Me),this.notify=Me.notify.bind(Me),e.set("modal",this),e.on("dispose",()=>{Me.closeAll()})}}const Al=t=>{if(!t)return new URLSearchParams;if(t instanceof URLSearchParams)return t;if(typeof t!="object"||t?.constructor!==Object)throw new TypeError("only plain object is supported");const e=new URLSearchParams;for(const[i,r]of Object.entries(t))if(r!=null){if(Array.isArray(r)){for(const n of r)e.append(i,n?.toString());continue}if(typeof r=="object"&&r!==null&&r.constructor===Object){for(const[n,s]of Object.entries(r))s!=null&&e.set(`${i}[${n}]`,s?.toString());continue}e.set(i,r?.toString())}return e},Rl=(t,e,i)=>{const r=typeof t=="string"?new URL(t,window?.location?.origin):new URL(t),n=new URLSearchParams(r.search),s=Al(e);for(const[o,a]of s.entries())n.set(o,a);return r.search=n.toString(),r.hash="",r};var Up=Object.create,Zs=Object.defineProperty,Fp=Object.getOwnPropertyDescriptor,Tl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ol=t=>{throw TypeError(t)},qp=(t,e,i)=>e in t?Zs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Bp=(t,e)=>Zs(t,"name",{value:e,configurable:!0}),Hp=t=>[,,,Up(t?.[Tl("metadata")]??null)],zp=["class","method","getter","setter","accessor","field","value","get","set"],Ll=t=>t!==void 0&&typeof t!="function"?Ol("Function expected"):t,Wp=(t,e,i,r,n)=>({kind:zp[t],name:e,metadata:r,addInitializer:s=>i._?Ol("Already initialized"):n.push(Ll(s||null))}),Kp=(t,e)=>qp(e,Tl("metadata"),t[3]),Vp=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Gp=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&Fp(n,i));Bp(n,i);for(var h=r.length-1;h>=0;h--)c=Wp(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,Ll(o)&&(n=o);return Kp(t,n),p&&Zs(n,i,p),u?l^4?s:p:n},Nl,eo,Ml;Nl=[xe(["api","storage"])];class mn extends(Ml=ht){constructor(e){super(e,"wiki",!1),this.ctx=e,this._data={},this.CACHE_VERSION=4,this.CACHE_TTL={siteinfo:1e3*60*60*24*3,userinfo:1e3*60*30},this.QUERY_DATA={siteinfo:{meta:"siteinfo|filerepoinfo",siprop:"general|specialpagealiases|namespacealiases|namespaces|magicwords",friprop:"canUpload|displayname|initialCapital|local|name|rootUrl|scriptDirUrl|thumbUrl|url"},userinfo:{meta:"userinfo",uiprop:"groups|rights|blockinfo|options"}},this.CACHE_DB=void 0,this.mwConfig={get:((i,r)=>window?.mw?.config?.get?.(i,r)??r),has:(i=>window?.mw?.config?.exists?.(i)??!1),get values(){return window?.mw?.config?.values||{}}},this.CACHE_DB=e.storage.createDatabase("wiki-metadata",1/0,this.CACHE_VERSION)}get logger(){return this.ctx.logger("WIKI_METADATA")}get api(){return this.ctx.api}async start(){await Promise.all(Object.keys(this.QUERY_DATA).map(e=>this.initData(e))),this.ctx.on("clear-cache",this.onClearCache.bind(this)),this.ctx.set("getUrl",this.getUrl.bind(this)),this.ctx.set("getSciprtUrl",this.getSciprtUrl.bind(this)),this.ctx.set("getMainpageUrl",this.getMainpageUrl.bind(this)),this.ctx.inject(["preferences","$"],e=>{const i=e.$;e.preferences.registerCustomConfig("WikiMetadataService",A.object({WikiMetadataService:A.const(f("div",{children:[f("h3",{children:i`Wiki Informations`}),f("ul",{children:[f("li",{children:[f("strong",{children:[i`Site`,":"]})," ",this.general.sitename," (",this.landingPageUrl,")"]}),f("li",{children:[f("strong",{children:i`User`}),": ",this.userInfo.name," (ID: ",this.userInfo.id,")"]}),f("li",{children:[f("strong",{children:i`Groups`}),": ",this.userGroups.join(", ")||"None"]})]}),f("div",{children:[f("p",{style:{fontStyle:"italic"},children:i`If the information shown above is incorrect (for example, the user is not you), click the button below.`}),f("button",{className:"btn danger",onClick:async r=>{r.preventDefault(),await e.serial("clear-cache")||window.location.reload()},children:["🧹 ",i`Clear caches & Reload`]})]})]})).role("raw-html")}).description("WikiMetadataService"),"about")}),this.logger.info("All initialized",this._data)}async initData(e,i=!1){const r=i?null:await this.fetchFromCache(e);if(r)return this._data[e]=r,this.logger.debug("Using cached",e,r),r;{const n=await this.fetchFromApi(e);return this.saveToCache(e,n),this._data[e]=n,this.logger.debug("Fetched from API",e,n),n}}getCacheKey(e){return`${e}:${new URL(this.ctx.api.config.baseURL).pathname.replace(/^\//,"")}`}async fetchFromApi(e){return this.api.get({action:"query",...this.QUERY_DATA[e]}).then(({data:i})=>{if(typeof i?.query!="object"||i.query===null)throw new Error("Invalid query data",{cause:i});return e==="siteinfo"?i.query:i.query?.[e]||i.query}).catch(i=>(this.logger.error("Failed to fetch",i),Promise.reject(i)))}async fetchFromCache(e){const i=this.getCacheKey(e);return await this.CACHE_DB.get(i,this.CACHE_TTL[e])}async saveToCache(e,i){const r=this.getCacheKey(e);return this.CACHE_DB.set(r,i)}async invalidateCache(e){const i=this.getCacheKey(e);return this.CACHE_DB.delete(i)}async onClearCache(){await this.CACHE_DB.clear()}get _raw(){return this._data}get siteInfo(){return this._data.siteinfo}get general(){return this.siteInfo.general}get specialPageAliases(){return this.siteInfo.specialpagealiases}get namespaceAliases(){return this.siteInfo.namespacealiases}get namespaces(){return this.siteInfo.namespaces}get namespaceMap(){const e=Object.values(this.namespaces).map(i=>({id:i.id,canonical:i.canonical,aliases:this.namespaceAliases.filter(r=>r.id===i.id).map(r=>r.alias)})).sort((i,r)=>i.id-r.id);return Reflect.defineProperty(this,"namespaceMap",{get:()=>e}),e}get magicWords(){return this.siteInfo.magicwords}get userInfo(){return this._data.userinfo}get userOptions(){return this.userInfo.options}get isUserBlocked(){return this.userInfo.blockedbyid&&this.userInfo.blockexpiry&&new Date(this.userInfo.blockexpiry).getTime()>Date.now()}get userGroups(){return this.userInfo.groups}get userRights(){return this.userInfo.rights}get fileRepos(){return this.siteInfo.repos||[]}get baseUrl(){const e=this.general.server;return e.startsWith("//")?`${window?.location?.protocol||"https:"}//${e.slice(2)}`:e}get landingPageUrl(){return this.general.base}get mainPageName(){return this.general.mainpage}get mainPageUrl(){return this.getUrl(this.mainPageName)}get articlePath(){return this.general.articlepath}get scriptPath(){return this.general.scriptpath}get articleBaseUrl(){return`${this.baseUrl}${this.articlePath}`}get scriptBaseUrl(){return`${this.baseUrl}${this.scriptPath}`}getSciprtUrl(e="index"){return`${this.scriptBaseUrl}/${e.replace(/\.php$/,"")}.php`}getMainpageUrl(e){return Rl(this.siteInfo.general.base,e).toString()}getUrl(e,i){const r=Al(i);let n;return typeof e=="string"&&e!==""?n=new URL(`${this.articleBaseUrl.replace("$1",e)}`):typeof e=="number"?(r.set("curid",e.toString()),n=new URL(this.getSciprtUrl("index"))):n=new URL(this.getSciprtUrl("index")),n.search=r.toString(),n.toString()}hasRight(e){return this.userRights.includes(e)}hasAnyRight(...e){return e.some(i=>this.hasRight(i))}hasEveryRights(...e){return e.every(i=>this.hasRight(i))}inGroup(e){return this.userGroups.includes(e)}inAnyGroup(...e){return this.userGroups.some(i=>e.includes(i))}getBlockInfo(){return this.isUserBlocked?{blockid:this.userInfo.blockid,blockedby:this.userInfo.blockedbyid,blockedbyid:this.userInfo.blockedbyid,blockreason:this.userInfo.blockreason,blockedtimestamp:this.userInfo.blockedtimestamp,blockexpiry:this.userInfo.blockexpiry}:null}}eo=Hp(Ml),mn=Gp(eo,0,"WikiMetadataService",Nl,mn),Vp(eo,1,mn);class Qp{constructor(){this.values={}}get length(){return Object.keys(this.values).length}clear(){this.values={}}getItem(e){return this.values[e]??null}setItem(e,i){this.values[e]=typeof i=="string"?i:String(i)}removeItem(e){delete this.values[e]}key(e){return Object.keys(this.values)[e]??null}}const Yp=()=>new Proxy(new Qp,{set(t,e,i){return typeof e=="string"&&t.setItem(e,i),!0},get(t,e){return typeof e=="string"&&!(e in t)?t.getItem(e):Reflect.get(t,e)}}),Xp=(()=>{const t=Symbol.for("IPE.GlobalMemoryStorage");return t in globalThis||(globalThis[t]=Yp()),globalThis[t]})();class Jp{constructor(e,i,r=1/0,n,s="localStorage"){this.dbName=e,this.storeName=i,this.ttl=r,this.version=n,this.engine=s,typeof r!="number"&&(this.ttl=Number(r)),(isNaN(this.ttl)||this.ttl<=0)&&(this.ttl=1/0),this.engine==="localStorage"&&"localStorage"in window?this.db=window.localStorage:this.engine==="sessionStorage"&&"sessionStorage"in window?this.db=window.sessionStorage:this.db=Xp}makeKey(e){return`${this.dbName?this.dbName+":":""}${this.storeName?this.storeName+"/":""}${e}`}load(e){const i=this.getRaw(e);if(i===null)return null;let r;try{r=JSON.parse(i)}catch{return this.deleteSync(e),null}const n=r;return typeof n.time!="number"||!("value"in n)?(this.deleteSync(e),null):typeof this.version<"u"&&typeof this.version<"u"&&n.version!==this.version?(this.deleteSync(e),null):n}getRaw(e){const i=this.makeKey(e);return this.db.getItem(i)}setRaw(e,i){const r=this.makeKey(e);try{this.db.setItem(r,i)}catch{}}deleteSync(e){const i=this.makeKey(e);this.db.removeItem(i)}isExpired(e,i=this.ttl){return e?Date.now()-e.time>i:!1}async get(e,i=this.ttl,r){const n=this.load(e),s=this.isExpired(n,i);if(!n||s){if(typeof r=="function"){const o=await r();return await this.set(e,o),o}return null}return n.value}async set(e,i){const r=Date.now();if(typeof e=="string"){const o=e,a=i;if(a===null||typeof a>"u"){await this.delete(o);return}const c={time:r,value:a,version:this.version};return this.setRaw(o,JSON.stringify(c)),c}const n=e,s={};for(const[o,a]of Object.entries(n)){if(a===null||typeof a>"u"){this.deleteSync(o);continue}const c={time:r,value:a,version:this.version};this.setRaw(o,JSON.stringify(c)),s[o]=c}return s}async has(e,i=this.ttl){const r=this.load(e);return r!==null&&!this.isExpired(r,i)}async delete(e){this.deleteSync(e)}async updatedAt(e){const i=this.load(e);return i?i.time:0}async clear(){const e=this.makeKey(""),i=[];for(let r=0;r<this.db.length;r++){const n=this.db.key(r);n&&n.startsWith(e)&&i.push(n)}for(const r of i)this.db.removeItem(r);return this}async*keys(){const e=this.makeKey("");for(let i=0;i<this.db.length;i++){const r=this.db.key(i);r&&r.startsWith(e)&&(yield r.slice(e.length))}}async*values(){for await(const e of this.keys()){const i=this.load(e);if(i){if(this.isExpired(i)){this.deleteSync(e);continue}yield i}}}async*entries(){for await(const e of this.keys()){const i=this.load(e);if(i){if(this.isExpired(i)){this.deleteSync(e);continue}yield[e,i]}}}}var Te;(t=>{t.cache=new Map,t.defaults=Object.freeze({iterBatch:100,retry:{attempts:3,baseDelayMs:16}}),t.sleep=l=>new Promise(u=>setTimeout(u,l));function e(l){const u=l?.name??"";return u==="AbortError"||u==="InvalidStateError"||u==="TransactionInactiveError"||u==="UnknownError"}t.shouldReconnect=e;async function i(l,u,d){const y=Math.max(1,l.attempts);for(let p=0;p<y;p++)try{return await u(p)}catch(h){if(p===y-1)throw h;await d?.(h,p);const _=l.baseDelayMs*Math.pow(2,p)+Math.floor(Math.random()*10);await(0,t.sleep)(_)}throw new Error("withRetry exhausted unexpectedly")}t.withRetry=i;function r(l,u,d){return new Promise((y,p)=>{const h=indexedDB.open(l,u);h.onupgradeneeded=()=>{try{const _=h.result,k=h.transaction;d?.(_,k)}catch(_){p(_)}},h.onerror=()=>p(h.error),h.onblocked=()=>{},h.onsuccess=()=>{const _=h.result;_.onversionchange=()=>{try{_.close()}finally{t.cache.delete(l)}},y(_)}})}async function n(l,u,d){let y=!l.objectStoreNames.contains(u),p=[];if(!y&&d?.indexes?.length){const k=l.transaction(u,"readonly"),P=k.objectStore(u),b=new Set(Array.from(P.indexNames));p=(d.indexes||[]).filter(m=>!b.has(m.name)),await new Promise((m,g)=>{k.oncomplete=()=>m(),k.onabort=()=>g(k.error),k.onerror=()=>g(k.error)})}if(!y&&p.length===0)return l;const h=l.version+1;l.close();const _=await r(l.name,h,(k,P)=>{let b;k.objectStoreNames.contains(u)?b=P.objectStore(u):b=k.createObjectStore(u,{keyPath:d?.keyPath??void 0,autoIncrement:!!d?.autoIncrement});for(const m of p)b.indexNames.contains(m.name)||b.createIndex(m.name,m.keyPath,m.options)});return _.onversionchange=()=>{try{_.close()}finally{t.cache.delete(_.name)}},_}async function s(l,u,d){let y=t.cache.get(l);return y?(y=y.then(p=>n(p,u,d)),t.cache.set(l,y)):(y=(async()=>{const p=await r(l);return n(p,u,d)})(),t.cache.set(l,y)),y}t.getDB=s;async function o(l){const u=t.cache.get(l);if(t.cache.delete(l),u)try{(await u).close()}catch{}}t.closeConnection=o;function a(l){return new Promise((u,d)=>{l.onsuccess=()=>u(l.result),l.onerror=()=>d(l.error)})}t.asyncRequest=a;function c(l){return new Promise((u,d)=>{l.oncomplete=()=>u(),l.onabort=()=>d(l.error??new DOMException("Aborted","AbortError")),l.onerror=()=>d(l.error??new DOMException("TransactionError","UnknownError"))})}t.waitTx=c})(Te||(Te={}));let Zp=class{constructor(e,i,r={}){this.dbName=e,this.storeName=i,this.options=r}get _iterBatch(){return this.options.iterBatch??Te.defaults.iterBatch}get _retryCfg(){const e=this.options.retry??Te.defaults.retry;return{attempts:e.attempts??3,baseDelayMs:e.baseDelayMs??16}}async _withStore(e,i){const r=this._retryCfg;return Te.withRetry(r,async()=>{const n=await Te.getDB(this.dbName,this.storeName,this.options.ensure);try{const s=n.transaction(this.storeName,e),o=s.objectStore(this.storeName),a=await i(o);return await Te.waitTx(s),a}catch(s){throw s}},async n=>{Te.shouldReconnect(n)&&await Te.closeConnection(this.dbName)})}async get(e){return this._withStore("readonly",async i=>{const r=await Te.asyncRequest(i.get(e));return r===void 0?void 0:r})}async set(e,i){return await this._withStore("readwrite",async r=>{const n=this.options.ensure?.keyPath!=null?r.put(i):r.put(i,e);await Te.asyncRequest(n)}),this}async delete(e){return this._withStore("readwrite",async i=>{const r=await Te.asyncRequest(i.get(e))!==void 0;return await Te.asyncRequest(i.delete(e)),r})}async clear(){await this._withStore("readwrite",async e=>{await Te.asyncRequest(e.clear())})}async has(e){return await this.get(e)!==void 0}async count(){return this._withStore("readonly",async e=>await Te.asyncRequest(e.count())??0)}async*_iterateEntries(){let e=null,i=!1;const r=Math.max(1,this._iterBatch);for(;!i;){const n=await this._withStore("readonly",async s=>{const o=[],a=e===null?void 0:IDBKeyRange.lowerBound(e,!0);return await new Promise((c,l)=>{const u=s.openCursor(a);u.onerror=()=>l(u.error),u.onsuccess=()=>{const d=u.result;if(!d){i=!0,c();return}o.push([d.key,d.value]),e=d.key,o.length>=r?c():d.continue()}}),o});for(const s of n)yield s;if(n.length===0)break}}entries(){return this._iterateEntries()}async*keys(){for await(const[e]of this.entries())yield e}async*values(){for await(const[,e]of this.entries())yield e}[Symbol.asyncIterator](){return this.entries()[Symbol.asyncIterator]()}async forEach(e){for await(const[i,r]of this.entries())await e(r,i,this)}async getMany(e){const i=new Map;for await(const r of e)i.set(r,void 0);return await this._withStore("readonly",async r=>{await Promise.all(i.keys().map(async n=>{const s=await Te.asyncRequest(r.get(n));i.set(n,s===void 0?void 0:s)}))}),i}async setMany(e){const i=this.options.ensure?.keyPath!=null;return await this._withStore("readwrite",async r=>{for await(const[n,s]of e){const o=i?r.put(s):r.put(s,n);await Te.asyncRequest(o)}}),this}async deleteMany(e){let i=0;return await this._withStore("readwrite",async r=>{for await(const n of e)await Te.asyncRequest(r.get(n))!==void 0&&i++,await Te.asyncRequest(r.delete(n))}),i}async disconnect(){await Te.closeConnection(this.dbName)}};class eg{constructor(e,i,r=1/0,n){this.dbName=e,this.storeName=i,this.ttl=r,this.version=n,this.db=new Zp(e,i),this.keys=this.db.keys.bind(this.db),this.values=this.db.values.bind(this.db),this.entries=this.db.entries.bind(this.db),typeof this.ttl!="number"&&(this.ttl=Number(this.ttl)),(isNaN(this.ttl)||this.ttl<=0)&&(this.ttl=1/0),this._clearExpiredEntries().catch(()=>{})}async _clearExpiredEntries(){if(this.ttl===1/0)return;const e=Date.now(),i=[];for await(const[r,n]of this.db.entries())typeof n.time=="number"&&e-n.time>this.ttl&&i.push(r);i.length>0&&await this.db.deleteMany(i)}async get(e,i=this.ttl,r){const n=await this.loadFromDB(e),s=this.checkIfExpired(n,i);if(!n||s){if(typeof r=="function"){const o=await r();return await this.set(e,o),o}return null}return n.value}async set(e,i){const r=Date.now();if(typeof e=="string"){const c=e,l=i;if(l===null||typeof l>"u")return this.delete(c);const u={time:r,value:l,version:this.version};return await this.db.set(c,u),u}const n=e,s=[],o=[],a={};for(const[c,l]of Object.entries(n))if(l===null||typeof l>"u")o.push(c);else{const u={time:r,value:l,version:this.version};s.push([c,u]),a[c]=u}return s.length>0&&await this.db.setMany(s),o.length>0&&await this.db.deleteMany(o),a}async has(e,i=this.ttl){const r=await this.loadFromDB(e),n=this.checkIfExpired(r,i);return r!==null&&!n}async delete(e){await this.db.delete(e)}async updatedAt(e){const i=await this.loadFromDB(e);return i?i.time:0}async loadFromDB(e){const i=await this.db.get(e);if(i===void 0)return null;if(typeof i.time!="number"||typeof i.value>"u"){try{await this.delete(e)}catch{}return null}if(typeof this.version<"u"&&typeof this.version<"u"&&i.version!==this.version){try{await this.delete(e)}catch{}return null}return i}checkIfExpired(e,i=this.ttl){return e?Date.now()-e.time>i:!1}async clear(){return await this.db.clear(),this}}class tg extends ht{constructor(e,i){super(e,"storage",!1),this.config=i,this.kv=this.createDatabase("key-val",0,1,"indexedDB"),this.simpleKV=this.createDatabase("~",0,1,"localStorage"),this.memoryKV=this.createDatabase("~",0,1,"memory")}createDatabase(e,i,r,n="indexedDB"){const s="indexedDB"in window&&window.indexedDB!==null;switch(n==="indexedDB"&&!s&&(n="localStorage"),n){case"indexedDB":return new eg(this.config.dbName,e,i,r);case"localStorage":case"sessionStorage":case"memory":return new Jp(this.config.dbName,e,i,r,n);default:throw new Error(`Unsupported storage engine: ${n}`)}}}function Tt(t){return function(e){return e.PreferencesSchema=t,e}}function Dl(t){return t==="html"?[document.documentElement]:t==="body"?[document.body]:[document.documentElement,document.body]}function to(t,e){return t.some(i=>e.some(r=>i.classList.contains(r)))}function ig(t){const e=t.target??"both",i=t.systemClasses??[];let r=null,n=null,s=null;return{name:t.name,match(){return to([document.documentElement,document.body],t.skinClasses)},getCurrentTheme(){const o=Dl(e);return to(o,t.darkClasses)||i.length>0&&to(o,i)&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"},startObserving(o){this.stopObserving(),r=new MutationObserver(o);for(const a of Dl(e))r.observe(a,{attributes:!0,attributeFilter:["class"]});i.length>0&&(n=window.matchMedia("(prefers-color-scheme: dark)"),s=o,n.addEventListener("change",s))},stopObserving(){r?.disconnect(),r=null,n&&s&&(n.removeEventListener("change",s),n=null,s=null)}}}const rg=[{name:"MoeSkin",skinClasses:["skin-moeskin"],darkClasses:["dark"],target:"html"},{name:"Fandom Desktop",skinClasses:["skin-fandomdesktop"],darkClasses:["theme-fandomdesktop-dark"]},{name:"Fandom Mobile",skinClasses:["skin-fandommobile"],darkClasses:["theme-fandommobile-dark"]},{name:"Vector 2022",skinClasses:["skin-vector-2022"],darkClasses:["skin-theme-clientpref-night"],systemClasses:["skin-theme-clientpref-os"],target:"html"},{name:"Citizen",skinClasses:["skin-citizen"],darkClasses:["skin-theme-clientpref-night"],systemClasses:["skin-theme-clientpref-os"],target:"html"}];var ng=Object.create,io=Object.defineProperty,sg=Object.getOwnPropertyDescriptor,jl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ul=t=>{throw TypeError(t)},og=(t,e,i)=>e in t?io(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ag=(t,e)=>io(t,"name",{value:e,configurable:!0}),lg=t=>[,,,ng(t?.[jl("metadata")]??null)],cg=["class","method","getter","setter","accessor","field","value","get","set"],Fl=t=>t!==void 0&&typeof t!="function"?Ul("Function expected"):t,ug=(t,e,i,r,n)=>({kind:cg[t],name:e,metadata:r,addInitializer:s=>i._?Ul("Already initialized"):n.push(Fl(s||null))}),dg=(t,e)=>og(e,jl("metadata"),t[3]),fg=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},hg=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&sg(n,i));ag(n,i);for(var h=r.length-1;h>=0;h--)c=ug(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,Fl(o)&&(n=o);return dg(t,n),p&&io(n,i,p),u?l^4?s:p:n},ql,ro,Bl;ql=[xe(["preferences"]),Tt(A.object({theme:A.union([A.const("auto").description("Follow system"),A.const("light").description("Light mode"),A.const("dark").description("Dark mode"),A.const("site").description("Follow site theme")]).default("auto").description("Theme preference")}).description("Theme settings").extra("category","general"))];class yn extends(Bl=ht){constructor(e){super(e,"theme",!1),this.ctx=e,this._mediaQueryList=null,this.adapters=[],this.activeAdapter=null,this._handleSystemThemeChange=this._onSystemThemeChange.bind(this)}async start(){this._mediaQueryList=window.matchMedia("(prefers-color-scheme: dark)"),this._mediaQueryList.addEventListener("change",this._handleSystemThemeChange);for(const e of rg)this.registerSiteThemeAdapter(ig(e));await this.applyTheme(),this.ctx.on("preferences/changed",async({changes:e})=>{"theme"in e&&await this.applyTheme()})}stop(){this._mediaQueryList&&this._mediaQueryList.removeEventListener("change",this._handleSystemThemeChange),this.activeAdapter?.stopObserving()}registerSiteThemeAdapter(e){return this.adapters.unshift(e),this.resolveActiveAdapter(),this.applyTheme(),()=>{this.adapters=this.adapters.filter(i=>i!==e),this.activeAdapter===e&&(e.stopObserving(),this.activeAdapter=null,this.resolveActiveAdapter()),this.applyTheme()}}resolveActiveAdapter(){this.activeAdapter=this.adapters.find(e=>e.match())??null}async _onSystemThemeChange(){await this.applyTheme()}async applyTheme(){const e=await this.ctx.preferences.get("theme")||"auto";this.updateSiteObserver(e);const i=this.getTheme(e);this.applyThemeClass(i),this.ctx.emit("theme/changed",{ctx:this.ctx,theme:i})}updateSiteObserver(e){e==="site"&&this.activeAdapter?this.activeAdapter.startObserving(()=>this.applyTheme()):this.activeAdapter?.stopObserving()}getTheme(e){return e==="auto"?this._mediaQueryList?.matches?"dark":"light":e==="site"?this.activeAdapter?this.activeAdapter.getCurrentTheme():this._mediaQueryList?.matches?"dark":"light":e}applyThemeClass(e){const i=document.body;e==="dark"?(i.classList.add("ipe-theme-dark"),i.setAttribute("data-ipe-theme","dark")):(i.classList.remove("ipe-theme-dark"),i.setAttribute("data-ipe-theme","light"))}get currentTheme(){return document.body.classList.contains("ipe-theme-dark")?"dark":"light"}}ro=lg(Bl),yn=hg(ro,0,"ThemeService",ql,yn),fg(ro,1,yn);var _t=(t=>(t.preferences="preferences",t.watch="watch",t.unwatch="unwatch",t.nochange="nochange",t))(_t||{});function pg(t){const i=class i{constructor(n,s=!0){this._loaded=s,this.api=t,n.revisions?.forEach(o=>{typeof o?.slots?.main=="object"&&Object.assign(o,o.slots.main)}),this.pageInfo={...i.DEFAULT_PAGE_INFO,...n}}static async newFromApi(n){const{data:s}=await this.api.get({...i.DEFAULT_QUERY_PARAMS,...n}),o=s?.query?.pages?.[0];if(!o||!o.title)throw new Error("Invalid page info",{cause:s});return new i(o,!0)}static newBlankPage(n={}){return new i(n,!1)}static async newFromAnyKind(n){const{title:s,pageId:o,revisionId:a}=n||{};return a?this.newFromApi({revids:parseInt(a.toString(),10)}):o?this.newFromApi({pageids:parseInt(o.toString(),10)}):s?this.newFromApi({titles:s.toString()}):null}static async newBatchFromApi(n){const{titles:s,pageids:o,revids:a,...c}=n||{},{data:l}=await this.api.post({...i.DEFAULT_QUERY_PARAMS,titles:s?.join("|")??void 0,pageids:o?.join("|")??void 0,revids:a?.join("|")??void 0,...c});return l?.query?.pages?.map(u=>new i(u,!0))||[]}async parse(n){return this.api.post({action:"parse",page:this.pageInfo.title,prop:"text|langlinks|categories|links|templates|images|externallinks|sections|revid|displaytitle|iwlinks|properties|parsewarnings",...n})}async preview(n,s){return this.parse({action:"parse",page:void 0,title:this.title,text:n,pst:1,preview:1,disableeditsection:1,disablelimitreport:1,...s})}async edit(n,s){const o=await this.api.postWithEditToken({action:"edit",title:this.title,starttimestamp:this.pageInfo.touched,basetimestamp:this.revisions[0]?.timestamp,...n,...s});if(o.data?.edit?.result==="Success")return o;throw new Rt([{module:"edit",code:"editfailure",text:"Unknown edit failure. Please try again.",docref:"https://www.mediawiki.org/wiki/API:Edit"}],o)}async createOnly(n,s){return this.edit(n,{createonly:1,recreate:n.recreate,...s})}async delete(n,s){return this.api.postWithEditToken({action:"delete",title:this.pageInfo.title||void 0,pageid:this.pageInfo.pageid||void 0,reason:n,deletetalk:s?.deletetalk,...s})}async moveTo(n,s,o){return this.api.postWithEditToken({action:"move",from:this.pageInfo.title,to:n,reason:s,movetalk:1,movesubpages:1,...o})}userCan(n){return!!this.pageInfo?.actions?.[n]}userCanEdit(){return this.userCan("edit")}async reloadSelfInfo(){const n=await i.newFromApi({pageids:this.pageInfo.pageid,titles:this.pageInfo.title}),s=(this.pageInfo.revisions||[]).concat(n.revisions||[]).sort((o,a)=>o.revid-a.revid).reduce((o,a)=>(o.find(c=>c.revid===a.revid)||o.push(a),o),[]);return this.pageInfo=n.pageInfo,this.pageInfo.revisions=s,this._loaded=!0,this}get pageid(){return this.pageInfo.pageid}get title(){return this.pageInfo.title}get ns(){return this.pageInfo.ns}get contentmodel(){return this.pageInfo.contentmodel}get fullurl(){return this.pageInfo.fullurl}get canonicalurl(){return this.pageInfo.canonicalurl}get editurl(){return this.pageInfo.editurl}get revisions(){return this.pageInfo.revisions||[]}get lastrevid(){return this.pageInfo.lastrevid}get templates(){return this.pageInfo.templates||[]}get images(){return this.pageInfo.images||[]}};i.api=t,i.DEFAULT_QUERY_PARAMS={action:"query",prop:"info|templates|transcludedin|images|pageimages|revisions",inprop:"protection|url|varianttitles",intestactions:"edit|move|delete",tllimit:"max",tilimit:"max",imlimit:"max",piprop:"thumbnail|name|original",pithumbsize:"200",pilimit:"max",rvprop:"ids|timestamp|flags|comment|user|content",rvslots:"main"},i.DEFAULT_PAGE_INFO={pageid:0,ns:0,title:"",contentmodel:"wikitext",pagelanguage:"",pagelanguagehtmlcode:"",pagelanguagedir:"ltr",touched:new Date().toISOString(),lastrevid:0,length:0,protection:[],restrictiontypes:[],fullurl:"",canonicalurl:"",editurl:"",varianttitles:{},actions:{edit:!0,move:!1,delete:!1},revisions:[],templates:[],images:[]};let e=i;return e}const Fa=class Fa extends ht{constructor(e){super(e,"wikiPage",!0),this.ctx=e,this.WikiPage=pg(this.ctx.api)}async createInstance(e,i=!1){return await this.WikiPage.newFromApi(e)}async newFromTitle(e,i=!1,r,n=!1){return this.createInstance({titles:e.toString(),converttitles:i,rvsection:r},n)}async newFromPageId(e,i,r=!1){return this.createInstance({pageids:e,rvsection:i},r)}async newFromRevision(e,i,r=!1){return await this.createInstance({revids:e,rvsection:i},r)}newBlankPage(e={}){return this.WikiPage.newBlankPage(e)}};Fa.inject=["api"];let no=Fa;const Hl=new WeakMap,br={toDBKey:t=>t.replace(/ /g,"_"),toNormalText:t=>t.replace(/_/g," "),ensureCase:(t,e)=>e==="first-letter"?t.charAt(0).toUpperCase()+t.slice(1):t},vr={normalizeSpecialPageName:t=>t.toLowerCase(),buildSpecialPageIndex:t=>{const e=new Map,i=new Map,r=new Map;for(const n of t.specialpagealiases){const s=n.realname;e.set(s,s);const o=vr.normalizeSpecialPageName(s);r.set(o,s);for(const a of n.aliases){i.set(a,s);const c=vr.normalizeSpecialPageName(a);r.set(c,s)}}return{byRealName:e,byAlias:i,byNormalized:r}},findSpecialPageRealName:(t,e)=>{const i=t.split("/")[0];let r=e.byRealName.get(i)??e.byAlias.get(i);if(r!==void 0)return r;const n=vr.normalizeSpecialPageName(i);return e.byNormalized.get(n)??null}},Ot={normalizeNamespaceText:t=>t.replace(/[_\s]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),buildIndex:t=>{const e=new Map,i=new Map,r=new Map,n=new Map;for(const[s,o]of Object.entries(t.namespaces)){const a=parseInt(s);e.set(o.name,a),i.set(o.canonical??"",a);const c=Ot.normalizeNamespaceText(o.name),l=Ot.normalizeNamespaceText(o.canonical??"");n.set(c,a),n.set(l,a)}for(const s of t.namespacealiases){r.set(s.alias,s.id);const o=Ot.normalizeNamespaceText(s.alias);n.set(o,s.id)}return{byName:e,byCanonical:i,byAlias:r,byNormalized:n}},findNamespaceId:(t,e)=>{let i=e.byName.get(t)??e.byCanonical.get(t)??e.byAlias.get(t);if(i!==void 0)return i;const r=Ot.normalizeNamespaceText(t);return e.byNormalized.get(r)??null},isTalkPage:t=>t%2===1&&t>0,getDefaultNamespaceInfo:t=>({id:t,name:"",canonical:"",case:"first-letter",content:!1,nonincludable:!1,subpages:!1})};function gg(t){var s,o;const e=Hl.get(t);if(e)return e;const i=Ot.buildIndex(t),r=vr.buildSpecialPageIndex(t),a=class a{constructor(l,u){Ni(this,s);Ni(this,o);if(this.newTitle=a.create.bind(a),this.toText=this.getPrefixedText.bind(this),this.toString=this.getPrefixedDBKey.bind(this),je(this,s,l||""),je(this,o,u??0),u===void 0)this.fixNSByTitle();else{const d=this.parseTitlePrefix(ce(this,s));d&&d.namespaceId===ce(this,o)&&je(this,s,d.mainTitle)}if(this.getMainText()==="")throw new Error("Invalid title")}static create(l,u){return new a(l,u)}parseTitlePrefix(l){const u=l.indexOf(":");if(u<=0)return null;const d=l.substring(0,u),y=l.substring(u+1),p=Ot.findNamespaceId(d,a._namespaceIndex);return p===null?null:{namespaceId:p,mainTitle:y}}adoptNamespaceFromTitle(){const l=this.parseTitlePrefix(ce(this,s));l&&(je(this,s,l.mainTitle),je(this,o,l.namespaceId))}fixNSByTitle(){const l=ce(this,s).indexOf(":");if(l!==-1){if(l===0){je(this,s,ce(this,s).substring(1));return}this.adoptNamespaceFromTitle()}}getNamespaceInfo(){return a._meta.namespaces[ce(this,o)]??Ot.getDefaultNamespaceInfo(ce(this,o))}resolveSpecialFullTitle(){if(ce(this,o)!==-1)return null;const l=vr.findSpecialPageRealName(ce(this,s),a._specialPageIndex);if(!l)return null;const u=ce(this,s).includes("/")?ce(this,s).substring(ce(this,s).indexOf("/")):"";return l+u}formatMainForOutput(l){const u=this.getNamespaceInfo(),y=this.resolveSpecialFullTitle()??ce(this,s),p=l==="db"?br.toDBKey(y):br.toNormalText(y);return br.ensureCase(p,u.case)}getMainDBKey(){return this.formatMainForOutput("db")}getMainText(){return this.formatMainForOutput("text")}getMainRootText(){return this.getMainText().split("/")[0]}getPrefixedDBKey(){return ce(this,o)===0?this.getMainDBKey():`${this.getNamespaceDBKey()}:${this.getMainDBKey()}`}getPrefixedText(){return ce(this,o)===0?this.getMainText():`${this.getNamespaceText()}:${this.getMainText()}`}getNamespaceId(){return ce(this,o)}getNamespaceText(){return this.getNamespaceInfo().name??""}getNamespaceDBKey(){const l=this.getNamespaceInfo();return br.ensureCase(br.toDBKey(this.getNamespaceText()),l.case)}getSubjectPage(){if(Ot.isTalkPage(ce(this,o))){const l=ce(this,o)-1;return new a(ce(this,s),l)}return this}getTalkPage(){if(Ot.isTalkPage(ce(this,o)))return this;if(ce(this,o)<0)return null;const l=ce(this,o)+1;return a._meta.namespaces[l.toString()]?new a(ce(this,s),l):null}getURL(l){const u=this.getPrefixedDBKey();return this.buildArticleURL(u,l)}buildArticleURL(l,u){const y=a._meta.general.articlepath.replace("$1",l),p=new URL(y,location.origin);return u&&(u instanceof URLSearchParams?u:new URLSearchParams(u)).forEach((_,k)=>{p.searchParams.set(k,_)}),p}setTitle(l){je(this,s,l);const u=ce(this,o);je(this,o,0);const d=this.parseTitlePrefix(ce(this,s));return d?(u!==0&&d.namespaceId===u?(je(this,s,d.mainTitle),je(this,o,u)):(je(this,s,d.mainTitle),je(this,o,d.namespaceId)),this):this}setMainText(l){return je(this,s,l),this}setNamespaceText(l){const u=Ot.findNamespaceId(l,a._namespaceIndex);return u!==null&&je(this,o,u),this}setNamespaceId(l){return je(this,o,l),this}equals(l){return typeof l=="string"&&(l=new a(l)),this.getPrefixedDBKey()===l.getPrefixedDBKey()}isSpecial(l){if(ce(this,o)!==-1)return!1;const u=new a(l,-1);return this.getMainRootText()===u.getMainRootText()}toJSON(){return{ns:ce(this,o),text:this.getMainText(),title:this.getPrefixedText(),url:this.getURL().toString(),isSpecial:ce(this,o)<0}}};s=new WeakMap,o=new WeakMap,a._meta=t,a._namespaceIndex=i,a._specialPageIndex=r;let n=a;return Hl.set(t,n),n}const wr=()=>{let t,e;return{promise:new Promise((r,n)=>{t=r,e=n}),resolve:t,reject:e}},Vr=class Vr extends ht{constructor(e){super(e,"wikiTitle",!0),this.ctx=e,this.logger=this.ctx.logger("WikiTitleService"),this._cachedTitles=new Map,this.wiki=this.ctx.wiki,this.wikiBaseUrl=this.wiki.baseUrl,this.wikiArticlePath=this.wiki.articlePath.replace("$1",""),this.wikiArticleBaseUrl=this.wiki.articleBaseUrl.replace("$1",""),this.wikiIndexPhpUrl=this.wiki.getSciprtUrl("index.php"),this.Title=gg(this.ctx.wiki.siteInfo)}newTitle(e,i){return typeof e=="string"?new this.Title(e,i):e}newMainPageTitle(){return this.newTitle(this.ctx.wiki.mainPageName)}async newTitleFromUrl(e){const i=this.parseWikiLink(e);return i?.title?i.title:i?.pageId?this.newTitleFromPageId(i.pageId):null}async newTitleFromAnyId(e,i=!1){const{title:r,pageId:n,revId:s}=e??{};if(typeof r=="string")return this.newTitle(r);let o,a;if(s?(o=parseInt(s.toString(),10),a="revid"):n&&(o=parseInt(n.toString(),10),a="pageid"),!o||!a||isNaN(o)||o<=0)throw new Error("Invalid id or kind",{cause:e});if(!i&&this._cachedTitles.has(`${a}:${o}`))return await this._cachedTitles.get(`${a}:${o}`);const{promise:c,resolve:l,reject:u}=wr();this._cachedTitles.set(`${a}:${o}`,c);try{const{wikiPage:d}=this.ctx;let y=null;if(a==="pageid")y=await d.newFromPageId(o);else if(a==="revid")y=await d.newFromRevision(o);else throw new Error(`Invalid kind: ${a}`);l(this.newTitle(y.title))}catch(d){this._cachedTitles.delete(`${a}:${o}`),u(d)}return c}async newTitleFromPageId(e){return this.newTitleFromAnyId({pageId:e})}async newTitleFromRevision(e){return this.newTitleFromAnyId({revId:e})}resolveSpecialPageTarget(e){const i=typeof e=="string"?this.newTitle(e):e;if(!i||i.getNamespaceId()!==-1)return null;let r,n,s="view";const o=i.getMainDBKey().split("/").slice(1).join("/")||"";if(i.isSpecial("edit")&&o)r=o,s="edit";else if(i.isSpecial("talkpage")&&o){const a=i.newTitle(o).getTalkPage();if(!a)return null;r=a.getPrefixedDBKey()}else if(i.isSpecial("mypage"))r=i.newTitle(this.ctx.wiki.userInfo.name,2).getPrefixedDBKey()+(o?`/${o}`:"");else if(i.isSpecial("mytalk"))r=i.newTitle(this.ctx.wiki.userInfo.name,3).getPrefixedDBKey()+(o?`/${o}`:"");else if(i.isSpecial("newsection")&&o)r=o,n="new",s="edit";else return null;return{title:new this.Title(r),section:n,action:s}}isWikiLink(e){return e.startsWith(this.wikiArticleBaseUrl)||e.startsWith(this.wikiIndexPhpUrl)||e.startsWith(`${this.wikiBaseUrl}/?`)||e===this.ctx.wiki.landingPageUrl}validateHrefAttr(e){return typeof e!="string"?!1:!Vr.REG_SKIPPED_HREF.test(e)}parseWikiLink(e){if(!e||typeof e=="string"&&!this.validateHrefAttr(e))return null;const i=Rl(e);if(!this.isWikiLink(i.toString()))return null;const r=i.searchParams,n=i.hash.replace("#",""),s=r.get("action")||"view",o=r.get("title")||"",a=parseInt(r.get("curid")||"0",10),c=parseInt(r.get("oldid")||"0",10);let l=o||(()=>{try{return decodeURIComponent(i.pathname.substring(this.wikiArticlePath.length))}catch(p){return this.logger.error("parseLink",i,p),""}})();l.endsWith("index.php")&&(l="");let u,d,y;if(c)y=c;else if(a)d=a;else if(l)u=this.newTitle(l);else if(i.origin+i.pathname===this.ctx.wiki.landingPageUrl)u=this.newMainPageTitle();else return null;return{title:u,pageId:d,revId:y,url:i,params:r,hash:n,action:s}}};Vr.inject=["wiki","wikiPage"],Vr.REG_SKIPPED_HREF=/^(#|javascript:|vbscript:|file:)/i;let so=Vr;const zl=t=>typeof t=="function";async function mg(t){return zl(t)?await t():t}function Wl(t){return zl(t)?t():t}var yg=Object.create,oo=Object.defineProperty,bg=Object.getOwnPropertyDescriptor,Kl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Vl=t=>{throw TypeError(t)},vg=(t,e,i)=>e in t?oo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,wg=(t,e)=>oo(t,"name",{value:e,configurable:!0}),_g=t=>[,,,yg(t?.[Kl("metadata")]??null)],xg=["class","method","getter","setter","accessor","field","value","get","set"],Gl=t=>t!==void 0&&typeof t!="function"?Vl("Function expected"):t,kg=(t,e,i,r,n)=>({kind:xg[t],name:e,metadata:r,addInitializer:s=>i._?Vl("Already initialized"):n.push(Gl(s||null))}),Sg=(t,e)=>vg(e,Kl("metadata"),t[3]),Eg=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},$g=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&bg(n,i));wg(n,i);for(var h=r.length-1;h>=0;h--)c=kg(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,Gl(o)&&(n=o);return Sg(t,n),p&&oo(n,i,p),u?l^4?s:p:n},Ql,ao,Yl;Ql=[xe(["storage","wiki"])];class bn extends(Yl=ht){constructor(e){super(e,"preferences",!0),this.ctx=e,this.db=void 0,this.customRegistries=[],this.categoryDefinitions=[],this._defaultPreferences={},e.set("prefs",this),this.db=e.storage.createDatabase(`preferences:${e.wiki.userInfo.id}`,1/0);try{this._migrageFromLegacyMasterDB()}catch{}}get logger(){return this.ctx.logger("PREFERENCES")}async start(){}async get(e,i){if(!e)return this.getAll();i??(i=()=>{const n=this.defaultOf(e);return this.logger.debug(e,`(fallback value: ${n})`),n});const r=await this.db.get(e,void 0);return r!==null?r:await mg(i)}async getAll(){const e=this.loadDefaultConfigs();for await(const[i,r]of this.db.entries())i!=="_touched"&&i in e&&(e[i]=r.value);return e}async set(e,i){return(await this.setMany({[e]:i}))[e]}async setMany(e){const i=this.loadDefaultConfigs(),r={};for(const[n,s]of Object.entries(e))s===i[n]||s===void 0?r[n]=void 0:r[n]=s;return await this.db.set(r),this.ctx.emit("preferences/changed",{ctx:this.ctx,input:e,changes:r}),r}defaultOf(e){var i;return(i=this._defaultPreferences)[e]??(i[e]=this.loadDefaultConfigs()[e])}async getExportableRecord(e){e??(e=await this.getAll());const i=this.loadDefaultConfigs(),r={};return Object.entries(i).sort(([n],[s])=>n.localeCompare(s)).forEach(([n,s])=>{const o=e[n];o!==void 0&&o!==s&&(r[n]=o)}),r}loadDefaultConfigs(){const e={};return this.getConfigRegistries().forEach(i=>{try{const r=i.schema({});Object.entries(r).forEach(([n,s])=>{e[n]=s})}catch{}}),Object.entries(e).forEach(([i,r])=>{this._defaultPreferences[i]=r}),e}registerCustomConfig(e,i,r){const n={name:e,schema:i,category:r||"general"},s=this.customRegistries.findIndex(o=>o.name===e);return s>=0?this.customRegistries[s]=n:this.customRegistries.push(n),this}getConfigRegistries(e){return Array.from(this.ctx.registry.entries()).map(([i])=>i===null?{name:"@root",schema:Fi?.PreferencesSchema||null}:{name:i.name,schema:i?.PreferencesSchema||null}).filter(i=>i.schema!==null).map(i=>({...i,category:i.schema.meta.category||"general"})).concat(this.customRegistries).filter(i=>!e||i.category===e)}getAllSchema(){return new A(A.intersect(this.getConfigRegistries().map(e=>e.schema)))}defineCategory(e){const i=this.categoryDefinitions.findIndex(r=>r.name===e.name);return i<0?this.categoryDefinitions.push(e):this.categoryDefinitions[i]=e,this.categoryDefinitions.sort((r,n)=>(r.index??0)-(n.index??0)),this}getConfigCategories(){return this.categoryDefinitions}async _migrageFromLegacyMasterDB(){const e=this.ctx.storage.createDatabase("preferences",1/0);let i=0;for await(const[r,n]of e.entries())r!=="_touched"&&(await this.db.set(r,n.value),i++);return i&&this.logger.info(`Migrated ${i} preferences from master DB`),await e.clear(),await e?.db?.disconnect?.(),i}}ao=_g(Yl),bn=$g(ao,0,"PreferencesService",Ql,bn),Eg(ao,1,bn);var Lt=(t=>(t.ANALYTICS_API_BASE="https://analytics.ipe.wiki/api/v6",t.ANALYTICS_DASH_URL="https://analytics.ipe.wiki",t.GITHUB_URL="https://github.com/inpageedit/inpageedit-next",t.GITHUB_OWNER="inpageedit",t.GITHUB_REPO="inpageedit-next",t.HOME_URL="https://www.ipe.wiki/",t.UPDATE_LOGS_URL="https://www.ipe.wiki/changelogs/",t.PLUGIN_REGISTRY_URL="https://registry.ipe.wiki/registry.v1.json",t.I18N_INDEX_URL="https://registry.ipe.wiki/i18n/index.json",t.QQ_GROUP_ID="1026023666",t))(Lt||{});const Xl="",Jl="",Pg=/\\\{/g,Cg=/\\\}/g,Ig=new RegExp(Xl,"g"),Ag=new RegExp(Jl,"g");function Zl(t){const e=t?{...t}:void 0;return(r,...n)=>Rg(e,r,...n)}function Rg(t,e,...i){if(!e)return"";let r=String(e).replace(Pg,Xl).replace(Cg,Jl),n={},s=[];i.length===1&&Array.isArray(i[0])?s=i[0]:i.length===1&&Tg(i[0])?n=i[0]:i.length>0&&(s=i);const o=Object.create(null);if(s&&s.length)for(let a=0;a<s.length;a++)o[`$${a+1}`]=s[a];if(n&&Object.keys(n).length)for(const a of Object.keys(n))o[a]=n[a];if(t&&Object.keys(t).length)for(const a of Object.keys(t))typeof o[a]>"u"&&(o[a]=t[a]);return r=r.replace(/\{\{\s*([\s\S]*?)\s*\}\}/g,(a,c)=>{const l=String(c).trim();if(!l)return"";try{const u=Og(l,o);return u==null?"":String(u)}catch{return""}}),r.replace(Ig,"{").replace(Ag,"}")}function Tg(t){return typeof t=="object"&&t!==null&&t.constructor===Object}const Og=Lg();function Lg(){const t=new Set(["eval","Object","Array","String","Number","Boolean","Date","Math","JSON","undefined","null","true","false","NaN","Infinity","isNaN","isFinite","parseInt","parseFloat"]),e=new Function("__expr__","ctx",`
5
5
  try {
6
6
  with (ctx) {
7
7
  return (eval(__expr__));
@@ -9,7 +9,7 @@
9
9
  } catch (e) {
10
10
  throw e;
11
11
  }
12
- `);return(i,r)=>{const n=new Proxy(r,{has:(s,o)=>typeof o=="symbol"?o in s:!(typeof o=="string"&&(t.has(o)||o==="__expr__")),get:(s,o)=>{if(o in s)return s[o]}});return e(i,n)}}function Jl(t){return t.charAt(0).toLowerCase()+t.slice(1)}function Ui(t){return Jl(t).replace(/_/g,"-").replace(/.[A-Z]+/g,e=>e[0]+"-"+e.slice(1).toLowerCase())}function Ag(t){return Jl(t).replace(/-/g,"_").replace(/.[A-Z]+/g,e=>e[0]+"_"+e.slice(1).toLowerCase())}function li(t,e){let i=t[0]??"";for(let r=0;r<e.length;r++)i+=String(e[r])+(t[r+1]??"");return i}class Tg{constructor(e,i){this.languages=new Map,this.currentLanguage="en",this.missingKeys=new Map,this.usedKeys=new Set;const r=i?.language||"en";this.currentLanguage=r,this.interpolate=Xl(i?.globals),e&&Object.keys(e).length&&this.setLanguageData(r,e)}setGlobals(e){return this.interpolate=Xl(e),this}set(e,i){const r=this.currentLanguage,n=this.ensureLanguageMap(r);if(typeof e=="string"&&typeof i=="string")n.set(e,i);else if(typeof e=="object"){const s=this.toStringRecord(e);for(const[o,a]of Object.entries(s))n.set(o,a)}return this}setLanguageData(e,i){e=Ui(e).toLowerCase();const r=this.ensureLanguageMap(e),n=this.toStringRecord(i);for(const[s,o]of Object.entries(n))r.set(s,o);return this}setLanguage(e){return e=Ui(e).toLowerCase(),this.currentLanguage=e,this}getLanguage(){return this.currentLanguage}hasLanguage(e){e=Ui(e).toLowerCase();const i=this.languages.get(e);return i&&Object.keys(i).length>0}toStringRecord(e,i){const r={};for(const[n,s]of Object.entries(e)){const o=i?`${i}.${n}`:n;if(s&&typeof s=="object"&&!Array.isArray(s)){const a=this.toStringRecord(s,o);for(const[c,l]of Object.entries(a))r[c]=String(l)}else r[o]=String(s)}return r}has(e){const i=this.resolveLanguageOrder(this.currentLanguage);for(const r of i)if(this.languages.get(r)?.has(e))return!0;return!1}get(e){this.recordUsedKey(e);const i=this.resolveLanguageOrder(this.currentLanguage),r=[];for(const n of i){const o=this.languages.get(n)?.get(e);if(typeof o<"u")return r.length&&this.recordMissing(e,r),o;r.push(n)}r.length&&this.recordMissing(e,r)}translate(e,...i){if(!e)return"";if(this.currentLanguage==="qqx")return`⧼${e}⧽`;const r=this.get(e);return typeof r>"u"?this.interpolate(e,...i):this.interpolate(r,...i)}$(...e){if(Array.isArray(e[0])&&e[0]?.raw){const n=e[0],s=e.slice(1),o=li(n,s);return this.translate(o)}const r=e;return(n,...s)=>{const o=li(n,s);return this.translate(o,...r)}}translateRaw(e){return e?this.currentLanguage==="qqx"?`⧼${e}⧽`:this.get(e)??e:""}$raw(...e){if(Array.isArray(e[0])&&e[0]?.raw){const r=e[0],n=e.slice(1),s=li(r,n);return this.translateRaw(s)}return(r,...n)=>{const s=li(r,n);return this.translateRaw(s)}}message(e,...i){if(!e)return"";if(this.currentLanguage==="qqx")return`⧼${e}⧽`;const r=this.get(e);return typeof r>"u"?`(${e})`:this.interpolate(r,...i)}$$(...e){if(Array.isArray(e[0])&&e[0]?.raw){const n=e[0],s=e.slice(1),o=li(n,s);return this.message(o)}const r=e;return(n,...s)=>{const o=li(n,s);return this.message(o,...r)}}messageRaw(e){return e?this.currentLanguage==="qqx"?`⧼${e}⧽`:this.get(e)??`(${e})`:""}$$raw(...e){if(Array.isArray(e[0])&&e[0].raw){const r=e[0],n=e.slice(1),s=li(r,n);return this.messageRaw(s)}return(r,...n)=>{const s=li(r,n);return this.messageRaw(s)}}getAvailableLanguages(){return Array.from(this.languages.keys())}ensureLanguageMap(e){let i=this.languages.get(e);return i||(i=new Map,this.languages.set(e,i)),i}resolveLanguageOrder(e){const i=e;return i==="en"?["en"]:[i,"en"]}getMissingReport(){return Object.fromEntries(this.missingKeys.entries())}clearMissingReport(){this.missingKeys.clear()}recordMissing(e,i){if(!i.length)return;const r=this.missingKeys.get(e)||[];for(const n of i)r.includes(n)||r.push(n);this.missingKeys.set(e,r)}recordUsedKey(e){this.usedKeys.add(e)}getUsedKeys(){return Array.from(this.usedKeys)}generateBlankKeyRecord(){const e={};for(const i of this.getUsedKeys())e[i]="";return e}}var Og=Object.create,ao=Object.defineProperty,Lg=Object.getOwnPropertyDescriptor,Zl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ec=t=>{throw TypeError(t)},Ng=(t,e,i)=>e in t?ao(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Mg=(t,e)=>ao(t,"name",{value:e,configurable:!0}),Dg=t=>[,,,Og(t?.[Zl("metadata")]??null)],jg=["class","method","getter","setter","accessor","field","value","get","set"],tc=t=>t!==void 0&&typeof t!="function"?ec("Function expected"):t,Ug=(t,e,i,r,n)=>({kind:jg[t],name:e,metadata:r,addInitializer:s=>i._?ec("Already initialized"):n.push(tc(s||null))}),Fg=(t,e)=>Ng(e,Zl("metadata"),t[3]),qg=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Bg=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&Lg(n,i));Mg(n,i);for(var h=r.length-1;h>=0;h--)c=Ug(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,tc(o)&&(n=o);return Fg(t,n),p&&ao(n,i,p),u?l^4?s:p:n},ic,lo,rc;const nc=new R(R.object({manifest_version:R.const(1).required(),base_language:R.string().required(),last_modified:R.string().required(),languages:R.dict(R.object({file:R.string().required(),fallback:R.string(),iso_name:R.string(),endonym:R.string(),data:R.transform(R.dict(R.any()).default({}),t=>Object.keys(t).length>0?t:void 0)})).required()}));ic=[xe(["wiki","preferences"]),Tt(R.object({"i18n.index_url":R.string().description("I18n index URL (DO NOT CHANGE THIS) ").default(Lt.I18N_INDEX_URL)}).description("").extra("category","general"))];class vn extends(rc=ht){constructor(e){super(e,"i18n",!1),this.ctx=e,this.logger=void 0,this._indexUrl=void 0,this._indexCache=null,this.manager=void 0,this.i18nIndexDB=void 0,this.i18nDataDB=void 0,this.$=void 0,this.$raw=void 0,this.$$=void 0,this.$$raw=void 0,this.logger=this.ctx.logger("I18nService"),this.manager=new Tg({},{language:"",globals:{userName:this.ctx.wiki.userInfo.name||"",userId:this.ctx.wiki.userInfo.id||0,siteName:this.ctx.wiki.siteInfo.general.sitename||""}}),this.i18nIndexDB=e.storage.createDatabase("i18n-index",1e3*60*60*24*3,this.ctx.version,"indexedDB"),this.i18nDataDB=e.storage.createDatabase("i18n-data",1e3*60*60*24*3,this.ctx.version,"indexedDB"),this.$=this.manager.$.bind(this.manager),this.$raw=this.manager.$raw.bind(this.manager),this.$$=this.manager.$$.bind(this.manager),this.$$raw=this.manager.$$raw.bind(this.manager)}async start(){this.ctx.preferences.registerCustomConfig("language",R.object({language:R.union(["@user","@site",R.string().description("Custom language code")]).description("UI language").default("@user")}).description("UI language")),this.ctx.on("clear-cache",this.onClearCache.bind(this));const e=this._indexUrl=await this.ctx.preferences.get("i18n.index_url")||"";if(!e){this.logger.error("I18n index URL is not set"),this.setupShortcuts();return}let i=null;try{i=await this.getI18nIndex(e)}catch(s){this.logger.error("Failed to fetch i18n index",s),this.setupShortcuts();return}this._indexCache=i,Object.entries(i.languages).forEach(([s,o])=>{o.data&&Object.keys(o.data).length>0&&this.manager.setLanguageData(s,o.data)});const r=await this.ctx.preferences.get("language"),n=this.normalizeLanguageCode(r);this.logger.debug("Settings",{prefer:r,normalized:n});try{await this.switchLanguage(n),this.logger.info(`Initialized for language: ${this.language}`)}catch(s){this.logger.error("Failed to fetch i18n index",s),this.manager.setLanguage("en")}this.ctx.preferences.registerCustomConfig("language",R.object({language:R.union([R.const("@user").description(this.$`Same as your personal language`),R.const("@site").description(this.$`Same as the site language`),...this.getAvailableLanguageCodes().map(({code:s,endonym:o,iso_name:a})=>R.const(s).description(o||a||s))]).default("@user")}).description(this.$`InPageEdit UI language`)),this.setupShortcuts(),this.ctx.on("preferences/changed",async({changes:s})=>{if(!("language"in s))return;const o=this.normalizeLanguageCode(await this.ctx.preferences.get("language"));o&&o!==this.language&&await this.switchLanguage(o)})}setupShortcuts(){if(!this.manager)throw new Error("I18nManager is not initialized");this.ctx.set("$",this.manager.$.bind(this.manager)),this.ctx.set("$raw",this.manager.$raw.bind(this.manager)),this.ctx.set("$$",this.manager.$$.bind(this.manager)),this.ctx.set("$$raw",this.manager.$$raw.bind(this.manager))}normalizeLanguageCode(e){return!e||typeof e!="string"?"en":(e==="@user"&&(e=this.ctx.wiki.userInfo.options.language||"en"),e==="@site"&&(e=this.ctx.wiki.siteInfo.general.lang||"en"),Ui(String(e)).toLowerCase())}get language(){return this.manager.getLanguage()}async setLanguagePreference(e){await this.ctx.preferences.set("language",e)}async switchLanguage(e){const i=this.normalizeLanguageCode(e);await this.ensureLanguageLoaded(i),this.manager.setLanguage(i),this.ctx.emit("i18n/changed",{ctx:this.ctx,language:i})}async registerMessages(e,i,r){const n=r?.namespace?{[r.namespace]:i}:i;this.manager.setLanguageData(e,n),e===this.language&&this.ctx.emit("i18n/changed",{ctx:this.ctx,language:this.language})}getAvailableLanguageCodes(){if(!this._indexCache)throw new Error("I18n index is not loaded");return Object.entries(this._indexCache.languages).filter(([e,i])=>!i.fallback).reduce((e,[i,r])=>(e.push({code:i,...r}),e),[])}findLanguageMeta(e,i){const r=Ui(String(i)).toLowerCase(),n=e.languages[r];if(n)return{code:r,...n};{const s=e.languages.en;if(s)return{code:"en",...s}}}async getI18nIndex(e,i=!1){if(!i){const n=await this.i18nIndexDB.get(e);if(n)try{return nc(n)}catch(s){this.logger.error("Failed to parse cached i18n index",s),this.i18nIndexDB.delete(e)}}const r=await this.fetchI18nIndex(e);return this.i18nIndexDB.set(e,r),r}async fetchI18nIndex(e){const i=await fetch(e).then(r=>r.json());return nc(i)}async ensureLanguageLoaded(e){if(!this.manager||!this._indexCache)throw new Error("I18nManager is not initialized");if(this.manager.hasLanguage(e))return this.logger.debug("Language already loaded",e);const i=await this.getLanguageData(e);this.manager.setLanguageData(e,i),this.logger.debug("Language data ensured",e,i)}async getLanguageData(e,i=!1){if(!this._indexCache)throw new Error("I18n index is not loaded");const r=this.findLanguageMeta(this._indexCache,e);if(!r)return{};const n=`${this._indexUrl}#${r.file}`;if(!i){const o=await this.i18nDataDB.get(n);if(o&&Object.keys(o).length>0)return this.logger.debug("Using cached language data",e,o),o}const s=r.data||await fetch(new URL(r.file,this._indexUrl).toString()).then(o=>o.json());return this.i18nDataDB.set(n,s),this.logger.debug("Language data fetched",e,r.file,s),s}getMissingReport(){return this.manager.getMissingReport()}clearMissingReport(){this.manager.clearMissingReport()}async onClearCache(){await this.i18nIndexDB.clear(),await this.i18nDataDB.clear()}}lo=Dg(rc),vn=Bg(lo,0,"I18nService",ic,vn),qg(lo,1,vn);const Hg=new TextEncoder;function zg(t){if(typeof t=="string")return Hg.encode(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new TypeError("Unsupported input type")}function Wg(t){let e="";for(let i=0;i<t.length;i++){const r=t[i].toString(16).padStart(2,"0");e+=r}return e}function Kg(t,e){return t<<e|t>>>32-e}const Vg=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],Gg=new Array(64).fill(0).map((t,e)=>Math.floor(Math.abs(Math.sin(e+1))*2**32)>>>0);function Qg(t){const e=zg(t),i=(56-(e.length+1)%64+64)%64,r=e.length+1+i+8,n=new Uint8Array(r);n.set(e,0),n[e.length]=128;const s=e.length,o=s<<3>>>0,a=s>>>29>>>0,c=new DataView(n.buffer);c.setUint32(r-8,o,!0),c.setUint32(r-4,a,!0);let l=1732584193,u=4023233417,d=2562383102,y=271733878;const p=new Uint32Array(16);for(let k=0;k<n.length;k+=64){for(let w=0;w<16;w++)p[w]=c.getUint32(k+w*4,!0);let P=l,b=u,m=d,g=y;for(let w=0;w<64;w++){let S,I;w<16?(S=b&m|~b&g,I=w):w<32?(S=g&b|~g&m,I=(5*w+1)%16):w<48?(S=b^m^g,I=(3*w+5)%16):(S=m^(b|~g),I=7*w%16);const F=g,N=P+S+Gg[w]+p[I]>>>0;g=m,m=b,b=b+Kg(N,Vg[w])>>>0,P=F}l=l+P>>>0,u=u+b>>>0,d=d+m>>>0,y=y+g>>>0}const h=new Uint8Array(16),_=new DataView(h.buffer);return _.setUint32(0,l,!0),_.setUint32(4,u,!0),_.setUint32(8,d,!0),_.setUint32(12,y,!0),h}var Yg=Object.create,co=Object.defineProperty,Xg=Object.getOwnPropertyDescriptor,sc=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),oc=t=>{throw TypeError(t)},Jg=(t,e,i)=>e in t?co(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Zg=(t,e)=>co(t,"name",{value:e,configurable:!0}),em=t=>[,,,Yg(t?.[sc("metadata")]??null)],tm=["class","method","getter","setter","accessor","field","value","get","set"],ac=t=>t!==void 0&&typeof t!="function"?oc("Function expected"):t,im=(t,e,i,r,n)=>({kind:tm[t],name:e,metadata:r,addInitializer:s=>i._?oc("Already initialized"):n.push(ac(s||null))}),rm=(t,e)=>Jg(e,sc("metadata"),t[3]),nm=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},sm=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&Xg(n,i));Zg(n,i);for(var h=r.length-1;h>=0;h--)c=im(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,ac(o)&&(n=o);return rm(t,n),p&&co(n,i,p),u?l^4?s:p:n},lc,uo,cc;lc=[xe(["wiki","wikiTitle","wikiPage","apiService"])];class wn extends(cc=ht){constructor(e){super(e,"wikiFile",!0),this.ctx=e}get fileRepos(){return this.ctx.wiki.fileRepos||[]}get defaultFileRepo(){return this.fileRepos[0]}get localFileRepo(){return this.fileRepos.find(e=>e.local)}get writableFileRepo(){return this.fileRepos.find(e=>e.canUpload)}getFileName(e){if(e=this.ctx.wikiTitle.newTitle(e,6),![6,-2].includes(e.getNamespaceId()))throw new Error("Not a file title");return e.getMainDBKey().split("/").pop()||""}getHashPath(e,i=2){const r=this.getFileName(e),n=Wg(Qg(r));let s=[];for(let o=1;o<=i;o++)s.push(n.slice(0,o));return s.push(r),s.join("/")}getFileUrl(e,i){if(i=i||this.defaultFileRepo,!i)throw new Error("No file repository found");const r=this.getHashPath(e);return new URL(`${i.rootUrl}/${r}`,location.origin).toString()}async upload(e,i){if(i=i||this.writableFileRepo,!i?.canUpload)throw new Error("No writable file repository found");if(!e.file&&!e.url&&!e.chunk&&!e.filekey)throw new Error('At least one of "file", "url", "chunk", or "filekey" is required');return this.ctx.apiService.getClientByFileRepo(i).postWithToken("csrf",{action:"upload",...e},{fexiosOptions:{timeout:0}})}}uo=em(cc),wn=sm(uo,0,"WikiFileService",lc,wn),nm(uo,1,wn);const Gr=class Gr extends Ze{constructor(i){super({name:"InPageEdit"});Ni(this,vt);this.version="0.16.1",this.Endpoints=Lt,this.schema=R,this.config=Rt(Gr.DEFAULT_CONFIG,i),this.logger=nl({name:"IPE",color:"#33aaff",level:this.config.logLevel}),wt(this,vt,Wf).call(this)}async withInject(i){const{promise:r,resolve:n}=wr();return this.inject(i,s=>{n(s)}),r}};vt=new WeakSet,Wf=async function(){await wt(this,vt,Kf).call(this),this.config.autoInstallCorePlugins&&wt(this,vt,Gf).call(this),wt(this,vt,Qf).call(this)},Kf=async function(){this.plugin(vn),this.plugin(Th,this.config.apiConfigs),this.plugin(zh),this.plugin(Wh),this.plugin(Mp),this.plugin(bn),this.plugin(Zp,{dbName:this.config.storageNamespace}),this.plugin(yn),this.plugin(wn),this.plugin(mn),this.plugin(ro),this.plugin(no),wt(this,vt,Vf).call(this,["i18n","$","$$","api","currentPage","resourceLoader","modal","preferences","storage","theme","wikiPage","wikiTitle","wiki","getUrl","getSciprtUrl","getMainpageUrl"])},Vf=function(i){if(!Array.isArray(i)||i.length===0)return this;for(const r of i){const n=this[Gr.internal][r];n?.type==="service"&&(n.builtin=!0)}return this},Gf=async function(){[Promise.resolve().then(()=>bm).then(({PluginAnalytics:r})=>r),Promise.resolve().then(()=>Im).then(({PluginInArticleLinks:r})=>r),Promise.resolve().then(()=>dv).then(({PluginPluginStore:r})=>r),Promise.resolve().then(()=>jv).then(({PluginPreferencesUI:r})=>r),Promise.resolve().then(()=>Zv).then(({PluginQuickEdit:r})=>r),Promise.resolve().then(()=>uw).then(({PluginQuickMove:r})=>r),Promise.resolve().then(()=>xw).then(({PluginQuickPreview:r})=>r),Promise.resolve().then(()=>jw).then(({PluginQuickDiff:r})=>r),Promise.resolve().then(()=>Uw).then(({PluginQuickRedirect:r})=>r),Promise.resolve().then(()=>Jw).then(({PluginQuickUpload:r})=>r),Promise.resolve().then(()=>e_).then(({PluginQuickUsage:r})=>r),Promise.resolve().then(()=>d_).then(({PluginToolbox:r})=>r)].forEach(async r=>{this.plugin(await r)})},Qf=async function(){this.inject(["resourceLoader"],i=>{})},Gr.DEFAULT_CONFIG={apiConfigs:{},legacyPreferences:{},logLevel:As.info,storageNamespace:"InPageEdit",autoloadStyles:!0,autoInstallCorePlugins:!0};let Fi=Gr;const ms=class ms{constructor(e,i=void 0,r){Ni(this,Qr);this.ctx=e,this.disposeHandlers=[],this.name=r||"",this.config=i||{};const{promise:n,resolve:s,reject:o}=wr();queueMicrotask(()=>{this.name||(this.name=this.constructor.name);try{const a=this.start();a&&typeof a.then=="function"?a.then(()=>s()).catch(c=>{this.logger.error("start() returns a rejected promise",c),o(c)}):s()}catch(a){this.logger.error("start() threw synchronously",a),o(a)}n.then(()=>{this.logger.debug("started")}),n.catch(a=>{this.logger.error("start failed",a),this.ctx.scope.dispose()})}),this.ctx.once("dispose",()=>{this.disposeHandlers.forEach(a=>a(this.ctx)),this.stop(),this.logger.debug("disposed")})}start(){}stop(){}addDisposeHandler(e){this.disposeHandlers.push(e)}removeDisposeHandler(e){this.disposeHandlers=this.disposeHandlers.filter(i=>i!==e)}set name(e){je(this,Qr,Ag(e).toUpperCase())}get name(){return ce(this,Qr)}get logger(){return this.ctx.logger(this.name)}};Qr=new WeakMap,ms.inject=[],ms.reusable=!1;let Ue=ms;window.RLQ||(window.RLQ=[]),window.__IPE_MODULES__||(window.__IPE_MODULES__=[]),am("InPageEdit#autoload",()=>{const t=uc();t&&om({baseURL:t,InPageEdit:Fi})});async function om(t={baseURL:uc(),InPageEdit:Fi}){const{baseURL:e,InPageEdit:i}=t;typeof window?.ipe?.stop=="function"&&await window.ipe.stop();const r=window.InPageEdit||{},n=new i({apiConfigs:{baseURL:e},legacyPreferences:r?.myPreferences||{}});if(window.ipe=n,await n.start(),window.RLQ.push(()=>{mw.hook("InPageEdit.ready").fire(n)}),Array.isArray(window.__IPE_MODULES__)){const s=[];for(;window.__IPE_MODULES__.length;)try{const o=window.__IPE_MODULES__.shift();typeof o=="function"&&o?.(n),s.push(o)}catch{}window.__IPE_MODULES__={push:o=>{typeof o=="function"&&o(n),s.push(o)}},n.on("dispose",()=>{window.__IPE_MODULES__=s})}n.logger("AUTOLOAD").info(`
12
+ `);return(i,r)=>{const n=new Proxy(r,{has:(s,o)=>typeof o=="symbol"?o in s:!(typeof o=="string"&&(t.has(o)||o==="__expr__")),get:(s,o)=>{if(o in s)return s[o]}});return e(i,n)}}function ec(t){return t.charAt(0).toLowerCase()+t.slice(1)}function Ui(t){return ec(t).replace(/_/g,"-").replace(/.[A-Z]+/g,e=>e[0]+"-"+e.slice(1).toLowerCase())}function Ng(t){return ec(t).replace(/-/g,"_").replace(/.[A-Z]+/g,e=>e[0]+"_"+e.slice(1).toLowerCase())}function li(t,e){let i=t[0]??"";for(let r=0;r<e.length;r++)i+=String(e[r])+(t[r+1]??"");return i}class Mg{constructor(e,i){this.languages=new Map,this.currentLanguage="en",this.missingKeys=new Map,this.usedKeys=new Set;const r=i?.language||"en";this.currentLanguage=r,this.interpolate=Zl(i?.globals),e&&Object.keys(e).length&&this.setLanguageData(r,e)}setGlobals(e){return this.interpolate=Zl(e),this}set(e,i){const r=this.currentLanguage,n=this.ensureLanguageMap(r);if(typeof e=="string"&&typeof i=="string")n.set(e,i);else if(typeof e=="object"){const s=this.toStringRecord(e);for(const[o,a]of Object.entries(s))n.set(o,a)}return this}setLanguageData(e,i){e=Ui(e).toLowerCase();const r=this.ensureLanguageMap(e),n=this.toStringRecord(i);for(const[s,o]of Object.entries(n))r.set(s,o);return this}setLanguage(e){return e=Ui(e).toLowerCase(),this.currentLanguage=e,this}getLanguage(){return this.currentLanguage}hasLanguage(e){e=Ui(e).toLowerCase();const i=this.languages.get(e);return i&&Object.keys(i).length>0}toStringRecord(e,i){const r={};for(const[n,s]of Object.entries(e)){const o=i?`${i}.${n}`:n;if(s&&typeof s=="object"&&!Array.isArray(s)){const a=this.toStringRecord(s,o);for(const[c,l]of Object.entries(a))r[c]=String(l)}else r[o]=String(s)}return r}has(e){const i=this.resolveLanguageOrder(this.currentLanguage);for(const r of i)if(this.languages.get(r)?.has(e))return!0;return!1}get(e){this.recordUsedKey(e);const i=this.resolveLanguageOrder(this.currentLanguage),r=[];for(const n of i){const o=this.languages.get(n)?.get(e);if(typeof o<"u")return r.length&&this.recordMissing(e,r),o;r.push(n)}r.length&&this.recordMissing(e,r)}translate(e,...i){if(!e)return"";if(this.currentLanguage==="qqx")return`⧼${e}⧽`;const r=this.get(e);return typeof r>"u"?this.interpolate(e,...i):this.interpolate(r,...i)}$(...e){if(Array.isArray(e[0])&&e[0]?.raw){const n=e[0],s=e.slice(1),o=li(n,s);return this.translate(o)}const r=e;return(n,...s)=>{const o=li(n,s);return this.translate(o,...r)}}translateRaw(e){return e?this.currentLanguage==="qqx"?`⧼${e}⧽`:this.get(e)??e:""}$raw(...e){if(Array.isArray(e[0])&&e[0]?.raw){const r=e[0],n=e.slice(1),s=li(r,n);return this.translateRaw(s)}return(r,...n)=>{const s=li(r,n);return this.translateRaw(s)}}message(e,...i){if(!e)return"";if(this.currentLanguage==="qqx")return`⧼${e}⧽`;const r=this.get(e);return typeof r>"u"?`(${e})`:this.interpolate(r,...i)}$$(...e){if(Array.isArray(e[0])&&e[0]?.raw){const n=e[0],s=e.slice(1),o=li(n,s);return this.message(o)}const r=e;return(n,...s)=>{const o=li(n,s);return this.message(o,...r)}}messageRaw(e){return e?this.currentLanguage==="qqx"?`⧼${e}⧽`:this.get(e)??`(${e})`:""}$$raw(...e){if(Array.isArray(e[0])&&e[0].raw){const r=e[0],n=e.slice(1),s=li(r,n);return this.messageRaw(s)}return(r,...n)=>{const s=li(r,n);return this.messageRaw(s)}}getAvailableLanguages(){return Array.from(this.languages.keys())}ensureLanguageMap(e){let i=this.languages.get(e);return i||(i=new Map,this.languages.set(e,i)),i}resolveLanguageOrder(e){const i=e;return i==="en"?["en"]:[i,"en"]}getMissingReport(){return Object.fromEntries(this.missingKeys.entries())}clearMissingReport(){this.missingKeys.clear()}recordMissing(e,i){if(!i.length)return;const r=this.missingKeys.get(e)||[];for(const n of i)r.includes(n)||r.push(n);this.missingKeys.set(e,r)}recordUsedKey(e){this.usedKeys.add(e)}getUsedKeys(){return Array.from(this.usedKeys)}generateBlankKeyRecord(){const e={};for(const i of this.getUsedKeys())e[i]="";return e}}var Dg=Object.create,lo=Object.defineProperty,jg=Object.getOwnPropertyDescriptor,tc=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ic=t=>{throw TypeError(t)},Ug=(t,e,i)=>e in t?lo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Fg=(t,e)=>lo(t,"name",{value:e,configurable:!0}),qg=t=>[,,,Dg(t?.[tc("metadata")]??null)],Bg=["class","method","getter","setter","accessor","field","value","get","set"],rc=t=>t!==void 0&&typeof t!="function"?ic("Function expected"):t,Hg=(t,e,i,r,n)=>({kind:Bg[t],name:e,metadata:r,addInitializer:s=>i._?ic("Already initialized"):n.push(rc(s||null))}),zg=(t,e)=>Ug(e,tc("metadata"),t[3]),Wg=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Kg=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&jg(n,i));Fg(n,i);for(var h=r.length-1;h>=0;h--)c=Hg(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,rc(o)&&(n=o);return zg(t,n),p&&lo(n,i,p),u?l^4?s:p:n},nc,co,sc;const oc=new A(A.object({manifest_version:A.const(1).required(),base_language:A.string().required(),last_modified:A.string().required(),languages:A.dict(A.object({file:A.string().required(),fallback:A.string(),iso_name:A.string(),endonym:A.string(),data:A.transform(A.dict(A.any()).default({}),t=>Object.keys(t).length>0?t:void 0)})).required()}));nc=[xe(["wiki","preferences"]),Tt(A.object({"i18n.index_url":A.string().description("I18n index URL (DO NOT CHANGE THIS) ").default(Lt.I18N_INDEX_URL)}).description("").extra("category","general"))];class vn extends(sc=ht){constructor(e){super(e,"i18n",!1),this.ctx=e,this.logger=void 0,this._indexUrl=void 0,this._indexCache=null,this.manager=void 0,this.i18nIndexDB=void 0,this.i18nDataDB=void 0,this.$=void 0,this.$raw=void 0,this.$$=void 0,this.$$raw=void 0,this.logger=this.ctx.logger("I18nService"),this.manager=new Mg({},{language:"",globals:{userName:this.ctx.wiki.userInfo.name||"",userId:this.ctx.wiki.userInfo.id||0,siteName:this.ctx.wiki.siteInfo.general.sitename||""}}),this.i18nIndexDB=e.storage.createDatabase("i18n-index",1e3*60*60*24*3,this.ctx.version,"indexedDB"),this.i18nDataDB=e.storage.createDatabase("i18n-data",1e3*60*60*24*3,this.ctx.version,"indexedDB"),this.$=this.manager.$.bind(this.manager),this.$raw=this.manager.$raw.bind(this.manager),this.$$=this.manager.$$.bind(this.manager),this.$$raw=this.manager.$$raw.bind(this.manager)}async start(){this.ctx.preferences.registerCustomConfig("language",A.object({language:A.union(["@user","@site",A.string().description("Custom language code")]).description("UI language").default("@user")}).description("UI language")),this.ctx.on("clear-cache",this.onClearCache.bind(this));const e=this._indexUrl=await this.ctx.preferences.get("i18n.index_url")||"";if(!e){this.logger.error("I18n index URL is not set"),this.setupShortcuts();return}let i=null;try{i=await this.getI18nIndex(e)}catch(s){this.logger.error("Failed to fetch i18n index",s),this.setupShortcuts();return}this._indexCache=i,Object.entries(i.languages).forEach(([s,o])=>{o.data&&Object.keys(o.data).length>0&&this.manager.setLanguageData(s,o.data)});const r=await this.ctx.preferences.get("language"),n=this.normalizeLanguageCode(r);this.logger.debug("Settings",{prefer:r,normalized:n});try{await this.switchLanguage(n),this.logger.info(`Initialized for language: ${this.language}`)}catch(s){this.logger.error("Failed to fetch i18n index",s),this.manager.setLanguage("en")}this.ctx.preferences.registerCustomConfig("language",A.object({language:A.union([A.const("@user").description(this.$`Same as your personal language`),A.const("@site").description(this.$`Same as the site language`),...this.getAvailableLanguageCodes().map(({code:s,endonym:o,iso_name:a})=>A.const(s).description(o||a||s))]).default("@user")}).description(this.$`InPageEdit UI language`)),this.setupShortcuts(),this.ctx.on("preferences/changed",async({changes:s})=>{if(!("language"in s))return;const o=this.normalizeLanguageCode(await this.ctx.preferences.get("language"));o&&o!==this.language&&await this.switchLanguage(o)})}setupShortcuts(){if(!this.manager)throw new Error("I18nManager is not initialized");this.ctx.set("$",this.manager.$.bind(this.manager)),this.ctx.set("$raw",this.manager.$raw.bind(this.manager)),this.ctx.set("$$",this.manager.$$.bind(this.manager)),this.ctx.set("$$raw",this.manager.$$raw.bind(this.manager))}normalizeLanguageCode(e){return!e||typeof e!="string"?"en":(e==="@user"&&(e=this.ctx.wiki.userInfo.options.language||"en"),e==="@site"&&(e=this.ctx.wiki.siteInfo.general.lang||"en"),Ui(String(e)).toLowerCase())}get language(){return this.manager.getLanguage()}async setLanguagePreference(e){await this.ctx.preferences.set("language",e)}async switchLanguage(e){const i=this.normalizeLanguageCode(e);await this.ensureLanguageLoaded(i),this.manager.setLanguage(i),this.ctx.emit("i18n/changed",{ctx:this.ctx,language:i})}async registerMessages(e,i,r){const n=r?.namespace?{[r.namespace]:i}:i;this.manager.setLanguageData(e,n),e===this.language&&this.ctx.emit("i18n/changed",{ctx:this.ctx,language:this.language})}getAvailableLanguageCodes(){if(!this._indexCache)throw new Error("I18n index is not loaded");return Object.entries(this._indexCache.languages).filter(([e,i])=>!i.fallback).reduce((e,[i,r])=>(e.push({code:i,...r}),e),[])}findLanguageMeta(e,i){const r=Ui(String(i)).toLowerCase(),n=e.languages[r];if(n)return{code:r,...n};{const s=e.languages.en;if(s)return{code:"en",...s}}}async getI18nIndex(e,i=!1){if(!i){const n=await this.i18nIndexDB.get(e);if(n)try{return oc(n)}catch(s){this.logger.error("Failed to parse cached i18n index",s),this.i18nIndexDB.delete(e)}}const r=await this.fetchI18nIndex(e);return this.i18nIndexDB.set(e,r),r}async fetchI18nIndex(e){const i=await fetch(e).then(r=>r.json());return oc(i)}async ensureLanguageLoaded(e){if(!this.manager||!this._indexCache)throw new Error("I18nManager is not initialized");if(this.manager.hasLanguage(e))return this.logger.debug("Language already loaded",e);const i=await this.getLanguageData(e);this.manager.setLanguageData(e,i),this.logger.debug("Language data ensured",e,i)}async getLanguageData(e,i=!1){if(!this._indexCache)throw new Error("I18n index is not loaded");const r=this.findLanguageMeta(this._indexCache,e);if(!r)return{};const n=`${this._indexUrl}#${r.file}`;if(!i){const o=await this.i18nDataDB.get(n);if(o&&Object.keys(o).length>0)return this.logger.debug("Using cached language data",e,o),o}const s=r.data||await fetch(new URL(r.file,this._indexUrl).toString()).then(o=>o.json());return this.i18nDataDB.set(n,s),this.logger.debug("Language data fetched",e,r.file,s),s}getMissingReport(){return this.manager.getMissingReport()}clearMissingReport(){this.manager.clearMissingReport()}async onClearCache(){await this.i18nIndexDB.clear(),await this.i18nDataDB.clear()}}co=qg(sc),vn=Kg(co,0,"I18nService",nc,vn),Wg(co,1,vn);const Vg=new TextEncoder;function Gg(t){if(typeof t=="string")return Vg.encode(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new TypeError("Unsupported input type")}function Qg(t){let e="";for(let i=0;i<t.length;i++){const r=t[i].toString(16).padStart(2,"0");e+=r}return e}function Yg(t,e){return t<<e|t>>>32-e}const Xg=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],Jg=new Array(64).fill(0).map((t,e)=>Math.floor(Math.abs(Math.sin(e+1))*2**32)>>>0);function Zg(t){const e=Gg(t),i=(56-(e.length+1)%64+64)%64,r=e.length+1+i+8,n=new Uint8Array(r);n.set(e,0),n[e.length]=128;const s=e.length,o=s<<3>>>0,a=s>>>29>>>0,c=new DataView(n.buffer);c.setUint32(r-8,o,!0),c.setUint32(r-4,a,!0);let l=1732584193,u=4023233417,d=2562383102,y=271733878;const p=new Uint32Array(16);for(let k=0;k<n.length;k+=64){for(let w=0;w<16;w++)p[w]=c.getUint32(k+w*4,!0);let P=l,b=u,m=d,g=y;for(let w=0;w<64;w++){let S,I;w<16?(S=b&m|~b&g,I=w):w<32?(S=g&b|~g&m,I=(5*w+1)%16):w<48?(S=b^m^g,I=(3*w+5)%16):(S=m^(b|~g),I=7*w%16);const F=g,N=P+S+Jg[w]+p[I]>>>0;g=m,m=b,b=b+Yg(N,Xg[w])>>>0,P=F}l=l+P>>>0,u=u+b>>>0,d=d+m>>>0,y=y+g>>>0}const h=new Uint8Array(16),_=new DataView(h.buffer);return _.setUint32(0,l,!0),_.setUint32(4,u,!0),_.setUint32(8,d,!0),_.setUint32(12,y,!0),h}var em=Object.create,uo=Object.defineProperty,tm=Object.getOwnPropertyDescriptor,ac=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),lc=t=>{throw TypeError(t)},im=(t,e,i)=>e in t?uo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,rm=(t,e)=>uo(t,"name",{value:e,configurable:!0}),nm=t=>[,,,em(t?.[ac("metadata")]??null)],sm=["class","method","getter","setter","accessor","field","value","get","set"],cc=t=>t!==void 0&&typeof t!="function"?lc("Function expected"):t,om=(t,e,i,r,n)=>({kind:sm[t],name:e,metadata:r,addInitializer:s=>i._?lc("Already initialized"):n.push(cc(s||null))}),am=(t,e)=>im(e,ac("metadata"),t[3]),lm=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},cm=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&tm(n,i));rm(n,i);for(var h=r.length-1;h>=0;h--)c=om(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,cc(o)&&(n=o);return am(t,n),p&&uo(n,i,p),u?l^4?s:p:n},uc,fo,dc;uc=[xe(["wiki","wikiTitle","wikiPage","apiService"])];class wn extends(dc=ht){constructor(e){super(e,"wikiFile",!0),this.ctx=e}get fileRepos(){return this.ctx.wiki.fileRepos||[]}get defaultFileRepo(){return this.localFileRepo||this.fileRepos[0]}get localFileRepo(){return this.fileRepos.find(e=>e.local)}get writableFileRepo(){return this.fileRepos.find(e=>e.canUpload)}getFileName(e){if(e=this.ctx.wikiTitle.newTitle(e,6),![6,-2].includes(e.getNamespaceId()))throw new Error("Not a file title");return e.getMainDBKey().split("/").pop()||""}getHashPath(e,i=2){const r=this.getFileName(e),n=Qg(Zg(r));let s=[];for(let o=1;o<=i;o++)s.push(n.slice(0,o));return s.push(r),s.join("/")}getFileUrl(e,i){if(i=i||this.defaultFileRepo,!i)throw new Error("No file repository found");const r=this.getHashPath(e);return new URL(`${i.rootUrl}/${r}`,location.origin).toString()}async upload(e,i){if(i=i||this.writableFileRepo,!i?.canUpload)throw new Error("No writable file repository found");if(!e.file&&!e.url&&!e.chunk&&!e.filekey)throw new Error('At least one of "file", "url", "chunk", or "filekey" is required');return this.ctx.apiService.getClientByFileRepo(i).postWithToken("csrf",{action:"upload",...e},{fexiosOptions:{timeout:0}})}}fo=nm(dc),wn=cm(fo,0,"WikiFileService",uc,wn),lm(fo,1,wn);const Gr=class Gr extends Ze{constructor(i){super({name:"InPageEdit"});Ni(this,vt);this.version="0.17.0",this.Endpoints=Lt,this.schema=A,this.config=At(Gr.DEFAULT_CONFIG,i),this.logger=sl({name:"IPE",color:"#33aaff",level:this.config.logLevel}),wt(this,vt,Vf).call(this)}async withInject(i){const{promise:r,resolve:n}=wr();return this.inject(i,s=>{n(s)}),r}};vt=new WeakSet,Vf=async function(){await wt(this,vt,Gf).call(this),this.config.autoInstallCorePlugins&&wt(this,vt,Yf).call(this),wt(this,vt,Xf).call(this)},Gf=async function(){this.plugin(vn),this.plugin(Lh,this.config.apiConfigs),this.plugin(Kh),this.plugin(Vh),this.plugin(jp),this.plugin(bn),this.plugin(tg,{dbName:this.config.storageNamespace}),this.plugin(yn),this.plugin(wn),this.plugin(mn),this.plugin(no),this.plugin(so),wt(this,vt,Qf).call(this,["i18n","$","$$","api","currentPage","resourceLoader","modal","preferences","storage","theme","wikiPage","wikiTitle","wiki","getUrl","getSciprtUrl","getMainpageUrl"])},Qf=function(i){if(!Array.isArray(i)||i.length===0)return this;for(const r of i){const n=this[Gr.internal][r];n?.type==="service"&&(n.builtin=!0)}return this},Yf=async function(){[Promise.resolve().then(()=>xm).then(({PluginAnalytics:r})=>r),Promise.resolve().then(()=>Om).then(({PluginInArticleLinks:r})=>r),Promise.resolve().then(()=>gv).then(({PluginPluginStore:r})=>r),Promise.resolve().then(()=>Bv).then(({PluginPreferencesUI:r})=>r),Promise.resolve().then(()=>rw).then(({PluginQuickEdit:r})=>r),Promise.resolve().then(()=>pw).then(({PluginQuickMove:r})=>r),Promise.resolve().then(()=>$w).then(({PluginQuickPreview:r})=>r),Promise.resolve().then(()=>Bw).then(({PluginQuickDiff:r})=>r),Promise.resolve().then(()=>Hw).then(({PluginQuickRedirect:r})=>r),Promise.resolve().then(()=>i_).then(({PluginQuickUpload:r})=>r),Promise.resolve().then(()=>n_).then(({PluginQuickUsage:r})=>r),Promise.resolve().then(()=>g_).then(({PluginToolbox:r})=>r)].forEach(async r=>{this.plugin(await r)})},Xf=async function(){this.inject(["resourceLoader"],i=>{})},Gr.DEFAULT_CONFIG={apiConfigs:{},legacyPreferences:{},logLevel:Rs.info,storageNamespace:"InPageEdit",autoloadStyles:!0,autoInstallCorePlugins:!0};let Fi=Gr;const ms=class ms{constructor(e,i=void 0,r){Ni(this,Qr);this.ctx=e,this.disposeHandlers=[],this.name=r||"",this.config=i||{};const{promise:n,resolve:s,reject:o}=wr();queueMicrotask(()=>{this.name||(this.name=this.constructor.name);try{const a=this.start();a&&typeof a.then=="function"?a.then(()=>s()).catch(c=>{this.logger.error("start() returns a rejected promise",c),o(c)}):s()}catch(a){this.logger.error("start() threw synchronously",a),o(a)}n.then(()=>{this.logger.debug("started")}),n.catch(a=>{this.logger.error("start failed",a),this.ctx.scope.dispose()})}),this.ctx.once("dispose",()=>{this.disposeHandlers.forEach(a=>a(this.ctx)),this.stop(),this.logger.debug("disposed")})}start(){}stop(){}addDisposeHandler(e){this.disposeHandlers.push(e)}removeDisposeHandler(e){this.disposeHandlers=this.disposeHandlers.filter(i=>i!==e)}set name(e){je(this,Qr,Ng(e).toUpperCase())}get name(){return ce(this,Qr)}get logger(){return this.ctx.logger(this.name)}};Qr=new WeakMap,ms.inject=[],ms.reusable=!1;let Ue=ms;window.RLQ||(window.RLQ=[]),window.__IPE_MODULES__||(window.__IPE_MODULES__=[]),dm("InPageEdit#autoload",()=>{const t=fc();t&&um({baseURL:t,InPageEdit:Fi})});async function um(t={baseURL:fc(),InPageEdit:Fi}){const{baseURL:e,InPageEdit:i}=t;typeof window?.ipe?.stop=="function"&&await window.ipe.stop();const r=window.InPageEdit||{},n=new i({apiConfigs:{baseURL:e},legacyPreferences:r?.myPreferences||{}});if(window.ipe=n,await n.start(),window.RLQ.push(()=>{mw.hook("InPageEdit.ready").fire(n)}),Array.isArray(window.__IPE_MODULES__)){const s=[];for(;window.__IPE_MODULES__.length;)try{const o=window.__IPE_MODULES__.shift();typeof o=="function"&&o?.(n),s.push(o)}catch{}window.__IPE_MODULES__={push:o=>{typeof o=="function"&&o(n),s.push(o)}},n.on("dispose",()=>{window.__IPE_MODULES__=s})}n.logger("AUTOLOAD").info(`
13
13
  ____ ____ ______ ___ __
14
14
  / _/___ / __ \\____ _____ ____ / ____/___/ (_) /_
15
15
  / // __ \\/ /_/ / __ \`/ __ \`/ _ \\/ __/ / __ / / __/
@@ -18,19 +18,19 @@
18
18
  /____/ v`+n.version+`
19
19
  - Wiki API Endpoint: ${e}
20
20
  - Documentation: ${Lt.HOME_URL}
21
- - Bug Reports: ${Lt.GITHUB_URL}`)}function uc(){const t=document.querySelector('meta[name="generator"][content^="MediaWiki"]')!==null,e=document.querySelector('link[rel="EditURI"]')?.href?.split("?")[0];return t&&e?e:void 0}function am(t,e){const i=Symbol.for(t);return window[i]?!1:(window[i]=!0,e(),!0)}var lm=Object.create,fo=Object.defineProperty,cm=Object.getOwnPropertyDescriptor,dc=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),fc=t=>{throw TypeError(t)},um=(t,e,i)=>e in t?fo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,dm=(t,e)=>fo(t,"name",{value:e,configurable:!0}),fm=t=>[,,,lm(t?.[dc("metadata")]??null)],hm=["class","method","getter","setter","accessor","field","value","get","set"],hc=t=>t!==void 0&&typeof t!="function"?fc("Function expected"):t,pm=(t,e,i,r,n)=>({kind:hm[t],name:e,metadata:r,addInitializer:s=>i._?fc("Already initialized"):n.push(hc(s||null))}),gm=(t,e)=>um(e,dc("metadata"),t[3]),mm=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},ym=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&cm(n,i));dm(n,i);for(var h=r.length-1;h>=0;h--)c=pm(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,hc(o)&&(n=o);return gm(t,n),p&&fo(n,i,p),u?l^4?s:p:n},pc,ho,gc;pc=[xe(["wiki","preferences","$"])];class _n extends(gc=Ue){constructor(e){super(e,{},"analytics"),this.ctx=e,this._usages=[],this._timer=null,this.MAX_QUEUE_SIZE=50,this.INTERVAL_MS=60*1e3,this._setupTimer(),this._registerUnloadHandler(),this._showConfirmNotify(),this._initPluginListeners(),e.set("analytics",this)}start(){const e=this.ctx,i=e.$;e.preferences.registerCustomConfig("analytics",R.object({"analytics._intro":R.const(f("section",{children:[f("h3",{children:i`InPageEdit Analytics`}),f("p",{children:i`InPageEdit Analytics is the companion analytics platform for the InPageEdit NEXT project. By collecting and displaying usage data from around the world, it helps developers and the community better understand how the tool is used, optimize feature design, and enhance user experience.`}),f("h4",{children:i`What data will be collected?`}),f("ol",{style:{listStyle:"number",paddingLeft:"1em"},children:[f("li",{children:[f("strong",{children:i`Usage data`}),":"," ",i`When and which features you use, what pages you edit, etc.`]}),f("li",{children:[f("strong",{children:i`User information`}),": ",i`Your user name and user ID.`]}),f("li",{children:[f("strong",{children:i`Site information`}),": ",i`This wiki's url and site name.`]})]}),f("p",{children:f("strong",{children:i`NO sensitive data will be collected.`})}),f("div",{style:{display:"grid",gap:"0.5rem"},children:[f("a",{href:this.analyticsDashUrl,target:"_blank",rel:"noopener noreferrer",children:f("button",{className:"btn",style:{width:"100%"},children:i`Analytics Platform`})}),f("a",{href:`${this.analyticsDashUrl}/_redirect/user?${new URLSearchParams({siteApi:this.ctx.wiki.getSciprtUrl("api"),mwUserId:this.ctx.wiki.userInfo.id.toString()}).toString()}`,target:"_blank",rel:"noopener noreferrer",children:f("button",{className:"btn",style:{width:"100%"},children:i`View My Data`})})]})]})).role("raw-html"),"analytics.enabled":R.boolean().description(i`prefs.analytics.enabled`).default(!1)}).description(i`prefs.analytics.$`),"general")}get analyticsDashUrl(){return Lt.ANALYTICS_DASH_URL}get analyticsApiBase(){return Lt.ANALYTICS_API_BASE}_setupTimer(){this._timer=setInterval(()=>{this._usages.length>0&&this.sendBeacon()},this.INTERVAL_MS)}_registerUnloadHandler(){const e=()=>{this._usages.length>0&&this.sendBeacon()};window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&e()}),window.addEventListener("pagehide",e),window.addEventListener("beforeunload",e)}async _showConfirmNotify(){const{$:e}=this.ctx;this.ctx.inject(["modal","storage"],async i=>{const r="analytics/confirm-shown",n=await i.storage.simpleKV.get(r),s=await i.preferences.get("analytics.enabled");n||s||i.modal.notify("confirm",{title:e`Enable Analytics`,content:f("div",{children:[f("p",{children:e`Help us improve InPageEdit by sharing your usage data with us.`}),f("p",{children:e`What data will be collected?`}),f("ul",{style:{listStyle:"auto",paddingLeft:"1.5em"},children:[f("li",{children:[e`Usage data`,": ",e`When and which features you use, what pages you edit, etc.`]}),f("li",{children:[e`User information`,": ",e`Your user name and user ID.`]}),f("li",{children:[e`Site information`,": ",e`This wiki's url and site name.`]})]}),f("p",{children:f("strong",{children:e`NO sensitive data will be collected.`})})]}),okBtn:{label:e`Enable`},cancelBtn:{label:e`Disable`},closeAfter:0,onClose:()=>{this.ctx.storage.simpleKV.set(r,1)}},o=>{i.preferences.set("analytics.enabled",o),o&&this.addEvent("analytics","enabled")})})}_initPluginListeners(){const e=this.ctx;e.on("analytics/event",i=>{i&&this.addEvent(i.feature,i.subtype,i.page)}),e.on("in-article-links/anchor-clicked",i=>{this.addEvent("in-article-links",Ui(i.action))}),e.on("quick-diff/loaded",i=>{this.addEvent("quick-diff","loaded",i.compare.fromtitle)}),e.on("quick-redirect/submit",i=>{this.addEvent("quick-redirect","submit",i.payload.to||void 0)}),e.on("quick-preview/loaded",i=>{this.addEvent("quick-preview","loaded",i.wikiPage.title)}),e.on("quick-edit/wiki-page",i=>{this.addEvent("quick-edit",void 0,i.wikiPage.title)}),e.on("quick-edit/submit",i=>{this.addEvent("quick-edit","submit",i.wikiPage.title)}),e.on("quick-move/submit",()=>{this.addEvent("quick-move","submit")}),e.on("toolbox/button-clicked",({payload:i})=>{this.addEvent("toolbox",`button-clicked#${i.id||"unknown"}`)}),e.on("plugin-store/plugin-installed",({registry:i,id:r,by:n})=>{n==="new-added"&&this.addEvent("plugin-store","plugin-installed",`${r}@${i.name}`)}),e.on("plugin-store/plugin-uninstalled",({registry:i,id:r})=>{this.addEvent("plugin-store","plugin-uninstalled",`${r}@${i.name}`)})}addEvent(e,i,r){if(!e)return;const n={ts:Date.now(),feature:e,subtype:i,page:r};return this._usages.push(n),this._usages.length>=this.MAX_QUEUE_SIZE&&this.sendBeacon(),this}async sendBeacon(){if(this._usages.length===0)return!0;if(!await this.ctx.preferences.get("analytics.enabled",!1))return this.logger.debug("Analytics disabled, skipping"),!0;const i=this._usages.splice(0,this._usages.length),r={siteApi:this.ctx.wiki.getSciprtUrl("api"),siteName:this.ctx.wiki.siteInfo.general.sitename,userId:this.ctx.wiki.userInfo.id,userName:this.ctx.wiki.userInfo.name,version:this.ctx.version.split("-")[0],usages:i},n=JSON.stringify(r),s=`${this.analyticsApiBase}/submit`;if(navigator?.sendBeacon?.(s,n))return this.logger.debug("Beacon sent successfully",r),!0;{this.logger.debug("Beacon failed, sending via XMLHttpRequest");const{promise:a,resolve:c,reject:l}=wr();try{const u=new XMLHttpRequest;u.open("POST",s,!0),u.setRequestHeader("Content-Type","application/json"),u.send(n),u.onload=()=>{this.logger.debug("Beacon sent successfully via XMLHttpRequest",r),c(u.status>=200&&u.status<300)},u.onerror=()=>{l(new Error("Failed to send beacon"))}}catch(u){l(u)}return a}}stop(){this._timer!==null&&(clearInterval(this._timer),this._timer=null),this._usages.length>0&&this.sendBeacon()}}ho=fm(gc),_n=ym(ho,0,"PluginAnalytics",pc,_n),mm(ho,1,_n);const bm=Object.freeze(Object.defineProperty({__proto__:null,get PluginAnalytics(){return _n}},Symbol.toStringTag,{value:"Module"}));var vm=Object.create,po=Object.defineProperty,wm=Object.getOwnPropertyDescriptor,mc=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),yc=t=>{throw TypeError(t)},_m=(t,e,i)=>e in t?po(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,xm=(t,e)=>po(t,"name",{value:e,configurable:!0}),km=t=>[,,,vm(t?.[mc("metadata")]??null)],Sm=["class","method","getter","setter","accessor","field","value","get","set"],bc=t=>t!==void 0&&typeof t!="function"?yc("Function expected"):t,Em=(t,e,i,r,n)=>({kind:Sm[t],name:e,metadata:r,addInitializer:s=>i._?yc("Already initialized"):n.push(bc(s||null))}),$m=(t,e)=>_m(e,mc("metadata"),t[3]),Pm=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Cm=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&wm(n,i));xm(n,i);for(var h=r.length-1;h>=0;h--)c=Em(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,bc(o)&&(n=o);return $m(t,n),p&&po(n,i,p),u?l^4?s:p:n},vc,go,wc;vc=[xe(["wiki","wikiTitle","preferences","$"]),Tt(R.object({"inArticleLinks.enable":R.boolean().description("Whether to enable in-article links").default(!0),"inArticleLinks.quickDiff.enable":R.boolean().description("Whether to enable in-article links for quick diff").default(!0),"inArticleLinks.quickEdit.enable":R.boolean().description("Whether to enable in-article links for quick edit").default(!0),"inArticleLinks.quickEdit.redlinks":R.boolean().description("Whether to show quick edit button for redlinks").default(!0)}).description("In-article links preferences").extra("category","in-article-links"))];class xn extends(wc=Ue){constructor(e){super(e,{linkClassName:"ipe__in-article-link"},"InArticleLinks"),this._cachedAnchorInfo=new WeakMap,this.ctx.set("inArticleLinks",this);const{$:i}=this.ctx;this.ctx.preferences.defineCategory({name:"in-article-links",label:i`prefs.inArticleLinks.label`,description:i`prefs.inArticleLinks.$`,index:9})}async start(){await this.ctx.preferences.get("inArticleLinks.quickEdit.enable")&&this.handleQuickEdit(),await this.ctx.preferences.get("inArticleLinks.quickDiff.enable")&&this.handleQuickDiff()}async stop(){Array.from(document.getElementsByClassName(this.config.linkClassName)).forEach(e=>{e.remove()}),document.querySelectorAll("[data-ipe-edit-mounted]").forEach(e=>{e.dataset.ipeEditMounted=void 0})}parseAnchor(e){if(!(e instanceof HTMLAnchorElement))return null;const i=this._cachedAnchorInfo.get(e);if(i)return i;const r=e.getAttribute("href")||"";if(!this.ctx.wikiTitle.validateHrefAttr(r))return null;const n=e.href||"",s=this.ctx.wikiTitle.parseWikiLink(n);if(!s)return null;const o={$el:e,kind:e.closest('[typeof^="mw:File"]')?"mw:File":"normal",external:e.classList.contains("external")||!!r.startsWith("http"),redlink:e.classList.contains("new")||s.params.has("redlink"),...s};return this._cachedAnchorInfo.set(e,o),this.ctx.emit("in-article-links/anchor-parsed",{ctx:this.ctx,anchor:e,info:o}),o}scanAnchors(e,i){const r=e.querySelectorAll("a[href]");return Array.from(r).map(n=>this.parseAnchor(n)).filter(n=>n!==null&&(!i||i(n)))}onContentReady(e){const i=()=>{if(!window.mw)return;window.mw.hook("wikipage.content").add(e);const r=window.$?.("#mw-content-text");r?.length&&e(r)};window.mw&&typeof window.mw.hook=="function"?i():(window.RLQ=window.RLQ||[],window.RLQ.push(["mediawiki.base",i]))}async handleQuickEdit(){let e=!1;const i=await this.ctx.preferences.get("inArticleLinks.quickEdit.redlinks");this.ctx.inject(["quickEdit"],r=>{e=!0,r.on("dispose",()=>{e=!1}),this.onContentReady(n=>{if(!e||!n?.length)return;this.scanAnchors(n.get(0),({action:o,title:a,redlink:c})=>i||!c?["edit","create"].includes(o)?!0:a?.isSpecial("edit")||a?.isSpecial("newsection")?a.getMainText().split("/").length>=2:!1:!1).forEach(o=>{const{$el:a,title:c,pageId:l,params:u}=o;if(a.dataset.ipeEditMounted)return;if(a.dataset.ipeEditMounted="1",u.has("preload")||u.has("redo"))return this.ctx.logger.debug(a,"Not compatible with quick edit");const y=c?.getPrefixedDBKey()||"",p=u.get("section")?.replace(/^T-/,"")||void 0,h=u.get("oldid"),_=u.has("redlink");let k;p==="new"||c?.isSpecial("newsection")?k="new":p&&/^\d+$/.test(p)&&(k=parseInt(p,10));const P=h?parseInt(h,10):void 0,b={title:y,pageId:l||void 0,section:k,revision:P,createOnly:_},m=r.quickEdit.createQuickEditButton(b,{label:""});m.classList.add(this.config.linkClassName),m.addEventListener("click",g=>{this.ctx.emit("in-article-links/anchor-clicked",{ctx:this.ctx,anchor:a,info:o,event:g,action:"quickEdit"})}),a.insertAdjacentElement("afterend",m)})})})}handleQuickDiff(){let e=!1;const i=r=>["prev","next","cur"].includes(r);this.ctx.inject(["quickDiff"],r=>{e=!0,r.on("dispose",()=>{e=!1}),this.onContentReady(n=>{if(!e||!n?.length)return;this.scanAnchors(n.get(0),({params:o,title:a})=>!!(o.has("diff")||a?.isSpecial("diff"))).forEach(o=>{const{$el:a,title:c,params:l}=o;if(a.dataset.ipeDiffMounted)return;a.dataset.ipeDiffMounted="1";let u,d;if(c?.getNamespaceId()===-1?([,d,u]=c.getMainDBKey().split("/"),u||(u="prev")):(u=l.get("diff"),d=l.get("oldid")),!u||!d)return;const y={};i(u)?(y.fromrev=parseInt(d),y.torelative=u):(y.fromrev=parseInt(d),y.torev=parseInt(u));const p=this.ctx.quickDiff.createQuickDiffButton(y,{label:""});p.classList.add(this.config.linkClassName),p.addEventListener("click",h=>{this.ctx.emit("in-article-links/anchor-clicked",{ctx:this.ctx,anchor:a,info:o,event:h,action:"quickDiff"})}),a.insertAdjacentElement("afterend",p)})})})}}go=km(wc),xn=Cm(go,0,"PluginInArticleLinks",vc,xn),Pm(go,1,xn);const Im=Object.freeze(Object.defineProperty({__proto__:null,get PluginInArticleLinks(){return xn}},Symbol.toStringTag,{value:"Module"}));function mo(t){const e=Object.create(null);for(const i of t.split(","))e[i]=1;return i=>i in e}const le={},qi=[],Nt=()=>{},_c=()=>!1,kn=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&(t.charCodeAt(2)>122||t.charCodeAt(2)<97),yo=t=>t.startsWith("onUpdate:"),Fe=Object.assign,bo=(t,e)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)},Rm=Object.prototype.hasOwnProperty,ue=(t,e)=>Rm.call(t,e),J=Array.isArray,Bi=t=>Sn(t)==="[object Map]",xc=t=>Sn(t)==="[object Set]",Z=t=>typeof t=="function",Re=t=>typeof t=="string",Qt=t=>typeof t=="symbol",ke=t=>t!==null&&typeof t=="object",kc=t=>(ke(t)||Z(t))&&Z(t.then)&&Z(t.catch),Sc=Object.prototype.toString,Sn=t=>Sc.call(t),Am=t=>Sn(t).slice(8,-1),Ec=t=>Sn(t)==="[object Object]",vo=t=>Re(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,_r=mo(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),En=t=>{const e=Object.create(null);return(i=>e[i]||(e[i]=t(i)))},Tm=/-\w/g,Yt=En(t=>t.replace(Tm,e=>e.slice(1).toUpperCase())),Om=/\B([A-Z])/g,ci=En(t=>t.replace(Om,"-$1").toLowerCase()),$c=En(t=>t.charAt(0).toUpperCase()+t.slice(1)),wo=En(t=>t?`on${$c(t)}`:""),it=(t,e)=>!Object.is(t,e),$n=(t,...e)=>{for(let i=0;i<t.length;i++)t[i](...e)},Pc=(t,e,i,r=!1)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:r,value:i})},_o=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let Cc;const Pn=()=>Cc||(Cc=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function xo(t){if(J(t)){const e={};for(let i=0;i<t.length;i++){const r=t[i],n=Re(r)?Dm(r):xo(r);if(n)for(const s in n)e[s]=n[s]}return e}else if(Re(t)||ke(t))return t}const Lm=/;(?![^(]*\))/g,Nm=/:([^]+)/,Mm=/\/\*[^]*?\*\//g;function Dm(t){const e={};return t.replace(Mm,"").split(Lm).forEach(i=>{if(i){const r=i.split(Nm);r.length>1&&(e[r[0].trim()]=r[1].trim())}}),e}function xt(t){let e="";if(Re(t))e=t;else if(J(t))for(let i=0;i<t.length;i++){const r=xt(t[i]);r&&(e+=r+" ")}else if(ke(t))for(const i in t)t[i]&&(e+=i+" ");return e.trim()}const jm=mo("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly");function Ic(t){return!!t||t===""}const Rc=t=>!!(t&&t.__v_isRef===!0),ye=t=>Re(t)?t:t==null?"":J(t)||ke(t)&&(t.toString===Sc||!Z(t.toString))?Rc(t)?ye(t.value):JSON.stringify(t,Ac,2):String(t),Ac=(t,e)=>Rc(e)?Ac(t,e.value):Bi(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((i,[r,n],s)=>(i[ko(r,s)+" =>"]=n,i),{})}:xc(e)?{[`Set(${e.size})`]:[...e.values()].map(i=>ko(i))}:Qt(e)?ko(e):ke(e)&&!J(e)&&!Ec(e)?String(e):e,ko=(t,e="")=>{var i;return Qt(t)?`Symbol(${(i=t.description)!=null?i:e})`:t};let rt;class Um{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.parent=rt,!e&&rt&&(this.index=(rt.scopes||(rt.scopes=[])).push(this)-1)}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,i;if(this.scopes)for(e=0,i=this.scopes.length;e<i;e++)this.scopes[e].pause();for(e=0,i=this.effects.length;e<i;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,i;if(this.scopes)for(e=0,i=this.scopes.length;e<i;e++)this.scopes[e].resume();for(e=0,i=this.effects.length;e<i;e++)this.effects[e].resume()}}run(e){if(this._active){const i=rt;try{return rt=this,e()}finally{rt=i}}}on(){++this._on===1&&(this.prevScope=rt,rt=this)}off(){this._on>0&&--this._on===0&&(rt=this.prevScope,this.prevScope=void 0)}stop(e){if(this._active){this._active=!1;let i,r;for(i=0,r=this.effects.length;i<r;i++)this.effects[i].stop();for(this.effects.length=0,i=0,r=this.cleanups.length;i<r;i++)this.cleanups[i]();if(this.cleanups.length=0,this.scopes){for(i=0,r=this.scopes.length;i<r;i++)this.scopes[i].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){const n=this.parent.scopes.pop();n&&n!==this&&(this.parent.scopes[this.index]=n,n.index=this.index)}this.parent=void 0}}}function Fm(){return rt}let be;const So=new WeakSet;class Tc{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,rt&&rt.active&&rt.effects.push(this)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,So.has(this)&&(So.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||Lc(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,Uc(this),Nc(this);const e=be,i=kt;be=this,kt=!0;try{return this.fn()}finally{Mc(this),be=e,kt=i,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)Co(e);this.deps=this.depsTail=void 0,Uc(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?So.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){Po(this)&&this.run()}get dirty(){return Po(this)}}let Oc=0,xr,kr;function Lc(t,e=!1){if(t.flags|=8,e){t.next=kr,kr=t;return}t.next=xr,xr=t}function Eo(){Oc++}function $o(){if(--Oc>0)return;if(kr){let e=kr;for(kr=void 0;e;){const i=e.next;e.next=void 0,e.flags&=-9,e=i}}let t;for(;xr;){let e=xr;for(xr=void 0;e;){const i=e.next;if(e.next=void 0,e.flags&=-9,e.flags&1)try{e.trigger()}catch(r){t||(t=r)}e=i}}if(t)throw t}function Nc(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function Mc(t){let e,i=t.depsTail,r=i;for(;r;){const n=r.prevDep;r.version===-1?(r===i&&(i=n),Co(r),qm(r)):e=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=n}t.deps=e,t.depsTail=i}function Po(t){for(let e=t.deps;e;e=e.nextDep)if(e.dep.version!==e.version||e.dep.computed&&(Dc(e.dep.computed)||e.dep.version!==e.version))return!0;return!!t._dirty}function Dc(t){if(t.flags&4&&!(t.flags&16)||(t.flags&=-17,t.globalVersion===Sr)||(t.globalVersion=Sr,!t.isSSR&&t.flags&128&&(!t.deps&&!t._dirty||!Po(t))))return;t.flags|=2;const e=t.dep,i=be,r=kt;be=t,kt=!0;try{Nc(t);const n=t.fn(t._value);(e.version===0||it(n,t._value))&&(t.flags|=128,t._value=n,e.version++)}catch(n){throw e.version++,n}finally{be=i,kt=r,Mc(t),t.flags&=-3}}function Co(t,e=!1){const{dep:i,prevSub:r,nextSub:n}=t;if(r&&(r.nextSub=n,t.prevSub=void 0),n&&(n.prevSub=r,t.nextSub=void 0),i.subs===t&&(i.subs=r,!r&&i.computed)){i.computed.flags&=-5;for(let s=i.computed.deps;s;s=s.nextDep)Co(s,!0)}!e&&!--i.sc&&i.map&&i.map.delete(i.key)}function qm(t){const{prevDep:e,nextDep:i}=t;e&&(e.nextDep=i,t.prevDep=void 0),i&&(i.prevDep=e,t.nextDep=void 0)}let kt=!0;const jc=[];function Mt(){jc.push(kt),kt=!1}function Dt(){const t=jc.pop();kt=t===void 0?!0:t}function Uc(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const i=be;be=void 0;try{e()}finally{be=i}}}let Sr=0;class Bm{constructor(e,i){this.sub=e,this.dep=i,this.version=i.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class Cn{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!be||!kt||be===this.computed)return;let i=this.activeLink;if(i===void 0||i.sub!==be)i=this.activeLink=new Bm(be,this),be.deps?(i.prevDep=be.depsTail,be.depsTail.nextDep=i,be.depsTail=i):be.deps=be.depsTail=i,Fc(i);else if(i.version===-1&&(i.version=this.version,i.nextDep)){const r=i.nextDep;r.prevDep=i.prevDep,i.prevDep&&(i.prevDep.nextDep=r),i.prevDep=be.depsTail,i.nextDep=void 0,be.depsTail.nextDep=i,be.depsTail=i,be.deps===i&&(be.deps=r)}return i}trigger(e){this.version++,Sr++,this.notify(e)}notify(e){Eo();try{for(let i=this.subs;i;i=i.prevSub)i.sub.notify()&&i.sub.dep.notify()}finally{$o()}}}function Fc(t){if(t.dep.sc++,t.sub.flags&4){const e=t.dep.computed;if(e&&!t.dep.subs){e.flags|=20;for(let r=e.deps;r;r=r.nextDep)Fc(r)}const i=t.dep.subs;i!==t&&(t.prevSub=i,i&&(i.nextSub=t)),t.dep.subs=t}}const Io=new WeakMap,xi=Symbol(""),Ro=Symbol(""),Er=Symbol("");function He(t,e,i){if(kt&&be){let r=Io.get(t);r||Io.set(t,r=new Map);let n=r.get(i);n||(r.set(i,n=new Cn),n.map=r,n.key=i),n.track()}}function Xt(t,e,i,r,n,s){const o=Io.get(t);if(!o){Sr++;return}const a=c=>{c&&c.trigger()};if(Eo(),e==="clear")o.forEach(a);else{const c=J(t),l=c&&vo(i);if(c&&i==="length"){const u=Number(r);o.forEach((d,y)=>{(y==="length"||y===Er||!Qt(y)&&y>=u)&&a(d)})}else switch((i!==void 0||o.has(void 0))&&a(o.get(i)),l&&a(o.get(Er)),e){case"add":c?l&&a(o.get("length")):(a(o.get(xi)),Bi(t)&&a(o.get(Ro)));break;case"delete":c||(a(o.get(xi)),Bi(t)&&a(o.get(Ro)));break;case"set":Bi(t)&&a(o.get(xi));break}}$o()}function Hi(t){const e=oe(t);return e===t?e:(He(e,"iterate",Er),gt(t)?e:e.map(St))}function In(t){return He(t=oe(t),"iterate",Er),t}function ui(t,e){return Zt(t)?ki(t)?zi(St(e)):zi(e):St(e)}const Hm={__proto__:null,[Symbol.iterator](){return Ao(this,Symbol.iterator,t=>ui(this,t))},concat(...t){return Hi(this).concat(...t.map(e=>J(e)?Hi(e):e))},entries(){return Ao(this,"entries",t=>(t[1]=ui(this,t[1]),t))},every(t,e){return Jt(this,"every",t,e,void 0,arguments)},filter(t,e){return Jt(this,"filter",t,e,i=>i.map(r=>ui(this,r)),arguments)},find(t,e){return Jt(this,"find",t,e,i=>ui(this,i),arguments)},findIndex(t,e){return Jt(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return Jt(this,"findLast",t,e,i=>ui(this,i),arguments)},findLastIndex(t,e){return Jt(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return Jt(this,"forEach",t,e,void 0,arguments)},includes(...t){return To(this,"includes",t)},indexOf(...t){return To(this,"indexOf",t)},join(t){return Hi(this).join(t)},lastIndexOf(...t){return To(this,"lastIndexOf",t)},map(t,e){return Jt(this,"map",t,e,void 0,arguments)},pop(){return $r(this,"pop")},push(...t){return $r(this,"push",t)},reduce(t,...e){return qc(this,"reduce",t,e)},reduceRight(t,...e){return qc(this,"reduceRight",t,e)},shift(){return $r(this,"shift")},some(t,e){return Jt(this,"some",t,e,void 0,arguments)},splice(...t){return $r(this,"splice",t)},toReversed(){return Hi(this).toReversed()},toSorted(t){return Hi(this).toSorted(t)},toSpliced(...t){return Hi(this).toSpliced(...t)},unshift(...t){return $r(this,"unshift",t)},values(){return Ao(this,"values",t=>ui(this,t))}};function Ao(t,e,i){const r=In(t),n=r[e]();return r!==t&&!gt(t)&&(n._next=n.next,n.next=()=>{const s=n._next();return s.done||(s.value=i(s.value)),s}),n}const zm=Array.prototype;function Jt(t,e,i,r,n,s){const o=In(t),a=o!==t&&!gt(t),c=o[e];if(c!==zm[e]){const d=c.apply(t,s);return a?St(d):d}let l=i;o!==t&&(a?l=function(d,y){return i.call(this,ui(t,d),y,t)}:i.length>2&&(l=function(d,y){return i.call(this,d,y,t)}));const u=c.call(o,l,r);return a&&n?n(u):u}function qc(t,e,i,r){const n=In(t);let s=i;return n!==t&&(gt(t)?i.length>3&&(s=function(o,a,c){return i.call(this,o,a,c,t)}):s=function(o,a,c){return i.call(this,o,ui(t,a),c,t)}),n[e](s,...r)}function To(t,e,i){const r=oe(t);He(r,"iterate",Er);const n=r[e](...i);return(n===-1||n===!1)&&Mo(i[0])?(i[0]=oe(i[0]),r[e](...i)):n}function $r(t,e,i=[]){Mt(),Eo();const r=oe(t)[e].apply(t,i);return $o(),Dt(),r}const Wm=mo("__proto__,__v_isRef,__isVue"),Bc=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(Qt));function Km(t){Qt(t)||(t=String(t));const e=oe(this);return He(e,"has",t),e.hasOwnProperty(t)}class Hc{constructor(e=!1,i=!1){this._isReadonly=e,this._isShallow=i}get(e,i,r){if(i==="__v_skip")return e.__v_skip;const n=this._isReadonly,s=this._isShallow;if(i==="__v_isReactive")return!n;if(i==="__v_isReadonly")return n;if(i==="__v_isShallow")return s;if(i==="__v_raw")return r===(n?s?Qc:Gc:s?Vc:Kc).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(r)?e:void 0;const o=J(e);if(!n){let c;if(o&&(c=Hm[i]))return c;if(i==="hasOwnProperty")return Km}const a=Reflect.get(e,i,De(e)?e:r);if((Qt(i)?Bc.has(i):Wm(i))||(n||He(e,"get",i),s))return a;if(De(a)){const c=o&&vo(i)?a:a.value;return n&&ke(c)?No(c):c}return ke(a)?n?No(a):Lo(a):a}}class zc extends Hc{constructor(e=!1){super(!1,e)}set(e,i,r,n){let s=e[i];const o=J(e)&&vo(i);if(!this._isShallow){const l=Zt(s);if(!gt(r)&&!Zt(r)&&(s=oe(s),r=oe(r)),!o&&De(s)&&!De(r))return l||(s.value=r),!0}const a=o?Number(i)<e.length:ue(e,i),c=Reflect.set(e,i,r,De(e)?e:n);return e===oe(n)&&(a?it(r,s)&&Xt(e,"set",i,r):Xt(e,"add",i,r)),c}deleteProperty(e,i){const r=ue(e,i);e[i];const n=Reflect.deleteProperty(e,i);return n&&r&&Xt(e,"delete",i,void 0),n}has(e,i){const r=Reflect.has(e,i);return(!Qt(i)||!Bc.has(i))&&He(e,"has",i),r}ownKeys(e){return He(e,"iterate",J(e)?"length":xi),Reflect.ownKeys(e)}}class Wc extends Hc{constructor(e=!1){super(!0,e)}set(e,i){return!0}deleteProperty(e,i){return!0}}const Vm=new zc,Gm=new Wc,Qm=new zc(!0),Ym=new Wc(!0),Oo=t=>t,Rn=t=>Reflect.getPrototypeOf(t);function Xm(t,e,i){return function(...r){const n=this.__v_raw,s=oe(n),o=Bi(s),a=t==="entries"||t===Symbol.iterator&&o,c=t==="keys"&&o,l=n[t](...r),u=i?Oo:e?zi:St;return!e&&He(s,"iterate",c?Ro:xi),{next(){const{value:d,done:y}=l.next();return y?{value:d,done:y}:{value:a?[u(d[0]),u(d[1])]:u(d),done:y}},[Symbol.iterator](){return this}}}}function An(t){return function(...e){return t==="delete"?!1:t==="clear"?void 0:this}}function Jm(t,e){const i={get(n){const s=this.__v_raw,o=oe(s),a=oe(n);t||(it(n,a)&&He(o,"get",n),He(o,"get",a));const{has:c}=Rn(o),l=e?Oo:t?zi:St;if(c.call(o,n))return l(s.get(n));if(c.call(o,a))return l(s.get(a));s!==o&&s.get(n)},get size(){const n=this.__v_raw;return!t&&He(oe(n),"iterate",xi),n.size},has(n){const s=this.__v_raw,o=oe(s),a=oe(n);return t||(it(n,a)&&He(o,"has",n),He(o,"has",a)),n===a?s.has(n):s.has(n)||s.has(a)},forEach(n,s){const o=this,a=o.__v_raw,c=oe(a),l=e?Oo:t?zi:St;return!t&&He(c,"iterate",xi),a.forEach((u,d)=>n.call(s,l(u),l(d),o))}};return Fe(i,t?{add:An("add"),set:An("set"),delete:An("delete"),clear:An("clear")}:{add(n){!e&&!gt(n)&&!Zt(n)&&(n=oe(n));const s=oe(this);return Rn(s).has.call(s,n)||(s.add(n),Xt(s,"add",n,n)),this},set(n,s){!e&&!gt(s)&&!Zt(s)&&(s=oe(s));const o=oe(this),{has:a,get:c}=Rn(o);let l=a.call(o,n);l||(n=oe(n),l=a.call(o,n));const u=c.call(o,n);return o.set(n,s),l?it(s,u)&&Xt(o,"set",n,s):Xt(o,"add",n,s),this},delete(n){const s=oe(this),{has:o,get:a}=Rn(s);let c=o.call(s,n);c||(n=oe(n),c=o.call(s,n)),a&&a.call(s,n);const l=s.delete(n);return c&&Xt(s,"delete",n,void 0),l},clear(){const n=oe(this),s=n.size!==0,o=n.clear();return s&&Xt(n,"clear",void 0,void 0),o}}),["keys","values","entries",Symbol.iterator].forEach(n=>{i[n]=Xm(n,t,e)}),i}function Tn(t,e){const i=Jm(t,e);return(r,n,s)=>n==="__v_isReactive"?!t:n==="__v_isReadonly"?t:n==="__v_raw"?r:Reflect.get(ue(i,n)&&n in r?i:r,n,s)}const Zm={get:Tn(!1,!1)},ey={get:Tn(!1,!0)},ty={get:Tn(!0,!1)},iy={get:Tn(!0,!0)},Kc=new WeakMap,Vc=new WeakMap,Gc=new WeakMap,Qc=new WeakMap;function ry(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function ny(t){return t.__v_skip||!Object.isExtensible(t)?0:ry(Am(t))}function Lo(t){return Zt(t)?t:On(t,!1,Vm,Zm,Kc)}function sy(t){return On(t,!1,Qm,ey,Vc)}function No(t){return On(t,!0,Gm,ty,Gc)}function D0(t){return On(t,!0,Ym,iy,Qc)}function On(t,e,i,r,n){if(!ke(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const s=ny(t);if(s===0)return t;const o=n.get(t);if(o)return o;const a=new Proxy(t,s===2?r:i);return n.set(t,a),a}function ki(t){return Zt(t)?ki(t.__v_raw):!!(t&&t.__v_isReactive)}function Zt(t){return!!(t&&t.__v_isReadonly)}function gt(t){return!!(t&&t.__v_isShallow)}function Mo(t){return t?!!t.__v_raw:!1}function oe(t){const e=t&&t.__v_raw;return e?oe(e):t}function oy(t){return!ue(t,"__v_skip")&&Object.isExtensible(t)&&Pc(t,"__v_skip",!0),t}const St=t=>ke(t)?Lo(t):t,zi=t=>ke(t)?No(t):t;function De(t){return t?t.__v_isRef===!0:!1}function Qe(t){return Xc(t,!1)}function Yc(t){return Xc(t,!0)}function Xc(t,e){return De(t)?t:new ay(t,e)}class ay{constructor(e,i){this.dep=new Cn,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=i?e:oe(e),this._value=i?e:St(e),this.__v_isShallow=i}get value(){return this.dep.track(),this._value}set value(e){const i=this._rawValue,r=this.__v_isShallow||gt(e)||Zt(e);e=r?e:oe(e),it(e,i)&&(this._rawValue=e,this._value=r?e:St(e),this.dep.trigger())}}function Oe(t){return De(t)?t.value:t}const ly={get:(t,e,i)=>e==="__v_raw"?t:Oe(Reflect.get(t,e,i)),set:(t,e,i,r)=>{const n=t[e];return De(n)&&!De(i)?(n.value=i,!0):Reflect.set(t,e,i,r)}};function Jc(t){return ki(t)?t:new Proxy(t,ly)}class cy{constructor(e){this.__v_isRef=!0,this._value=void 0;const i=this.dep=new Cn,{get:r,set:n}=e(i.track.bind(i),i.trigger.bind(i));this._get=r,this._set=n}get value(){return this._value=this._get()}set value(e){this._set(e)}}function uy(t){return new cy(t)}class dy{constructor(e,i,r){this.fn=e,this.setter=i,this._value=void 0,this.dep=new Cn(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=Sr-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!i,this.isSSR=r}notify(){if(this.flags|=16,!(this.flags&8)&&be!==this)return Lc(this,!0),!0}get value(){const e=this.dep.track();return Dc(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}}function fy(t,e,i=!1){let r,n;return Z(t)?r=t:(r=t.get,n=t.set),new dy(r,n,i)}const Ln={},Nn=new WeakMap;let Si;function hy(t,e=!1,i=Si){if(i){let r=Nn.get(i);r||Nn.set(i,r=[]),r.push(t)}}function py(t,e,i=le){const{immediate:r,deep:n,once:s,scheduler:o,augmentJob:a,call:c}=i,l=g=>n?g:gt(g)||n===!1||n===0?ei(g,1):ei(g);let u,d,y,p,h=!1,_=!1;if(De(t)?(d=()=>t.value,h=gt(t)):ki(t)?(d=()=>l(t),h=!0):J(t)?(_=!0,h=t.some(g=>ki(g)||gt(g)),d=()=>t.map(g=>{if(De(g))return g.value;if(ki(g))return l(g);if(Z(g))return c?c(g,2):g()})):Z(t)?e?d=c?()=>c(t,2):t:d=()=>{if(y){Mt();try{y()}finally{Dt()}}const g=Si;Si=u;try{return c?c(t,3,[p]):t(p)}finally{Si=g}}:d=Nt,e&&n){const g=d,w=n===!0?1/0:n;d=()=>ei(g(),w)}const k=Fm(),P=()=>{u.stop(),k&&k.active&&bo(k.effects,u)};if(s&&e){const g=e;e=(...w)=>{g(...w),P()}}let b=_?new Array(t.length).fill(Ln):Ln;const m=g=>{if(!(!(u.flags&1)||!u.dirty&&!g))if(e){const w=u.run();if(n||h||(_?w.some((S,I)=>it(S,b[I])):it(w,b))){y&&y();const S=Si;Si=u;try{const I=[w,b===Ln?void 0:_&&b[0]===Ln?[]:b,p];b=w,c?c(e,3,I):e(...I)}finally{Si=S}}}else u.run()};return a&&a(m),u=new Tc(d),u.scheduler=o?()=>o(m,!1):m,p=g=>hy(g,!1,u),y=u.onStop=()=>{const g=Nn.get(u);if(g){if(c)c(g,4);else for(const w of g)w();Nn.delete(u)}},e?r?m(!0):b=u.run():o?o(m.bind(null,!0),!0):u.run(),P.pause=u.pause.bind(u),P.resume=u.resume.bind(u),P.stop=P,P}function ei(t,e=1/0,i){if(e<=0||!ke(t)||t.__v_skip||(i=i||new Map,(i.get(t)||0)>=e))return t;if(i.set(t,e),e--,De(t))ei(t.value,e,i);else if(J(t))for(let r=0;r<t.length;r++)ei(t[r],e,i);else if(xc(t)||Bi(t))t.forEach(r=>{ei(r,e,i)});else if(Ec(t)){for(const r in t)ei(t[r],e,i);for(const r of Object.getOwnPropertySymbols(t))Object.prototype.propertyIsEnumerable.call(t,r)&&ei(t[r],e,i)}return t}const Pr=[];let Do=!1;function j0(t,...e){if(Do)return;Do=!0,Mt();const i=Pr.length?Pr[Pr.length-1].component:null,r=i&&i.appContext.config.warnHandler,n=gy();if(r)Wi(r,i,11,[t+e.map(s=>{var o,a;return(a=(o=s.toString)==null?void 0:o.call(s))!=null?a:JSON.stringify(s)}).join(""),i&&i.proxy,n.map(({vnode:s})=>`at <${Qu(i,s.type)}>`).join(`
21
+ - Bug Reports: ${Lt.GITHUB_URL}`)}function fc(){const t=document.querySelector('meta[name="generator"][content^="MediaWiki"]')!==null,e=document.querySelector('link[rel="EditURI"]')?.href?.split("?")[0];return t&&e?e:void 0}function dm(t,e){const i=Symbol.for(t);return window[i]?!1:(window[i]=!0,e(),!0)}var fm=Object.create,ho=Object.defineProperty,hm=Object.getOwnPropertyDescriptor,hc=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),pc=t=>{throw TypeError(t)},pm=(t,e,i)=>e in t?ho(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,gm=(t,e)=>ho(t,"name",{value:e,configurable:!0}),mm=t=>[,,,fm(t?.[hc("metadata")]??null)],ym=["class","method","getter","setter","accessor","field","value","get","set"],gc=t=>t!==void 0&&typeof t!="function"?pc("Function expected"):t,bm=(t,e,i,r,n)=>({kind:ym[t],name:e,metadata:r,addInitializer:s=>i._?pc("Already initialized"):n.push(gc(s||null))}),vm=(t,e)=>pm(e,hc("metadata"),t[3]),wm=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},_m=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&hm(n,i));gm(n,i);for(var h=r.length-1;h>=0;h--)c=bm(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,gc(o)&&(n=o);return vm(t,n),p&&ho(n,i,p),u?l^4?s:p:n},mc,po,yc;mc=[xe(["wiki","preferences","$"])];class _n extends(yc=Ue){constructor(e){super(e,{},"analytics"),this.ctx=e,this._usages=[],this._timer=null,this.MAX_QUEUE_SIZE=50,this.INTERVAL_MS=60*1e3,this._setupTimer(),this._registerUnloadHandler(),this._showConfirmNotify(),this._initPluginListeners(),e.set("analytics",this)}start(){const e=this.ctx,i=e.$;e.preferences.registerCustomConfig("analytics",A.object({"analytics._intro":A.const(f("section",{children:[f("h3",{children:i`InPageEdit Analytics`}),f("p",{children:i`InPageEdit Analytics is the companion analytics platform for the InPageEdit NEXT project. By collecting and displaying usage data from around the world, it helps developers and the community better understand how the tool is used, optimize feature design, and enhance user experience.`}),f("h4",{children:i`What data will be collected?`}),f("ol",{style:{listStyle:"number",paddingLeft:"1em"},children:[f("li",{children:[f("strong",{children:i`Usage data`}),":"," ",i`When and which features you use, what pages you edit, etc.`]}),f("li",{children:[f("strong",{children:i`User information`}),": ",i`Your user name and user ID.`]}),f("li",{children:[f("strong",{children:i`Site information`}),": ",i`This wiki's url and site name.`]})]}),f("p",{children:f("strong",{children:i`NO sensitive data will be collected.`})}),f("div",{style:{display:"grid",gap:"0.5rem"},children:[f("a",{href:this.analyticsDashUrl,target:"_blank",rel:"noopener noreferrer",children:f("button",{className:"btn",style:{width:"100%"},children:i`Analytics Platform`})}),f("a",{href:`${this.analyticsDashUrl}/_redirect/user?${new URLSearchParams({siteApi:this.ctx.wiki.getSciprtUrl("api"),mwUserId:this.ctx.wiki.userInfo.id.toString()}).toString()}`,target:"_blank",rel:"noopener noreferrer",children:f("button",{className:"btn",style:{width:"100%"},children:i`View My Data`})})]})]})).role("raw-html"),"analytics.enabled":A.boolean().description(i`prefs.analytics.enabled`).default(!1)}).description(i`prefs.analytics.$`),"general")}get analyticsDashUrl(){return Lt.ANALYTICS_DASH_URL}get analyticsApiBase(){return Lt.ANALYTICS_API_BASE}_setupTimer(){this._timer=setInterval(()=>{this._usages.length>0&&this.sendBeacon()},this.INTERVAL_MS)}_registerUnloadHandler(){const e=()=>{this._usages.length>0&&this.sendBeacon()};window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&e()}),window.addEventListener("pagehide",e),window.addEventListener("beforeunload",e)}async _showConfirmNotify(){const{$:e}=this.ctx;this.ctx.inject(["modal","storage"],async i=>{const r="analytics/confirm-shown",n=await i.storage.simpleKV.get(r),s=await i.preferences.get("analytics.enabled");n||s||i.modal.notify("confirm",{title:e`Enable Analytics`,content:f("div",{children:[f("p",{children:e`Help us improve InPageEdit by sharing your usage data with us.`}),f("p",{children:e`What data will be collected?`}),f("ul",{style:{listStyle:"auto",paddingLeft:"1.5em"},children:[f("li",{children:[e`Usage data`,": ",e`When and which features you use, what pages you edit, etc.`]}),f("li",{children:[e`User information`,": ",e`Your user name and user ID.`]}),f("li",{children:[e`Site information`,": ",e`This wiki's url and site name.`]})]}),f("p",{children:f("strong",{children:e`NO sensitive data will be collected.`})})]}),okBtn:{label:e`Enable`},cancelBtn:{label:e`Disable`},closeAfter:0,onClose:()=>{this.ctx.storage.simpleKV.set(r,1)}},o=>{i.preferences.set("analytics.enabled",o),o&&this.addEvent("analytics","enabled")})})}_initPluginListeners(){const e=this.ctx;e.on("analytics/event",i=>{i&&this.addEvent(i.feature,i.subtype,i.page)}),e.on("in-article-links/anchor-clicked",i=>{this.addEvent("in-article-links",Ui(i.action))}),e.on("quick-diff/loaded",i=>{this.addEvent("quick-diff","loaded",i.compare.fromtitle)}),e.on("quick-redirect/submit",i=>{this.addEvent("quick-redirect","submit",i.payload.to||void 0)}),e.on("quick-preview/loaded",i=>{this.addEvent("quick-preview","loaded",i.wikiPage.title)}),e.on("quick-edit/wiki-page",i=>{this.addEvent("quick-edit",void 0,i.wikiPage.title)}),e.on("quick-edit/submit",i=>{this.addEvent("quick-edit","submit",i.wikiPage.title)}),e.on("quick-move/submit",()=>{this.addEvent("quick-move","submit")}),e.on("toolbox/button-clicked",({payload:i})=>{this.addEvent("toolbox",`button-clicked#${i.id||"unknown"}`)}),e.on("plugin-store/plugin-installed",({registry:i,id:r,by:n})=>{n==="new-added"&&this.addEvent("plugin-store","plugin-installed",`${r}@${i.name}`)}),e.on("plugin-store/plugin-uninstalled",({registry:i,id:r})=>{this.addEvent("plugin-store","plugin-uninstalled",`${r}@${i.name}`)})}addEvent(e,i,r){if(!e)return;const n={ts:Date.now(),feature:e,subtype:i,page:r};return this._usages.push(n),this._usages.length>=this.MAX_QUEUE_SIZE&&this.sendBeacon(),this}async sendBeacon(){if(this._usages.length===0)return!0;if(!await this.ctx.preferences.get("analytics.enabled",!1))return this.logger.debug("Analytics disabled, skipping"),!0;const i=this._usages.splice(0,this._usages.length),r={siteApi:this.ctx.wiki.getSciprtUrl("api"),siteName:this.ctx.wiki.siteInfo.general.sitename,userId:this.ctx.wiki.userInfo.id,userName:this.ctx.wiki.userInfo.name,version:this.ctx.version.split("-")[0],usages:i},n=JSON.stringify(r),s=`${this.analyticsApiBase}/submit`;if(navigator?.sendBeacon?.(s,n))return this.logger.debug("Beacon sent successfully",r),!0;{this.logger.debug("Beacon failed, sending via XMLHttpRequest");const{promise:a,resolve:c,reject:l}=wr();try{const u=new XMLHttpRequest;u.open("POST",s,!0),u.setRequestHeader("Content-Type","application/json"),u.send(n),u.onload=()=>{this.logger.debug("Beacon sent successfully via XMLHttpRequest",r),c(u.status>=200&&u.status<300)},u.onerror=()=>{l(new Error("Failed to send beacon"))}}catch(u){l(u)}return a}}stop(){this._timer!==null&&(clearInterval(this._timer),this._timer=null),this._usages.length>0&&this.sendBeacon()}}po=mm(yc),_n=_m(po,0,"PluginAnalytics",mc,_n),wm(po,1,_n);const xm=Object.freeze(Object.defineProperty({__proto__:null,get PluginAnalytics(){return _n}},Symbol.toStringTag,{value:"Module"}));var km=Object.create,go=Object.defineProperty,Sm=Object.getOwnPropertyDescriptor,bc=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),vc=t=>{throw TypeError(t)},Em=(t,e,i)=>e in t?go(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,$m=(t,e)=>go(t,"name",{value:e,configurable:!0}),Pm=t=>[,,,km(t?.[bc("metadata")]??null)],Cm=["class","method","getter","setter","accessor","field","value","get","set"],wc=t=>t!==void 0&&typeof t!="function"?vc("Function expected"):t,Im=(t,e,i,r,n)=>({kind:Cm[t],name:e,metadata:r,addInitializer:s=>i._?vc("Already initialized"):n.push(wc(s||null))}),Am=(t,e)=>Em(e,bc("metadata"),t[3]),Rm=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Tm=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&Sm(n,i));$m(n,i);for(var h=r.length-1;h>=0;h--)c=Im(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,wc(o)&&(n=o);return Am(t,n),p&&go(n,i,p),u?l^4?s:p:n},_c,mo,xc;_c=[xe(["wiki","wikiTitle","preferences","$"]),Tt(A.object({"inArticleLinks.enable":A.boolean().description("Whether to enable in-article links").default(!0),"inArticleLinks.quickDiff.enable":A.boolean().description("Whether to enable in-article links for quick diff").default(!0),"inArticleLinks.quickEdit.enable":A.boolean().description("Whether to enable in-article links for quick edit").default(!0),"inArticleLinks.quickEdit.redlinks":A.boolean().description("Whether to show quick edit button for redlinks").default(!0)}).description("In-article links preferences").extra("category","in-article-links"))];class xn extends(xc=Ue){constructor(e){super(e,{linkClassName:"ipe__in-article-link"},"InArticleLinks"),this._cachedAnchorInfo=new WeakMap,this.ctx.set("inArticleLinks",this);const{$:i}=this.ctx;this.ctx.preferences.defineCategory({name:"in-article-links",label:i`prefs.inArticleLinks.label`,description:i`prefs.inArticleLinks.$`,index:9})}async start(){await this.ctx.preferences.get("inArticleLinks.quickEdit.enable")&&this.handleQuickEdit(),await this.ctx.preferences.get("inArticleLinks.quickDiff.enable")&&this.handleQuickDiff()}async stop(){Array.from(document.getElementsByClassName(this.config.linkClassName)).forEach(e=>{e.remove()}),document.querySelectorAll("[data-ipe-edit-mounted]").forEach(e=>{e.dataset.ipeEditMounted=void 0})}parseAnchor(e){if(!(e instanceof HTMLAnchorElement))return null;const i=this._cachedAnchorInfo.get(e);if(i)return i;const r=e.getAttribute("href")||"";if(!this.ctx.wikiTitle.validateHrefAttr(r))return null;const n=e.href||"",s=this.ctx.wikiTitle.parseWikiLink(n);if(!s)return null;const o={$el:e,kind:e.closest('[typeof^="mw:File"]')?"mw:File":"normal",external:e.classList.contains("external")||!!r.startsWith("http"),redlink:e.classList.contains("new")||s.params.has("redlink"),...s};return this._cachedAnchorInfo.set(e,o),this.ctx.emit("in-article-links/anchor-parsed",{ctx:this.ctx,anchor:e,info:o}),o}scanAnchors(e,i){const r=e.querySelectorAll("a[href]");return Array.from(r).map(n=>this.parseAnchor(n)).filter(n=>n!==null&&(!i||i(n)))}onContentReady(e){const i=()=>{if(!window.mw)return;window.mw.hook("wikipage.content").add(e);const r=window.$?.("#mw-content-text");r?.length&&e(r)};window.mw&&typeof window.mw.hook=="function"?i():(window.RLQ=window.RLQ||[],window.RLQ.push(["mediawiki.base",i]))}async handleQuickEdit(){let e=!1;const i=await this.ctx.preferences.get("inArticleLinks.quickEdit.redlinks");this.ctx.inject(["quickEdit"],r=>{e=!0,r.on("dispose",()=>{e=!1}),this.onContentReady(n=>{if(!e||!n?.length)return;this.scanAnchors(n.get(0),({action:o,title:a,redlink:c})=>i||!c?["edit","create"].includes(o)?!0:a?.isSpecial("edit")||a?.isSpecial("newsection")?a.getMainText().split("/").length>=2:!1:!1).forEach(o=>{const{$el:a,title:c,pageId:l,params:u}=o;if(a.dataset.ipeEditMounted)return;if(a.dataset.ipeEditMounted="1",u.has("preload")||u.has("redo"))return this.ctx.logger.debug(a,"Not compatible with quick edit");const y=c?.getPrefixedDBKey()||"",p=u.get("section")?.replace(/^T-/,"")||void 0,h=u.get("oldid"),_=u.has("redlink");let k;p==="new"||c?.isSpecial("newsection")?k="new":p&&/^\d+$/.test(p)&&(k=parseInt(p,10));const P=h?parseInt(h,10):void 0,b={title:y,pageId:l||void 0,section:k,revision:P,createOnly:_},m=r.quickEdit.createQuickEditButton(b,{label:""});m.classList.add(this.config.linkClassName),m.addEventListener("click",g=>{this.ctx.emit("in-article-links/anchor-clicked",{ctx:this.ctx,anchor:a,info:o,event:g,action:"quickEdit"})}),a.insertAdjacentElement("afterend",m)})})})}handleQuickDiff(){let e=!1;const i=r=>["prev","next","cur"].includes(r);this.ctx.inject(["quickDiff"],r=>{e=!0,r.on("dispose",()=>{e=!1}),this.onContentReady(n=>{if(!e||!n?.length)return;this.scanAnchors(n.get(0),({params:o,title:a})=>!!(o.has("diff")||a?.isSpecial("diff"))).forEach(o=>{const{$el:a,title:c,params:l}=o;if(a.dataset.ipeDiffMounted)return;a.dataset.ipeDiffMounted="1";let u,d;if(c?.getNamespaceId()===-1?([,d,u]=c.getMainDBKey().split("/"),u||(u="prev")):(u=l.get("diff"),d=l.get("oldid")),!u||!d)return;const y={};i(u)?(y.fromrev=parseInt(d),y.torelative=u):(y.fromrev=parseInt(d),y.torev=parseInt(u));const p=this.ctx.quickDiff.createQuickDiffButton(y,{label:""});p.classList.add(this.config.linkClassName),p.addEventListener("click",h=>{this.ctx.emit("in-article-links/anchor-clicked",{ctx:this.ctx,anchor:a,info:o,event:h,action:"quickDiff"})}),a.insertAdjacentElement("afterend",p)})})})}}mo=Pm(xc),xn=Tm(mo,0,"PluginInArticleLinks",_c,xn),Rm(mo,1,xn);const Om=Object.freeze(Object.defineProperty({__proto__:null,get PluginInArticleLinks(){return xn}},Symbol.toStringTag,{value:"Module"}));function yo(t){const e=Object.create(null);for(const i of t.split(","))e[i]=1;return i=>i in e}const le={},qi=[],Nt=()=>{},kc=()=>!1,kn=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&(t.charCodeAt(2)>122||t.charCodeAt(2)<97),bo=t=>t.startsWith("onUpdate:"),Fe=Object.assign,vo=(t,e)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)},Lm=Object.prototype.hasOwnProperty,ue=(t,e)=>Lm.call(t,e),J=Array.isArray,Bi=t=>Sn(t)==="[object Map]",Sc=t=>Sn(t)==="[object Set]",Z=t=>typeof t=="function",Ae=t=>typeof t=="string",Qt=t=>typeof t=="symbol",ke=t=>t!==null&&typeof t=="object",Ec=t=>(ke(t)||Z(t))&&Z(t.then)&&Z(t.catch),$c=Object.prototype.toString,Sn=t=>$c.call(t),Nm=t=>Sn(t).slice(8,-1),Pc=t=>Sn(t)==="[object Object]",wo=t=>Ae(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,_r=yo(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),En=t=>{const e=Object.create(null);return(i=>e[i]||(e[i]=t(i)))},Mm=/-\w/g,Yt=En(t=>t.replace(Mm,e=>e.slice(1).toUpperCase())),Dm=/\B([A-Z])/g,ci=En(t=>t.replace(Dm,"-$1").toLowerCase()),Cc=En(t=>t.charAt(0).toUpperCase()+t.slice(1)),_o=En(t=>t?`on${Cc(t)}`:""),it=(t,e)=>!Object.is(t,e),$n=(t,...e)=>{for(let i=0;i<t.length;i++)t[i](...e)},Ic=(t,e,i,r=!1)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:r,value:i})},xo=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let Ac;const Pn=()=>Ac||(Ac=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function ko(t){if(J(t)){const e={};for(let i=0;i<t.length;i++){const r=t[i],n=Ae(r)?qm(r):ko(r);if(n)for(const s in n)e[s]=n[s]}return e}else if(Ae(t)||ke(t))return t}const jm=/;(?![^(]*\))/g,Um=/:([^]+)/,Fm=/\/\*[^]*?\*\//g;function qm(t){const e={};return t.replace(Fm,"").split(jm).forEach(i=>{if(i){const r=i.split(Um);r.length>1&&(e[r[0].trim()]=r[1].trim())}}),e}function xt(t){let e="";if(Ae(t))e=t;else if(J(t))for(let i=0;i<t.length;i++){const r=xt(t[i]);r&&(e+=r+" ")}else if(ke(t))for(const i in t)t[i]&&(e+=i+" ");return e.trim()}const Bm=yo("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly");function Rc(t){return!!t||t===""}const Tc=t=>!!(t&&t.__v_isRef===!0),ye=t=>Ae(t)?t:t==null?"":J(t)||ke(t)&&(t.toString===$c||!Z(t.toString))?Tc(t)?ye(t.value):JSON.stringify(t,Oc,2):String(t),Oc=(t,e)=>Tc(e)?Oc(t,e.value):Bi(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((i,[r,n],s)=>(i[So(r,s)+" =>"]=n,i),{})}:Sc(e)?{[`Set(${e.size})`]:[...e.values()].map(i=>So(i))}:Qt(e)?So(e):ke(e)&&!J(e)&&!Pc(e)?String(e):e,So=(t,e="")=>{var i;return Qt(t)?`Symbol(${(i=t.description)!=null?i:e})`:t};let rt;class Hm{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.parent=rt,!e&&rt&&(this.index=(rt.scopes||(rt.scopes=[])).push(this)-1)}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,i;if(this.scopes)for(e=0,i=this.scopes.length;e<i;e++)this.scopes[e].pause();for(e=0,i=this.effects.length;e<i;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,i;if(this.scopes)for(e=0,i=this.scopes.length;e<i;e++)this.scopes[e].resume();for(e=0,i=this.effects.length;e<i;e++)this.effects[e].resume()}}run(e){if(this._active){const i=rt;try{return rt=this,e()}finally{rt=i}}}on(){++this._on===1&&(this.prevScope=rt,rt=this)}off(){this._on>0&&--this._on===0&&(rt=this.prevScope,this.prevScope=void 0)}stop(e){if(this._active){this._active=!1;let i,r;for(i=0,r=this.effects.length;i<r;i++)this.effects[i].stop();for(this.effects.length=0,i=0,r=this.cleanups.length;i<r;i++)this.cleanups[i]();if(this.cleanups.length=0,this.scopes){for(i=0,r=this.scopes.length;i<r;i++)this.scopes[i].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){const n=this.parent.scopes.pop();n&&n!==this&&(this.parent.scopes[this.index]=n,n.index=this.index)}this.parent=void 0}}}function zm(){return rt}let be;const Eo=new WeakSet;class Lc{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,rt&&rt.active&&rt.effects.push(this)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,Eo.has(this)&&(Eo.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||Mc(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,qc(this),Dc(this);const e=be,i=kt;be=this,kt=!0;try{return this.fn()}finally{jc(this),be=e,kt=i,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)Io(e);this.deps=this.depsTail=void 0,qc(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?Eo.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){Co(this)&&this.run()}get dirty(){return Co(this)}}let Nc=0,xr,kr;function Mc(t,e=!1){if(t.flags|=8,e){t.next=kr,kr=t;return}t.next=xr,xr=t}function $o(){Nc++}function Po(){if(--Nc>0)return;if(kr){let e=kr;for(kr=void 0;e;){const i=e.next;e.next=void 0,e.flags&=-9,e=i}}let t;for(;xr;){let e=xr;for(xr=void 0;e;){const i=e.next;if(e.next=void 0,e.flags&=-9,e.flags&1)try{e.trigger()}catch(r){t||(t=r)}e=i}}if(t)throw t}function Dc(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function jc(t){let e,i=t.depsTail,r=i;for(;r;){const n=r.prevDep;r.version===-1?(r===i&&(i=n),Io(r),Wm(r)):e=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=n}t.deps=e,t.depsTail=i}function Co(t){for(let e=t.deps;e;e=e.nextDep)if(e.dep.version!==e.version||e.dep.computed&&(Uc(e.dep.computed)||e.dep.version!==e.version))return!0;return!!t._dirty}function Uc(t){if(t.flags&4&&!(t.flags&16)||(t.flags&=-17,t.globalVersion===Sr)||(t.globalVersion=Sr,!t.isSSR&&t.flags&128&&(!t.deps&&!t._dirty||!Co(t))))return;t.flags|=2;const e=t.dep,i=be,r=kt;be=t,kt=!0;try{Dc(t);const n=t.fn(t._value);(e.version===0||it(n,t._value))&&(t.flags|=128,t._value=n,e.version++)}catch(n){throw e.version++,n}finally{be=i,kt=r,jc(t),t.flags&=-3}}function Io(t,e=!1){const{dep:i,prevSub:r,nextSub:n}=t;if(r&&(r.nextSub=n,t.prevSub=void 0),n&&(n.prevSub=r,t.nextSub=void 0),i.subs===t&&(i.subs=r,!r&&i.computed)){i.computed.flags&=-5;for(let s=i.computed.deps;s;s=s.nextDep)Io(s,!0)}!e&&!--i.sc&&i.map&&i.map.delete(i.key)}function Wm(t){const{prevDep:e,nextDep:i}=t;e&&(e.nextDep=i,t.prevDep=void 0),i&&(i.prevDep=e,t.nextDep=void 0)}let kt=!0;const Fc=[];function Mt(){Fc.push(kt),kt=!1}function Dt(){const t=Fc.pop();kt=t===void 0?!0:t}function qc(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const i=be;be=void 0;try{e()}finally{be=i}}}let Sr=0;class Km{constructor(e,i){this.sub=e,this.dep=i,this.version=i.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class Cn{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!be||!kt||be===this.computed)return;let i=this.activeLink;if(i===void 0||i.sub!==be)i=this.activeLink=new Km(be,this),be.deps?(i.prevDep=be.depsTail,be.depsTail.nextDep=i,be.depsTail=i):be.deps=be.depsTail=i,Bc(i);else if(i.version===-1&&(i.version=this.version,i.nextDep)){const r=i.nextDep;r.prevDep=i.prevDep,i.prevDep&&(i.prevDep.nextDep=r),i.prevDep=be.depsTail,i.nextDep=void 0,be.depsTail.nextDep=i,be.depsTail=i,be.deps===i&&(be.deps=r)}return i}trigger(e){this.version++,Sr++,this.notify(e)}notify(e){$o();try{for(let i=this.subs;i;i=i.prevSub)i.sub.notify()&&i.sub.dep.notify()}finally{Po()}}}function Bc(t){if(t.dep.sc++,t.sub.flags&4){const e=t.dep.computed;if(e&&!t.dep.subs){e.flags|=20;for(let r=e.deps;r;r=r.nextDep)Bc(r)}const i=t.dep.subs;i!==t&&(t.prevSub=i,i&&(i.nextSub=t)),t.dep.subs=t}}const Ao=new WeakMap,xi=Symbol(""),Ro=Symbol(""),Er=Symbol("");function He(t,e,i){if(kt&&be){let r=Ao.get(t);r||Ao.set(t,r=new Map);let n=r.get(i);n||(r.set(i,n=new Cn),n.map=r,n.key=i),n.track()}}function Xt(t,e,i,r,n,s){const o=Ao.get(t);if(!o){Sr++;return}const a=c=>{c&&c.trigger()};if($o(),e==="clear")o.forEach(a);else{const c=J(t),l=c&&wo(i);if(c&&i==="length"){const u=Number(r);o.forEach((d,y)=>{(y==="length"||y===Er||!Qt(y)&&y>=u)&&a(d)})}else switch((i!==void 0||o.has(void 0))&&a(o.get(i)),l&&a(o.get(Er)),e){case"add":c?l&&a(o.get("length")):(a(o.get(xi)),Bi(t)&&a(o.get(Ro)));break;case"delete":c||(a(o.get(xi)),Bi(t)&&a(o.get(Ro)));break;case"set":Bi(t)&&a(o.get(xi));break}}Po()}function Hi(t){const e=oe(t);return e===t?e:(He(e,"iterate",Er),gt(t)?e:e.map(St))}function In(t){return He(t=oe(t),"iterate",Er),t}function ui(t,e){return Zt(t)?ki(t)?zi(St(e)):zi(e):St(e)}const Vm={__proto__:null,[Symbol.iterator](){return To(this,Symbol.iterator,t=>ui(this,t))},concat(...t){return Hi(this).concat(...t.map(e=>J(e)?Hi(e):e))},entries(){return To(this,"entries",t=>(t[1]=ui(this,t[1]),t))},every(t,e){return Jt(this,"every",t,e,void 0,arguments)},filter(t,e){return Jt(this,"filter",t,e,i=>i.map(r=>ui(this,r)),arguments)},find(t,e){return Jt(this,"find",t,e,i=>ui(this,i),arguments)},findIndex(t,e){return Jt(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return Jt(this,"findLast",t,e,i=>ui(this,i),arguments)},findLastIndex(t,e){return Jt(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return Jt(this,"forEach",t,e,void 0,arguments)},includes(...t){return Oo(this,"includes",t)},indexOf(...t){return Oo(this,"indexOf",t)},join(t){return Hi(this).join(t)},lastIndexOf(...t){return Oo(this,"lastIndexOf",t)},map(t,e){return Jt(this,"map",t,e,void 0,arguments)},pop(){return $r(this,"pop")},push(...t){return $r(this,"push",t)},reduce(t,...e){return Hc(this,"reduce",t,e)},reduceRight(t,...e){return Hc(this,"reduceRight",t,e)},shift(){return $r(this,"shift")},some(t,e){return Jt(this,"some",t,e,void 0,arguments)},splice(...t){return $r(this,"splice",t)},toReversed(){return Hi(this).toReversed()},toSorted(t){return Hi(this).toSorted(t)},toSpliced(...t){return Hi(this).toSpliced(...t)},unshift(...t){return $r(this,"unshift",t)},values(){return To(this,"values",t=>ui(this,t))}};function To(t,e,i){const r=In(t),n=r[e]();return r!==t&&!gt(t)&&(n._next=n.next,n.next=()=>{const s=n._next();return s.done||(s.value=i(s.value)),s}),n}const Gm=Array.prototype;function Jt(t,e,i,r,n,s){const o=In(t),a=o!==t&&!gt(t),c=o[e];if(c!==Gm[e]){const d=c.apply(t,s);return a?St(d):d}let l=i;o!==t&&(a?l=function(d,y){return i.call(this,ui(t,d),y,t)}:i.length>2&&(l=function(d,y){return i.call(this,d,y,t)}));const u=c.call(o,l,r);return a&&n?n(u):u}function Hc(t,e,i,r){const n=In(t);let s=i;return n!==t&&(gt(t)?i.length>3&&(s=function(o,a,c){return i.call(this,o,a,c,t)}):s=function(o,a,c){return i.call(this,o,ui(t,a),c,t)}),n[e](s,...r)}function Oo(t,e,i){const r=oe(t);He(r,"iterate",Er);const n=r[e](...i);return(n===-1||n===!1)&&Do(i[0])?(i[0]=oe(i[0]),r[e](...i)):n}function $r(t,e,i=[]){Mt(),$o();const r=oe(t)[e].apply(t,i);return Po(),Dt(),r}const Qm=yo("__proto__,__v_isRef,__isVue"),zc=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(Qt));function Ym(t){Qt(t)||(t=String(t));const e=oe(this);return He(e,"has",t),e.hasOwnProperty(t)}class Wc{constructor(e=!1,i=!1){this._isReadonly=e,this._isShallow=i}get(e,i,r){if(i==="__v_skip")return e.__v_skip;const n=this._isReadonly,s=this._isShallow;if(i==="__v_isReactive")return!n;if(i==="__v_isReadonly")return n;if(i==="__v_isShallow")return s;if(i==="__v_raw")return r===(n?s?Xc:Yc:s?Qc:Gc).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(r)?e:void 0;const o=J(e);if(!n){let c;if(o&&(c=Vm[i]))return c;if(i==="hasOwnProperty")return Ym}const a=Reflect.get(e,i,De(e)?e:r);if((Qt(i)?zc.has(i):Qm(i))||(n||He(e,"get",i),s))return a;if(De(a)){const c=o&&wo(i)?a:a.value;return n&&ke(c)?Mo(c):c}return ke(a)?n?Mo(a):No(a):a}}class Kc extends Wc{constructor(e=!1){super(!1,e)}set(e,i,r,n){let s=e[i];const o=J(e)&&wo(i);if(!this._isShallow){const l=Zt(s);if(!gt(r)&&!Zt(r)&&(s=oe(s),r=oe(r)),!o&&De(s)&&!De(r))return l||(s.value=r),!0}const a=o?Number(i)<e.length:ue(e,i),c=Reflect.set(e,i,r,De(e)?e:n);return e===oe(n)&&(a?it(r,s)&&Xt(e,"set",i,r):Xt(e,"add",i,r)),c}deleteProperty(e,i){const r=ue(e,i);e[i];const n=Reflect.deleteProperty(e,i);return n&&r&&Xt(e,"delete",i,void 0),n}has(e,i){const r=Reflect.has(e,i);return(!Qt(i)||!zc.has(i))&&He(e,"has",i),r}ownKeys(e){return He(e,"iterate",J(e)?"length":xi),Reflect.ownKeys(e)}}class Vc extends Wc{constructor(e=!1){super(!0,e)}set(e,i){return!0}deleteProperty(e,i){return!0}}const Xm=new Kc,Jm=new Vc,Zm=new Kc(!0),ey=new Vc(!0),Lo=t=>t,An=t=>Reflect.getPrototypeOf(t);function ty(t,e,i){return function(...r){const n=this.__v_raw,s=oe(n),o=Bi(s),a=t==="entries"||t===Symbol.iterator&&o,c=t==="keys"&&o,l=n[t](...r),u=i?Lo:e?zi:St;return!e&&He(s,"iterate",c?Ro:xi),{next(){const{value:d,done:y}=l.next();return y?{value:d,done:y}:{value:a?[u(d[0]),u(d[1])]:u(d),done:y}},[Symbol.iterator](){return this}}}}function Rn(t){return function(...e){return t==="delete"?!1:t==="clear"?void 0:this}}function iy(t,e){const i={get(n){const s=this.__v_raw,o=oe(s),a=oe(n);t||(it(n,a)&&He(o,"get",n),He(o,"get",a));const{has:c}=An(o),l=e?Lo:t?zi:St;if(c.call(o,n))return l(s.get(n));if(c.call(o,a))return l(s.get(a));s!==o&&s.get(n)},get size(){const n=this.__v_raw;return!t&&He(oe(n),"iterate",xi),n.size},has(n){const s=this.__v_raw,o=oe(s),a=oe(n);return t||(it(n,a)&&He(o,"has",n),He(o,"has",a)),n===a?s.has(n):s.has(n)||s.has(a)},forEach(n,s){const o=this,a=o.__v_raw,c=oe(a),l=e?Lo:t?zi:St;return!t&&He(c,"iterate",xi),a.forEach((u,d)=>n.call(s,l(u),l(d),o))}};return Fe(i,t?{add:Rn("add"),set:Rn("set"),delete:Rn("delete"),clear:Rn("clear")}:{add(n){!e&&!gt(n)&&!Zt(n)&&(n=oe(n));const s=oe(this);return An(s).has.call(s,n)||(s.add(n),Xt(s,"add",n,n)),this},set(n,s){!e&&!gt(s)&&!Zt(s)&&(s=oe(s));const o=oe(this),{has:a,get:c}=An(o);let l=a.call(o,n);l||(n=oe(n),l=a.call(o,n));const u=c.call(o,n);return o.set(n,s),l?it(s,u)&&Xt(o,"set",n,s):Xt(o,"add",n,s),this},delete(n){const s=oe(this),{has:o,get:a}=An(s);let c=o.call(s,n);c||(n=oe(n),c=o.call(s,n)),a&&a.call(s,n);const l=s.delete(n);return c&&Xt(s,"delete",n,void 0),l},clear(){const n=oe(this),s=n.size!==0,o=n.clear();return s&&Xt(n,"clear",void 0,void 0),o}}),["keys","values","entries",Symbol.iterator].forEach(n=>{i[n]=ty(n,t,e)}),i}function Tn(t,e){const i=iy(t,e);return(r,n,s)=>n==="__v_isReactive"?!t:n==="__v_isReadonly"?t:n==="__v_raw"?r:Reflect.get(ue(i,n)&&n in r?i:r,n,s)}const ry={get:Tn(!1,!1)},ny={get:Tn(!1,!0)},sy={get:Tn(!0,!1)},oy={get:Tn(!0,!0)},Gc=new WeakMap,Qc=new WeakMap,Yc=new WeakMap,Xc=new WeakMap;function ay(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function ly(t){return t.__v_skip||!Object.isExtensible(t)?0:ay(Nm(t))}function No(t){return Zt(t)?t:On(t,!1,Xm,ry,Gc)}function cy(t){return On(t,!1,Zm,ny,Qc)}function Mo(t){return On(t,!0,Jm,sy,Yc)}function q0(t){return On(t,!0,ey,oy,Xc)}function On(t,e,i,r,n){if(!ke(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const s=ly(t);if(s===0)return t;const o=n.get(t);if(o)return o;const a=new Proxy(t,s===2?r:i);return n.set(t,a),a}function ki(t){return Zt(t)?ki(t.__v_raw):!!(t&&t.__v_isReactive)}function Zt(t){return!!(t&&t.__v_isReadonly)}function gt(t){return!!(t&&t.__v_isShallow)}function Do(t){return t?!!t.__v_raw:!1}function oe(t){const e=t&&t.__v_raw;return e?oe(e):t}function uy(t){return!ue(t,"__v_skip")&&Object.isExtensible(t)&&Ic(t,"__v_skip",!0),t}const St=t=>ke(t)?No(t):t,zi=t=>ke(t)?Mo(t):t;function De(t){return t?t.__v_isRef===!0:!1}function Qe(t){return Zc(t,!1)}function Jc(t){return Zc(t,!0)}function Zc(t,e){return De(t)?t:new dy(t,e)}class dy{constructor(e,i){this.dep=new Cn,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=i?e:oe(e),this._value=i?e:St(e),this.__v_isShallow=i}get value(){return this.dep.track(),this._value}set value(e){const i=this._rawValue,r=this.__v_isShallow||gt(e)||Zt(e);e=r?e:oe(e),it(e,i)&&(this._rawValue=e,this._value=r?e:St(e),this.dep.trigger())}}function Oe(t){return De(t)?t.value:t}const fy={get:(t,e,i)=>e==="__v_raw"?t:Oe(Reflect.get(t,e,i)),set:(t,e,i,r)=>{const n=t[e];return De(n)&&!De(i)?(n.value=i,!0):Reflect.set(t,e,i,r)}};function eu(t){return ki(t)?t:new Proxy(t,fy)}class hy{constructor(e){this.__v_isRef=!0,this._value=void 0;const i=this.dep=new Cn,{get:r,set:n}=e(i.track.bind(i),i.trigger.bind(i));this._get=r,this._set=n}get value(){return this._value=this._get()}set value(e){this._set(e)}}function py(t){return new hy(t)}class gy{constructor(e,i,r){this.fn=e,this.setter=i,this._value=void 0,this.dep=new Cn(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=Sr-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!i,this.isSSR=r}notify(){if(this.flags|=16,!(this.flags&8)&&be!==this)return Mc(this,!0),!0}get value(){const e=this.dep.track();return Uc(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}}function my(t,e,i=!1){let r,n;return Z(t)?r=t:(r=t.get,n=t.set),new gy(r,n,i)}const Ln={},Nn=new WeakMap;let Si;function yy(t,e=!1,i=Si){if(i){let r=Nn.get(i);r||Nn.set(i,r=[]),r.push(t)}}function by(t,e,i=le){const{immediate:r,deep:n,once:s,scheduler:o,augmentJob:a,call:c}=i,l=g=>n?g:gt(g)||n===!1||n===0?ei(g,1):ei(g);let u,d,y,p,h=!1,_=!1;if(De(t)?(d=()=>t.value,h=gt(t)):ki(t)?(d=()=>l(t),h=!0):J(t)?(_=!0,h=t.some(g=>ki(g)||gt(g)),d=()=>t.map(g=>{if(De(g))return g.value;if(ki(g))return l(g);if(Z(g))return c?c(g,2):g()})):Z(t)?e?d=c?()=>c(t,2):t:d=()=>{if(y){Mt();try{y()}finally{Dt()}}const g=Si;Si=u;try{return c?c(t,3,[p]):t(p)}finally{Si=g}}:d=Nt,e&&n){const g=d,w=n===!0?1/0:n;d=()=>ei(g(),w)}const k=zm(),P=()=>{u.stop(),k&&k.active&&vo(k.effects,u)};if(s&&e){const g=e;e=(...w)=>{g(...w),P()}}let b=_?new Array(t.length).fill(Ln):Ln;const m=g=>{if(!(!(u.flags&1)||!u.dirty&&!g))if(e){const w=u.run();if(n||h||(_?w.some((S,I)=>it(S,b[I])):it(w,b))){y&&y();const S=Si;Si=u;try{const I=[w,b===Ln?void 0:_&&b[0]===Ln?[]:b,p];b=w,c?c(e,3,I):e(...I)}finally{Si=S}}}else u.run()};return a&&a(m),u=new Lc(d),u.scheduler=o?()=>o(m,!1):m,p=g=>yy(g,!1,u),y=u.onStop=()=>{const g=Nn.get(u);if(g){if(c)c(g,4);else for(const w of g)w();Nn.delete(u)}},e?r?m(!0):b=u.run():o?o(m.bind(null,!0),!0):u.run(),P.pause=u.pause.bind(u),P.resume=u.resume.bind(u),P.stop=P,P}function ei(t,e=1/0,i){if(e<=0||!ke(t)||t.__v_skip||(i=i||new Map,(i.get(t)||0)>=e))return t;if(i.set(t,e),e--,De(t))ei(t.value,e,i);else if(J(t))for(let r=0;r<t.length;r++)ei(t[r],e,i);else if(Sc(t)||Bi(t))t.forEach(r=>{ei(r,e,i)});else if(Pc(t)){for(const r in t)ei(t[r],e,i);for(const r of Object.getOwnPropertySymbols(t))Object.prototype.propertyIsEnumerable.call(t,r)&&ei(t[r],e,i)}return t}const Pr=[];let jo=!1;function B0(t,...e){if(jo)return;jo=!0,Mt();const i=Pr.length?Pr[Pr.length-1].component:null,r=i&&i.appContext.config.warnHandler,n=vy();if(r)Wi(r,i,11,[t+e.map(s=>{var o,a;return(a=(o=s.toString)==null?void 0:o.call(s))!=null?a:JSON.stringify(s)}).join(""),i&&i.proxy,n.map(({vnode:s})=>`at <${Xu(i,s.type)}>`).join(`
22
22
  `),n]);else{const s=[`[Vue warn]: ${t}`,...e];n.length&&s.push(`
23
- `,...my(n))}Dt(),Do=!1}function gy(){let t=Pr[Pr.length-1];if(!t)return[];const e=[];for(;t;){const i=e[0];i&&i.vnode===t?i.recurseCount++:e.push({vnode:t,recurseCount:0});const r=t.component&&t.component.parent;t=r&&r.vnode}return e}function my(t){const e=[];return t.forEach((i,r)=>{e.push(...r===0?[]:[`
24
- `],...yy(i))}),e}function yy({vnode:t,recurseCount:e}){const i=e>0?`... (${e} recursive calls)`:"",r=t.component?t.component.parent==null:!1,n=` at <${Qu(t.component,t.type,r)}`,s=">"+i;return t.props?[n,...by(t.props),s]:[n+s]}function by(t){const e=[],i=Object.keys(t);return i.slice(0,3).forEach(r=>{e.push(...Zc(r,t[r]))}),i.length>3&&e.push(" ..."),e}function Zc(t,e,i){return Re(e)?(e=JSON.stringify(e),i?e:[`${t}=${e}`]):typeof e=="number"||typeof e=="boolean"||e==null?i?e:[`${t}=${e}`]:De(e)?(e=Zc(t,oe(e.value),!0),i?e:[`${t}=Ref<`,e,">"]):Z(e)?[`${t}=fn${e.name?`<${e.name}>`:""}`]:(e=oe(e),i?e:[`${t}=`,e])}function Wi(t,e,i,r){try{return r?t(...r):t()}catch(n){Cr(n,e,i)}}function jt(t,e,i,r){if(Z(t)){const n=Wi(t,e,i,r);return n&&kc(n)&&n.catch(s=>{Cr(s,e,i)}),n}if(J(t)){const n=[];for(let s=0;s<t.length;s++)n.push(jt(t[s],e,i,r));return n}}function Cr(t,e,i,r=!0){const n=e?e.vnode:null,{errorHandler:s,throwUnhandledErrorInProduction:o}=e&&e.appContext.config||le;if(e){let a=e.parent;const c=e.proxy,l=`https://vuejs.org/error-reference/#runtime-${i}`;for(;a;){const u=a.ec;if(u){for(let d=0;d<u.length;d++)if(u[d](t,c,l)===!1)return}a=a.parent}if(s){Mt(),Wi(s,null,10,[t,c,l]),Dt();return}}vy(t,i,n,r,o)}function vy(t,e,i,r=!0,n=!1){if(n)throw t}const Ye=[];let Ut=-1;const Ki=[];let di=null,Vi=0;const eu=Promise.resolve();let Mn=null;function Ir(t){const e=Mn||eu;return t?e.then(this?t.bind(this):t):e}function wy(t){let e=Ut+1,i=Ye.length;for(;e<i;){const r=e+i>>>1,n=Ye[r],s=Rr(n);s<t||s===t&&n.flags&2?e=r+1:i=r}return e}function jo(t){if(!(t.flags&1)){const e=Rr(t),i=Ye[Ye.length-1];!i||!(t.flags&2)&&e>=Rr(i)?Ye.push(t):Ye.splice(wy(e),0,t),t.flags|=1,tu()}}function tu(){Mn||(Mn=eu.then(nu))}function _y(t){J(t)?Ki.push(...t):di&&t.id===-1?di.splice(Vi+1,0,t):t.flags&1||(Ki.push(t),t.flags|=1),tu()}function iu(t,e,i=Ut+1){for(;i<Ye.length;i++){const r=Ye[i];if(r&&r.flags&2){if(t&&r.id!==t.uid)continue;Ye.splice(i,1),i--,r.flags&4&&(r.flags&=-2),r(),r.flags&4||(r.flags&=-2)}}}function ru(t){if(Ki.length){const e=[...new Set(Ki)].sort((i,r)=>Rr(i)-Rr(r));if(Ki.length=0,di){di.push(...e);return}for(di=e,Vi=0;Vi<di.length;Vi++){const i=di[Vi];i.flags&4&&(i.flags&=-2),i.flags&8||i(),i.flags&=-2}di=null,Vi=0}}const Rr=t=>t.id==null?t.flags&2?-1:1/0:t.id;function nu(t){try{for(Ut=0;Ut<Ye.length;Ut++){const e=Ye[Ut];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),Wi(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;Ut<Ye.length;Ut++){const e=Ye[Ut];e&&(e.flags&=-2)}Ut=-1,Ye.length=0,ru(),Mn=null,(Ye.length||Ki.length)&&nu()}}let ze=null,su=null;function Dn(t){const e=ze;return ze=t,su=t&&t.type.__scopeId||null,e}function Ar(t,e=ze,i){if(!e||t._n)return t;const r=(...n)=>{r._d&&qu(-1);const s=Dn(e);let o;try{o=t(...n)}finally{Dn(s),r._d&&qu(1)}return o};return r._n=!0,r._c=!0,r._d=!0,r}function ou(t,e){if(ze===null)return t;const i=Gn(ze),r=t.dirs||(t.dirs=[]);for(let n=0;n<e.length;n++){let[s,o,a,c=le]=e[n];s&&(Z(s)&&(s={mounted:s,updated:s}),s.deep&&ei(o),r.push({dir:s,instance:i,value:o,oldValue:void 0,arg:a,modifiers:c}))}return t}function Ei(t,e,i,r){const n=t.dirs,s=e&&e.dirs;for(let o=0;o<n.length;o++){const a=n[o];s&&(a.oldValue=s[o].value);let c=a.dir[r];c&&(Mt(),jt(c,i,8,[t.el,a,t,e]),Dt())}}function au(t,e){if(Ke){let i=Ke.provides;const r=Ke.parent&&Ke.parent.provides;r===i&&(i=Ke.provides=Object.create(r)),i[t]=e}}function Tr(t,e,i=!1){const r=ra();if(r||Yi){let n=Yi?Yi._context.provides:r?r.parent==null||r.ce?r.vnode.appContext&&r.vnode.appContext.provides:r.parent.provides:void 0;if(n&&t in n)return n[t];if(arguments.length>1)return i&&Z(e)?e.call(r&&r.proxy):e}}const xy=Symbol.for("v-scx"),ky=()=>Tr(xy);function Sy(t,e){return Uo(t,null,{flush:"sync"})}function Gi(t,e,i){return Uo(t,e,i)}function Uo(t,e,i=le){const{immediate:r,deep:n,flush:s,once:o}=i,a=Fe({},i),c=e&&r||!e&&s!=="post";let l;if(Ji){if(s==="sync"){const p=ky();l=p.__watcherHandles||(p.__watcherHandles=[])}else if(!c){const p=()=>{};return p.stop=Nt,p.resume=Nt,p.pause=Nt,p}}const u=Ke;a.call=(p,h,_)=>jt(p,u,h,_);let d=!1;s==="post"?a.scheduler=p=>{at(p,u&&u.suspense)}:s!=="sync"&&(d=!0,a.scheduler=(p,h)=>{h?p():jo(p)}),a.augmentJob=p=>{e&&(p.flags|=4),d&&(p.flags|=2,u&&(p.id=u.uid,p.i=u))};const y=py(t,e,a);return Ji&&(l?l.push(y):c&&y()),y}function Ey(t,e,i){const r=this.proxy,n=Re(t)?t.includes(".")?lu(r,t):()=>r[t]:t.bind(r,r);let s;Z(e)?s=e:(s=e.handler,i=e);const o=qr(this),a=Uo(n,s.bind(r),i);return o(),a}function lu(t,e){const i=e.split(".");return()=>{let r=t;for(let n=0;n<i.length&&r;n++)r=r[i[n]];return r}}const $y=Symbol("_vte"),Py=t=>t.__isTeleport,Cy=Symbol("_leaveCb");function Fo(t,e){t.shapeFlag&6&&t.component?(t.transition=e,Fo(t.component.subTree,e)):t.shapeFlag&128?(t.ssContent.transition=e.clone(t.ssContent),t.ssFallback.transition=e.clone(t.ssFallback)):t.transition=e}function $i(t,e){return Z(t)?Fe({name:t.name},e,{setup:t}):t}function qo(t){t.ids=[t.ids[0]+t.ids[2]+++"-",0,0]}function cu(t){const e=ra(),i=Yc(null);if(e){const n=e.refs===le?e.refs={}:e.refs;Object.defineProperty(n,t,{enumerable:!0,get:()=>i.value,set:s=>i.value=s})}return i}const jn=new WeakMap;function Or(t,e,i,r,n=!1){if(J(t)){t.forEach((h,_)=>Or(h,e&&(J(e)?e[_]:e),i,r,n));return}if(Qi(r)&&!n){r.shapeFlag&512&&r.type.__asyncResolved&&r.component.subTree.component&&Or(t,e,i,r.component.subTree);return}const s=r.shapeFlag&4?Gn(r.component):r.el,o=n?null:s,{i:a,r:c}=t,l=e&&e.r,u=a.refs===le?a.refs={}:a.refs,d=a.setupState,y=oe(d),p=d===le?_c:h=>ue(y,h);if(l!=null&&l!==c){if(uu(e),Re(l))u[l]=null,p(l)&&(d[l]=null);else if(De(l)){l.value=null;const h=e;h.k&&(u[h.k]=null)}}if(Z(c))Wi(c,a,12,[o,u]);else{const h=Re(c),_=De(c);if(h||_){const k=()=>{if(t.f){const P=h?p(c)?d[c]:u[c]:c.value;if(n)J(P)&&bo(P,s);else if(J(P))P.includes(s)||P.push(s);else if(h)u[c]=[s],p(c)&&(d[c]=u[c]);else{const b=[s];c.value=b,t.k&&(u[t.k]=b)}}else h?(u[c]=o,p(c)&&(d[c]=o)):_&&(c.value=o,t.k&&(u[t.k]=o))};if(o){const P=()=>{k(),jn.delete(t)};P.id=-1,jn.set(t,P),at(P,i)}else uu(t),k()}}}function uu(t){const e=jn.get(t);e&&(e.flags|=8,jn.delete(t))}const du=t=>t.nodeType===8;Pn().requestIdleCallback,Pn().cancelIdleCallback;function Iy(t,e){if(du(t)&&t.data==="["){let i=1,r=t.nextSibling;for(;r;){if(r.nodeType===1){if(e(r)===!1)break}else if(du(r))if(r.data==="]"){if(--i===0)break}else r.data==="["&&i++;r=r.nextSibling}}else e(t)}const Qi=t=>!!t.type.__asyncLoader;function Ry(t){Z(t)&&(t={loader:t});const{loader:e,loadingComponent:i,errorComponent:r,delay:n=200,hydrate:s,timeout:o,suspensible:a=!0,onError:c}=t;let l=null,u,d=0;const y=()=>(d++,l=null,p()),p=()=>{let h;return l||(h=l=e().catch(_=>{if(_=_ instanceof Error?_:new Error(String(_)),c)return new Promise((k,P)=>{c(_,()=>k(y()),()=>P(_),d+1)});throw _}).then(_=>h!==l&&l?l:(_&&(_.__esModule||_[Symbol.toStringTag]==="Module")&&(_=_.default),u=_,_)))};return $i({name:"AsyncComponentWrapper",__asyncLoader:p,__asyncHydrate(h,_,k){let P=!1;(_.bu||(_.bu=[])).push(()=>P=!0);const b=()=>{P||k()},m=s?()=>{const g=s(b,w=>Iy(h,w));g&&(_.bum||(_.bum=[])).push(g)}:b;u?m():p().then(()=>!_.isUnmounted&&m())},get __asyncResolved(){return u},setup(){const h=Ke;if(qo(h),u)return()=>Un(u,h);const _=m=>{l=null,Cr(m,h,13,!r)};if(a&&h.suspense||Ji)return p().then(m=>()=>Un(m,h)).catch(m=>(_(m),()=>r?Ne(r,{error:m}):null));const k=Qe(!1),P=Qe(),b=Qe(!!n);return n&&setTimeout(()=>{b.value=!1},n),o!=null&&setTimeout(()=>{if(!k.value&&!P.value){const m=new Error(`Async component timed out after ${o}ms.`);_(m),P.value=m}},o),p().then(()=>{k.value=!0,h.parent&&Bo(h.parent.vnode)&&h.parent.update()}).catch(m=>{_(m),P.value=m}),()=>{if(k.value&&u)return Un(u,h);if(P.value&&r)return Ne(r,{error:P.value});if(i&&!b.value)return Un(i,h)}}})}function Un(t,e){const{ref:i,props:r,children:n,ce:s}=e.vnode,o=Ne(t,r,n);return o.ref=i,o.ce=s,delete e.vnode.ce,o}const Bo=t=>t.type.__isKeepAlive;function Ay(t,e){fu(t,"a",e)}function Ty(t,e){fu(t,"da",e)}function fu(t,e,i=Ke){const r=t.__wdc||(t.__wdc=()=>{let n=i;for(;n;){if(n.isDeactivated)return;n=n.parent}return t()});if(Fn(e,r,i),i){let n=i.parent;for(;n&&n.parent;)Bo(n.parent.vnode)&&Oy(r,e,i,n),n=n.parent}}function Oy(t,e,i,r){const n=Fn(e,t,r,!0);zo(()=>{bo(r[e],n)},i)}function Fn(t,e,i=Ke,r=!1){if(i){const n=i[t]||(i[t]=[]),s=e.__weh||(e.__weh=(...o)=>{Mt();const a=qr(i),c=jt(e,i,t,o);return a(),Dt(),c});return r?n.unshift(s):n.push(s),s}}const ti=t=>(e,i=Ke)=>{(!Ji||t==="sp")&&Fn(t,(...r)=>e(...r),i)},hu=ti("bm"),Lr=ti("m"),Ly=ti("bu"),Ny=ti("u"),Ho=ti("bum"),zo=ti("um"),My=ti("sp"),Dy=ti("rtg"),jy=ti("rtc");function Uy(t,e=Ke){Fn("ec",t,e)}const Fy=Symbol.for("v-ndc");function Wo(t,e,i,r){let n;const s=i,o=J(t);if(o||Re(t)){const a=o&&ki(t);let c=!1,l=!1;a&&(c=!gt(t),l=Zt(t),t=In(t)),n=new Array(t.length);for(let u=0,d=t.length;u<d;u++)n[u]=e(c?l?zi(St(t[u])):St(t[u]):t[u],u,void 0,s)}else if(typeof t=="number"){n=new Array(t);for(let a=0;a<t;a++)n[a]=e(a+1,a,void 0,s)}else if(ke(t))if(t[Symbol.iterator])n=Array.from(t,(a,c)=>e(a,c,void 0,s));else{const a=Object.keys(t);n=new Array(a.length);for(let c=0,l=a.length;c<l;c++){const u=a[c];n[c]=e(t[u],u,c,s)}}else n=[];return n}function qy(t,e,i={},r,n){if(ze.ce||ze.parent&&Qi(ze.parent)&&ze.parent.ce){const l=Object.keys(i).length>0;return de(),Wn(We,null,[Ne("slot",i,r)],l?-2:64)}let s=t[e];s&&s._c&&(s._d=!1),de();const o=s&&pu(s(i)),a=i.key||o&&o.key,c=Wn(We,{key:(a&&!Qt(a)?a:`_${e}`)+(!o&&r?"_fb":"")},o||[],o&&t._===1?64:-2);return c.scopeId&&(c.slotScopeIds=[c.scopeId+"-s"]),s&&s._c&&(s._d=!0),c}function pu(t){return t.some(e=>ta(e)?!(e.type===ii||e.type===We&&!pu(e.children)):!0)?t:null}const Ko=t=>t?Ku(t)?Gn(t):Ko(t.parent):null,Nr=Fe(Object.create(null),{$:t=>t,$el:t=>t.vnode.el,$data:t=>t.data,$props:t=>t.props,$attrs:t=>t.attrs,$slots:t=>t.slots,$refs:t=>t.refs,$parent:t=>Ko(t.parent),$root:t=>Ko(t.root),$host:t=>t.ce,$emit:t=>t.emit,$options:t=>bu(t),$forceUpdate:t=>t.f||(t.f=()=>{jo(t.update)}),$nextTick:t=>t.n||(t.n=Ir.bind(t.proxy)),$watch:t=>Ey.bind(t)}),Vo=(t,e)=>t!==le&&!t.__isScriptSetup&&ue(t,e),By={get({_:t},e){if(e==="__v_skip")return!0;const{ctx:i,setupState:r,data:n,props:s,accessCache:o,type:a,appContext:c}=t;if(e[0]!=="$"){const y=o[e];if(y!==void 0)switch(y){case 1:return r[e];case 2:return n[e];case 4:return i[e];case 3:return s[e]}else{if(Vo(r,e))return o[e]=1,r[e];if(n!==le&&ue(n,e))return o[e]=2,n[e];if(ue(s,e))return o[e]=3,s[e];if(i!==le&&ue(i,e))return o[e]=4,i[e];Go&&(o[e]=0)}}const l=Nr[e];let u,d;if(l)return e==="$attrs"&&He(t.attrs,"get",""),l(t);if((u=a.__cssModules)&&(u=u[e]))return u;if(i!==le&&ue(i,e))return o[e]=4,i[e];if(d=c.config.globalProperties,ue(d,e))return d[e]},set({_:t},e,i){const{data:r,setupState:n,ctx:s}=t;return Vo(n,e)?(n[e]=i,!0):r!==le&&ue(r,e)?(r[e]=i,!0):ue(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(s[e]=i,!0)},has({_:{data:t,setupState:e,accessCache:i,ctx:r,appContext:n,props:s,type:o}},a){let c;return!!(i[a]||t!==le&&a[0]!=="$"&&ue(t,a)||Vo(e,a)||ue(s,a)||ue(r,a)||ue(Nr,a)||ue(n.config.globalProperties,a)||(c=o.__cssModules)&&c[a])},defineProperty(t,e,i){return i.get!=null?t._.accessCache[e]=0:ue(i,"value")&&this.set(t,e,i.value,null),Reflect.defineProperty(t,e,i)}};function qn(t){return J(t)?t.reduce((e,i)=>(e[i]=null,e),{}):t}function gu(t,e){return!t||!e?t||e:J(t)&&J(e)?t.concat(e):Fe({},qn(t),qn(e))}let Go=!0;function Hy(t){const e=bu(t),i=t.proxy,r=t.ctx;Go=!1,e.beforeCreate&&mu(e.beforeCreate,t,"bc");const{data:n,computed:s,methods:o,watch:a,provide:c,inject:l,created:u,beforeMount:d,mounted:y,beforeUpdate:p,updated:h,activated:_,deactivated:k,beforeDestroy:P,beforeUnmount:b,destroyed:m,unmounted:g,render:w,renderTracked:S,renderTriggered:I,errorCaptured:F,serverPrefetch:N,expose:G,inheritAttrs:K,components:qe,directives:fe,filters:Ae}=e;if(l&&zy(l,r,null),o)for(const me in o){const ge=o[me];Z(ge)&&(r[me]=ge.bind(i))}if(n){const me=n.call(i,i);ke(me)&&(t.data=Lo(me))}if(Go=!0,s)for(const me in s){const ge=s[me],ni=Z(ge)?ge.bind(i,i):Z(ge.get)?ge.get.bind(i,i):Nt,ar=!Z(ge)&&Z(ge.set)?ge.set.bind(i):Nt,si=Bt({get:ni,set:ar});Object.defineProperty(r,me,{enumerable:!0,configurable:!0,get:()=>si.value,set:Pt=>si.value=Pt})}if(a)for(const me in a)yu(a[me],r,i,me);if(c){const me=Z(c)?c.call(i):c;Reflect.ownKeys(me).forEach(ge=>{au(ge,me[ge])})}u&&mu(u,t,"c");function ae(me,ge){J(ge)?ge.forEach(ni=>me(ni.bind(i))):ge&&me(ge.bind(i))}if(ae(hu,d),ae(Lr,y),ae(Ly,p),ae(Ny,h),ae(Ay,_),ae(Ty,k),ae(Uy,F),ae(jy,S),ae(Dy,I),ae(Ho,b),ae(zo,g),ae(My,N),J(G))if(G.length){const me=t.exposed||(t.exposed={});G.forEach(ge=>{Object.defineProperty(me,ge,{get:()=>i[ge],set:ni=>i[ge]=ni,enumerable:!0})})}else t.exposed||(t.exposed={});w&&t.render===Nt&&(t.render=w),K!=null&&(t.inheritAttrs=K),qe&&(t.components=qe),fe&&(t.directives=fe),N&&qo(t)}function zy(t,e,i=Nt){J(t)&&(t=Qo(t));for(const r in t){const n=t[r];let s;ke(n)?"default"in n?s=Tr(n.from||r,n.default,!0):s=Tr(n.from||r):s=Tr(n),De(s)?Object.defineProperty(e,r,{enumerable:!0,configurable:!0,get:()=>s.value,set:o=>s.value=o}):e[r]=s}}function mu(t,e,i){jt(J(t)?t.map(r=>r.bind(e.proxy)):t.bind(e.proxy),e,i)}function yu(t,e,i,r){let n=r.includes(".")?lu(i,r):()=>i[r];if(Re(t)){const s=e[t];Z(s)&&Gi(n,s)}else if(Z(t))Gi(n,t.bind(i));else if(ke(t))if(J(t))t.forEach(s=>yu(s,e,i,r));else{const s=Z(t.handler)?t.handler.bind(i):e[t.handler];Z(s)&&Gi(n,s,t)}}function bu(t){const e=t.type,{mixins:i,extends:r}=e,{mixins:n,optionsCache:s,config:{optionMergeStrategies:o}}=t.appContext,a=s.get(e);let c;return a?c=a:!n.length&&!i&&!r?c=e:(c={},n.length&&n.forEach(l=>Bn(c,l,o,!0)),Bn(c,e,o)),ke(e)&&s.set(e,c),c}function Bn(t,e,i,r=!1){const{mixins:n,extends:s}=e;s&&Bn(t,s,i,!0),n&&n.forEach(o=>Bn(t,o,i,!0));for(const o in e)if(!(r&&o==="expose")){const a=Wy[o]||i&&i[o];t[o]=a?a(t[o],e[o]):e[o]}return t}const Wy={data:vu,props:wu,emits:wu,methods:Mr,computed:Mr,beforeCreate:Xe,created:Xe,beforeMount:Xe,mounted:Xe,beforeUpdate:Xe,updated:Xe,beforeDestroy:Xe,beforeUnmount:Xe,destroyed:Xe,unmounted:Xe,activated:Xe,deactivated:Xe,errorCaptured:Xe,serverPrefetch:Xe,components:Mr,directives:Mr,watch:Vy,provide:vu,inject:Ky};function vu(t,e){return e?t?function(){return Fe(Z(t)?t.call(this,this):t,Z(e)?e.call(this,this):e)}:e:t}function Ky(t,e){return Mr(Qo(t),Qo(e))}function Qo(t){if(J(t)){const e={};for(let i=0;i<t.length;i++)e[t[i]]=t[i];return e}return t}function Xe(t,e){return t?[...new Set([].concat(t,e))]:e}function Mr(t,e){return t?Fe(Object.create(null),t,e):e}function wu(t,e){return t?J(t)&&J(e)?[...new Set([...t,...e])]:Fe(Object.create(null),qn(t),qn(e??{})):e}function Vy(t,e){if(!t)return e;if(!e)return t;const i=Fe(Object.create(null),t);for(const r in e)i[r]=Xe(t[r],e[r]);return i}function _u(){return{app:null,config:{isNativeTag:_c,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}let Gy=0;function Qy(t,e){return function(r,n=null){Z(r)||(r=Fe({},r)),n!=null&&!ke(n)&&(n=null);const s=_u(),o=new WeakSet,a=[];let c=!1;const l=s.app={_uid:Gy++,_component:r,_props:n,_container:null,_context:s,_instance:null,version:Pb,get config(){return s.config},set config(u){},use(u,...d){return o.has(u)||(u&&Z(u.install)?(o.add(u),u.install(l,...d)):Z(u)&&(o.add(u),u(l,...d))),l},mixin(u){return s.mixins.includes(u)||s.mixins.push(u),l},component(u,d){return d?(s.components[u]=d,l):s.components[u]},directive(u,d){return d?(s.directives[u]=d,l):s.directives[u]},mount(u,d,y){if(!c){const p=l._ceVNode||Ne(r,n);return p.appContext=s,y===!0?y="svg":y===!1&&(y=void 0),t(p,u,y),c=!0,l._container=u,u.__vue_app__=l,Gn(p.component)}},onUnmount(u){a.push(u)},unmount(){c&&(jt(a,l._instance,16),t(null,l._container),delete l._container.__vue_app__)},provide(u,d){return s.provides[u]=d,l},runWithContext(u){const d=Yi;Yi=l;try{return u()}finally{Yi=d}}};return l}}let Yi=null;function xu(t,e,i=le){const r=ra(),n=Yt(e),s=ci(e),o=ku(t,n),a=uy((c,l)=>{let u,d=le,y;return Sy(()=>{const p=t[n];it(u,p)&&(u=p,l())}),{get(){return c(),i.get?i.get(u):u},set(p){const h=i.set?i.set(p):p;if(!it(h,u)&&!(d!==le&&it(p,d)))return;const _=r.vnode.props;_&&(e in _||n in _||s in _)&&(`onUpdate:${e}`in _||`onUpdate:${n}`in _||`onUpdate:${s}`in _)||(u=p,l()),r.emit(`update:${e}`,h),it(p,h)&&it(p,d)&&!it(h,y)&&l(),d=p,y=h}}});return a[Symbol.iterator]=()=>{let c=0;return{next(){return c<2?{value:c++?o||le:a,done:!1}:{done:!0}}}},a}const ku=(t,e)=>e==="modelValue"||e==="model-value"?t.modelModifiers:t[`${e}Modifiers`]||t[`${Yt(e)}Modifiers`]||t[`${ci(e)}Modifiers`];function Yy(t,e,...i){if(t.isUnmounted)return;const r=t.vnode.props||le;let n=i;const s=e.startsWith("update:"),o=s&&ku(r,e.slice(7));o&&(o.trim&&(n=i.map(u=>Re(u)?u.trim():u)),o.number&&(n=i.map(_o)));let a,c=r[a=wo(e)]||r[a=wo(Yt(e))];!c&&s&&(c=r[a=wo(ci(e))]),c&&jt(c,t,6,n);const l=r[a+"Once"];if(l){if(!t.emitted)t.emitted={};else if(t.emitted[a])return;t.emitted[a]=!0,jt(l,t,6,n)}}const Xy=new WeakMap;function Su(t,e,i=!1){const r=i?Xy:e.emitsCache,n=r.get(t);if(n!==void 0)return n;const s=t.emits;let o={},a=!1;if(!Z(t)){const c=l=>{const u=Su(l,e,!0);u&&(a=!0,Fe(o,u))};!i&&e.mixins.length&&e.mixins.forEach(c),t.extends&&c(t.extends),t.mixins&&t.mixins.forEach(c)}return!s&&!a?(ke(t)&&r.set(t,null),null):(J(s)?s.forEach(c=>o[c]=null):Fe(o,s),ke(t)&&r.set(t,o),o)}function Hn(t,e){return!t||!kn(e)?!1:(e=e.slice(2).replace(/Once$/,""),ue(t,e[0].toLowerCase()+e.slice(1))||ue(t,ci(e))||ue(t,e))}function U0(){}function Eu(t){const{type:e,vnode:i,proxy:r,withProxy:n,propsOptions:[s],slots:o,attrs:a,emit:c,render:l,renderCache:u,props:d,data:y,setupState:p,ctx:h,inheritAttrs:_}=t,k=Dn(t);let P,b;try{if(i.shapeFlag&4){const g=n||r,w=g;P=Ft(l.call(w,g,u,d,p,y,h)),b=a}else{const g=e;P=Ft(g.length>1?g(d,{attrs:a,slots:o,emit:c}):g(d,null)),b=e.props?a:Jy(a)}}catch(g){Dr.length=0,Cr(g,t,1),P=Ne(ii)}let m=P;if(b&&_!==!1){const g=Object.keys(b),{shapeFlag:w}=m;g.length&&w&7&&(s&&g.some(yo)&&(b=Zy(b,s)),m=Xi(m,b,!1,!0))}return i.dirs&&(m=Xi(m,null,!1,!0),m.dirs=m.dirs?m.dirs.concat(i.dirs):i.dirs),i.transition&&Fo(m,i.transition),P=m,Dn(k),P}const Jy=t=>{let e;for(const i in t)(i==="class"||i==="style"||kn(i))&&((e||(e={}))[i]=t[i]);return e},Zy=(t,e)=>{const i={};for(const r in t)(!yo(r)||!(r.slice(9)in e))&&(i[r]=t[r]);return i};function eb(t,e,i){const{props:r,children:n,component:s}=t,{props:o,children:a,patchFlag:c}=e,l=s.emitsOptions;if(e.dirs||e.transition)return!0;if(i&&c>=0){if(c&1024)return!0;if(c&16)return r?$u(r,o,l):!!o;if(c&8){const u=e.dynamicProps;for(let d=0;d<u.length;d++){const y=u[d];if(o[y]!==r[y]&&!Hn(l,y))return!0}}}else return(n||a)&&(!a||!a.$stable)?!0:r===o?!1:r?o?$u(r,o,l):!0:!!o;return!1}function $u(t,e,i){const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!0;for(let n=0;n<r.length;n++){const s=r[n];if(e[s]!==t[s]&&!Hn(i,s))return!0}return!1}function tb({vnode:t,parent:e},i){for(;e;){const r=e.subTree;if(r.suspense&&r.suspense.activeBranch===t&&(r.el=t.el),r===t)(t=e.vnode).el=i,e=e.parent;else break}}const Pu={},Cu=()=>Object.create(Pu),Iu=t=>Object.getPrototypeOf(t)===Pu;function ib(t,e,i,r=!1){const n={},s=Cu();t.propsDefaults=Object.create(null),Ru(t,e,n,s);for(const o in t.propsOptions[0])o in n||(n[o]=void 0);i?t.props=r?n:sy(n):t.type.props?t.props=n:t.props=s,t.attrs=s}function rb(t,e,i,r){const{props:n,attrs:s,vnode:{patchFlag:o}}=t,a=oe(n),[c]=t.propsOptions;let l=!1;if((r||o>0)&&!(o&16)){if(o&8){const u=t.vnode.dynamicProps;for(let d=0;d<u.length;d++){let y=u[d];if(Hn(t.emitsOptions,y))continue;const p=e[y];if(c)if(ue(s,y))p!==s[y]&&(s[y]=p,l=!0);else{const h=Yt(y);n[h]=Yo(c,a,h,p,t,!1)}else p!==s[y]&&(s[y]=p,l=!0)}}}else{Ru(t,e,n,s)&&(l=!0);let u;for(const d in a)(!e||!ue(e,d)&&((u=ci(d))===d||!ue(e,u)))&&(c?i&&(i[d]!==void 0||i[u]!==void 0)&&(n[d]=Yo(c,a,d,void 0,t,!0)):delete n[d]);if(s!==a)for(const d in s)(!e||!ue(e,d))&&(delete s[d],l=!0)}l&&Xt(t.attrs,"set","")}function Ru(t,e,i,r){const[n,s]=t.propsOptions;let o=!1,a;if(e)for(let c in e){if(_r(c))continue;const l=e[c];let u;n&&ue(n,u=Yt(c))?!s||!s.includes(u)?i[u]=l:(a||(a={}))[u]=l:Hn(t.emitsOptions,c)||(!(c in r)||l!==r[c])&&(r[c]=l,o=!0)}if(s){const c=oe(i),l=a||le;for(let u=0;u<s.length;u++){const d=s[u];i[d]=Yo(n,c,d,l[d],t,!ue(l,d))}}return o}function Yo(t,e,i,r,n,s){const o=t[i];if(o!=null){const a=ue(o,"default");if(a&&r===void 0){const c=o.default;if(o.type!==Function&&!o.skipFactory&&Z(c)){const{propsDefaults:l}=n;if(i in l)r=l[i];else{const u=qr(n);r=l[i]=c.call(null,e),u()}}else r=c;n.ce&&n.ce._setProp(i,r)}o[0]&&(s&&!a?r=!1:o[1]&&(r===""||r===ci(i))&&(r=!0))}return r}const nb=new WeakMap;function Au(t,e,i=!1){const r=i?nb:e.propsCache,n=r.get(t);if(n)return n;const s=t.props,o={},a=[];let c=!1;if(!Z(t)){const u=d=>{c=!0;const[y,p]=Au(d,e,!0);Fe(o,y),p&&a.push(...p)};!i&&e.mixins.length&&e.mixins.forEach(u),t.extends&&u(t.extends),t.mixins&&t.mixins.forEach(u)}if(!s&&!c)return ke(t)&&r.set(t,qi),qi;if(J(s))for(let u=0;u<s.length;u++){const d=Yt(s[u]);Tu(d)&&(o[d]=le)}else if(s)for(const u in s){const d=Yt(u);if(Tu(d)){const y=s[u],p=o[d]=J(y)||Z(y)?{type:y}:Fe({},y),h=p.type;let _=!1,k=!0;if(J(h))for(let P=0;P<h.length;++P){const b=h[P],m=Z(b)&&b.name;if(m==="Boolean"){_=!0;break}else m==="String"&&(k=!1)}else _=Z(h)&&h.name==="Boolean";p[0]=_,p[1]=k,(_||ue(p,"default"))&&a.push(d)}}const l=[o,a];return ke(t)&&r.set(t,l),l}function Tu(t){return t[0]!=="$"&&!_r(t)}const Xo=t=>t==="_"||t==="_ctx"||t==="$stable",Jo=t=>J(t)?t.map(Ft):[Ft(t)],sb=(t,e,i)=>{if(e._n)return e;const r=Ar((...n)=>Jo(e(...n)),i);return r._c=!1,r},Ou=(t,e,i)=>{const r=t._ctx;for(const n in t){if(Xo(n))continue;const s=t[n];if(Z(s))e[n]=sb(n,s,r);else if(s!=null){const o=Jo(s);e[n]=()=>o}}},Lu=(t,e)=>{const i=Jo(e);t.slots.default=()=>i},Nu=(t,e,i)=>{for(const r in e)(i||!Xo(r))&&(t[r]=e[r])},ob=(t,e,i)=>{const r=t.slots=Cu();if(t.vnode.shapeFlag&32){const n=e._;n?(Nu(r,e,i),i&&Pc(r,"_",n,!0)):Ou(e,r)}else e&&Lu(t,e)},ab=(t,e,i)=>{const{vnode:r,slots:n}=t;let s=!0,o=le;if(r.shapeFlag&32){const a=e._;a?i&&a===1?s=!1:Nu(n,e,i):(s=!e.$stable,Ou(e,n)),o=e}else e&&(Lu(t,e),o={default:1});if(s)for(const a in n)!Xo(a)&&o[a]==null&&delete n[a]},at=fb;function lb(t){return cb(t)}function cb(t,e){const i=Pn();i.__VUE__=!0;const{insert:r,remove:n,patchProp:s,createElement:o,createText:a,createComment:c,setText:l,setElementText:u,parentNode:d,nextSibling:y,setScopeId:p=Nt,insertStaticContent:h}=t,_=(v,x,E,T=null,A=null,O=null,B=void 0,q=null,D=!!x.dynamicChildren)=>{if(v===x)return;v&&!Ur(v,x)&&(T=H(v),Pt(v,A,O,!0),v=null),x.patchFlag===-2&&(D=!1,x.dynamicChildren=null);const{type:L,ref:Q,shapeFlag:z}=x;switch(L){case zn:k(v,x,E,T);break;case ii:P(v,x,E,T);break;case ea:v==null&&b(x,E,T,B);break;case We:qe(v,x,E,T,A,O,B,q,D);break;default:z&1?w(v,x,E,T,A,O,B,q,D):z&6?fe(v,x,E,T,A,O,B,q,D):(z&64||z&128)&&L.process(v,x,E,T,A,O,B,q,D,we)}Q!=null&&A?Or(Q,v&&v.ref,O,x||v,!x):Q==null&&v&&v.ref!=null&&Or(v.ref,null,O,v,!0)},k=(v,x,E,T)=>{if(v==null)r(x.el=a(x.children),E,T);else{const A=x.el=v.el;x.children!==v.children&&l(A,x.children)}},P=(v,x,E,T)=>{v==null?r(x.el=c(x.children||""),E,T):x.el=v.el},b=(v,x,E,T)=>{[v.el,v.anchor]=h(v.children,x,E,T,v.el,v.anchor)},m=({el:v,anchor:x},E,T)=>{let A;for(;v&&v!==x;)A=y(v),r(v,E,T),v=A;r(x,E,T)},g=({el:v,anchor:x})=>{let E;for(;v&&v!==x;)E=y(v),n(v),v=E;n(x)},w=(v,x,E,T,A,O,B,q,D)=>{if(x.type==="svg"?B="svg":x.type==="math"&&(B="mathml"),v==null)S(x,E,T,A,O,B,q,D);else{const L=v.el&&v.el._isVueCE?v.el:null;try{L&&L._beginPatch(),N(v,x,A,O,B,q,D)}finally{L&&L._endPatch()}}},S=(v,x,E,T,A,O,B,q)=>{let D,L;const{props:Q,shapeFlag:z,transition:V,dirs:ee}=v;if(D=v.el=o(v.type,O,Q&&Q.is,Q),z&8?u(D,v.children):z&16&&F(v.children,D,null,T,A,Zo(v,O),B,q),ee&&Ei(v,null,T,"created"),I(D,v,v.scopeId,B,T),Q){for(const _e in Q)_e!=="value"&&!_r(_e)&&s(D,_e,null,Q[_e],O,T);"value"in Q&&s(D,"value",null,Q.value,O),(L=Q.onVnodeBeforeMount)&&qt(L,T,v)}ee&&Ei(v,null,T,"beforeMount");const se=ub(A,V);se&&V.beforeEnter(D),r(D,x,E),((L=Q&&Q.onVnodeMounted)||se||ee)&&at(()=>{L&&qt(L,T,v),se&&V.enter(D),ee&&Ei(v,null,T,"mounted")},A)},I=(v,x,E,T,A)=>{if(E&&p(v,E),T)for(let O=0;O<T.length;O++)p(v,T[O]);if(A){let O=A.subTree;if(x===O||Fu(O.type)&&(O.ssContent===x||O.ssFallback===x)){const B=A.vnode;I(v,B,B.scopeId,B.slotScopeIds,A.parent)}}},F=(v,x,E,T,A,O,B,q,D=0)=>{for(let L=D;L<v.length;L++){const Q=v[L]=q?hi(v[L]):Ft(v[L]);_(null,Q,x,E,T,A,O,B,q)}},N=(v,x,E,T,A,O,B)=>{const q=x.el=v.el;let{patchFlag:D,dynamicChildren:L,dirs:Q}=x;D|=v.patchFlag&16;const z=v.props||le,V=x.props||le;let ee;if(E&&Pi(E,!1),(ee=V.onVnodeBeforeUpdate)&&qt(ee,E,x,v),Q&&Ei(x,v,E,"beforeUpdate"),E&&Pi(E,!0),(z.innerHTML&&V.innerHTML==null||z.textContent&&V.textContent==null)&&u(q,""),L?G(v.dynamicChildren,L,q,E,T,Zo(x,A),O):B||ge(v,x,q,null,E,T,Zo(x,A),O,!1),D>0){if(D&16)K(q,z,V,E,A);else if(D&2&&z.class!==V.class&&s(q,"class",null,V.class,A),D&4&&s(q,"style",z.style,V.style,A),D&8){const se=x.dynamicProps;for(let _e=0;_e<se.length;_e++){const he=se[_e],nt=z[he],st=V[he];(st!==nt||he==="value")&&s(q,he,nt,st,A,E)}}D&1&&v.children!==x.children&&u(q,x.children)}else!B&&L==null&&K(q,z,V,E,A);((ee=V.onVnodeUpdated)||Q)&&at(()=>{ee&&qt(ee,E,x,v),Q&&Ei(x,v,E,"updated")},T)},G=(v,x,E,T,A,O,B)=>{for(let q=0;q<x.length;q++){const D=v[q],L=x[q],Q=D.el&&(D.type===We||!Ur(D,L)||D.shapeFlag&198)?d(D.el):E;_(D,L,Q,null,T,A,O,B,!0)}},K=(v,x,E,T,A)=>{if(x!==E){if(x!==le)for(const O in x)!_r(O)&&!(O in E)&&s(v,O,x[O],null,A,T);for(const O in E){if(_r(O))continue;const B=E[O],q=x[O];B!==q&&O!=="value"&&s(v,O,q,B,A,T)}"value"in E&&s(v,"value",x.value,E.value,A)}},qe=(v,x,E,T,A,O,B,q,D)=>{const L=x.el=v?v.el:a(""),Q=x.anchor=v?v.anchor:a("");let{patchFlag:z,dynamicChildren:V,slotScopeIds:ee}=x;ee&&(q=q?q.concat(ee):ee),v==null?(r(L,E,T),r(Q,E,T),F(x.children||[],E,Q,A,O,B,q,D)):z>0&&z&64&&V&&v.dynamicChildren&&v.dynamicChildren.length===V.length?(G(v.dynamicChildren,V,E,A,O,B,q),(x.key!=null||A&&x===A.subTree)&&Mu(v,x,!0)):ge(v,x,E,Q,A,O,B,q,D)},fe=(v,x,E,T,A,O,B,q,D)=>{x.slotScopeIds=q,v==null?x.shapeFlag&512?A.ctx.activate(x,E,T,B,D):Ae(x,E,T,A,O,B,D):Pe(v,x,D)},Ae=(v,x,E,T,A,O,B)=>{const q=v.component=bb(v,T,A);if(Bo(v)&&(q.ctx.renderer=we),vb(q,!1,B),q.asyncDep){if(A&&A.registerDep(q,ae,B),!v.el){const D=q.subTree=Ne(ii);P(null,D,x,E),v.placeholder=D.el}}else ae(q,v,x,E,A,O,B)},Pe=(v,x,E)=>{const T=x.component=v.component;if(eb(v,x,E))if(T.asyncDep&&!T.asyncResolved){me(T,x,E);return}else T.next=x,T.update();else x.el=v.el,T.vnode=x},ae=(v,x,E,T,A,O,B)=>{const q=()=>{if(v.isMounted){let{next:z,bu:V,u:ee,parent:se,vnode:_e}=v;{const zt=Du(v);if(zt){z&&(z.el=_e.el,me(v,z,B)),zt.asyncDep.then(()=>{v.isUnmounted||q()});return}}let he=z,nt;Pi(v,!1),z?(z.el=_e.el,me(v,z,B)):z=_e,V&&$n(V),(nt=z.props&&z.props.onVnodeBeforeUpdate)&&qt(nt,se,z,_e),Pi(v,!0);const st=Eu(v),Ht=v.subTree;v.subTree=st,_(Ht,st,d(Ht.el),H(Ht),v,A,O),z.el=st.el,he===null&&tb(v,st.el),ee&&at(ee,A),(nt=z.props&&z.props.onVnodeUpdated)&&at(()=>qt(nt,se,z,_e),A)}else{let z;const{el:V,props:ee}=x,{bm:se,m:_e,parent:he,root:nt,type:st}=v,Ht=Qi(x);Pi(v,!1),se&&$n(se),!Ht&&(z=ee&&ee.onVnodeBeforeMount)&&qt(z,he,x),Pi(v,!0);{nt.ce&&nt.ce._def.shadowRoot!==!1&&nt.ce._injectChildStyle(st);const zt=v.subTree=Eu(v);_(null,zt,E,T,v,A,O),x.el=zt.el}if(_e&&at(_e,A),!Ht&&(z=ee&&ee.onVnodeMounted)){const zt=x;at(()=>qt(z,he,zt),A)}(x.shapeFlag&256||he&&Qi(he.vnode)&&he.vnode.shapeFlag&256)&&v.a&&at(v.a,A),v.isMounted=!0,x=E=T=null}};v.scope.on();const D=v.effect=new Tc(q);v.scope.off();const L=v.update=D.run.bind(D),Q=v.job=D.runIfDirty.bind(D);Q.i=v,Q.id=v.uid,D.scheduler=()=>jo(Q),Pi(v,!0),L()},me=(v,x,E)=>{x.component=v;const T=v.vnode.props;v.vnode=x,v.next=null,rb(v,x.props,T,E),ab(v,x.children,E),Mt(),iu(v),Dt()},ge=(v,x,E,T,A,O,B,q,D=!1)=>{const L=v&&v.children,Q=v?v.shapeFlag:0,z=x.children,{patchFlag:V,shapeFlag:ee}=x;if(V>0){if(V&128){ar(L,z,E,T,A,O,B,q,D);return}else if(V&256){ni(L,z,E,T,A,O,B,q,D);return}}ee&8?(Q&16&&M(L,A,O),z!==L&&u(E,z)):Q&16?ee&16?ar(L,z,E,T,A,O,B,q,D):M(L,A,O,!0):(Q&8&&u(E,""),ee&16&&F(z,E,T,A,O,B,q,D))},ni=(v,x,E,T,A,O,B,q,D)=>{v=v||qi,x=x||qi;const L=v.length,Q=x.length,z=Math.min(L,Q);let V;for(V=0;V<z;V++){const ee=x[V]=D?hi(x[V]):Ft(x[V]);_(v[V],ee,E,null,A,O,B,q,D)}L>Q?M(v,A,O,!0,!1,z):F(x,E,T,A,O,B,q,D,z)},ar=(v,x,E,T,A,O,B,q,D)=>{let L=0;const Q=x.length;let z=v.length-1,V=Q-1;for(;L<=z&&L<=V;){const ee=v[L],se=x[L]=D?hi(x[L]):Ft(x[L]);if(Ur(ee,se))_(ee,se,E,null,A,O,B,q,D);else break;L++}for(;L<=z&&L<=V;){const ee=v[z],se=x[V]=D?hi(x[V]):Ft(x[V]);if(Ur(ee,se))_(ee,se,E,null,A,O,B,q,D);else break;z--,V--}if(L>z){if(L<=V){const ee=V+1,se=ee<Q?x[ee].el:T;for(;L<=V;)_(null,x[L]=D?hi(x[L]):Ft(x[L]),E,se,A,O,B,q,D),L++}}else if(L>V)for(;L<=z;)Pt(v[L],A,O,!0),L++;else{const ee=L,se=L,_e=new Map;for(L=se;L<=V;L++){const ft=x[L]=D?hi(x[L]):Ft(x[L]);ft.key!=null&&_e.set(ft.key,L)}let he,nt=0;const st=V-se+1;let Ht=!1,zt=0;const Yr=new Array(st);for(L=0;L<st;L++)Yr[L]=0;for(L=ee;L<=z;L++){const ft=v[L];if(nt>=st){Pt(ft,A,O,!0);continue}let Wt;if(ft.key!=null)Wt=_e.get(ft.key);else for(he=se;he<=V;he++)if(Yr[he-se]===0&&Ur(ft,x[he])){Wt=he;break}Wt===void 0?Pt(ft,A,O,!0):(Yr[Wt-se]=L+1,Wt>=zt?zt=Wt:Ht=!0,_(ft,x[Wt],E,null,A,O,B,q,D),nt++)}const Mf=Ht?db(Yr):qi;for(he=Mf.length-1,L=st-1;L>=0;L--){const ft=se+L,Wt=x[ft],Df=x[ft+1],jf=ft+1<Q?Df.el||Uu(Df):T;Yr[L]===0?_(null,Wt,E,jf,A,O,B,q,D):Ht&&(he<0||L!==Mf[he]?si(Wt,E,jf,2):he--)}}},si=(v,x,E,T,A=null)=>{const{el:O,type:B,transition:q,children:D,shapeFlag:L}=v;if(L&6){si(v.component.subTree,x,E,T);return}if(L&128){v.suspense.move(x,E,T);return}if(L&64){B.move(v,x,E,we);return}if(B===We){r(O,x,E);for(let z=0;z<D.length;z++)si(D[z],x,E,T);r(v.anchor,x,E);return}if(B===ea){m(v,x,E);return}if(T!==2&&L&1&&q)if(T===0)q.beforeEnter(O),r(O,x,E),at(()=>q.enter(O),A);else{const{leave:z,delayLeave:V,afterLeave:ee}=q,se=()=>{v.ctx.isUnmounted?n(O):r(O,x,E)},_e=()=>{O._isLeaving&&O[Cy](!0),z(O,()=>{se(),ee&&ee()})};V?V(O,se,_e):_e()}else r(O,x,E)},Pt=(v,x,E,T=!1,A=!1)=>{const{type:O,props:B,ref:q,children:D,dynamicChildren:L,shapeFlag:Q,patchFlag:z,dirs:V,cacheIndex:ee}=v;if(z===-2&&(A=!1),q!=null&&(Mt(),Or(q,null,E,v,!0),Dt()),ee!=null&&(x.renderCache[ee]=void 0),Q&256){x.ctx.deactivate(v);return}const se=Q&1&&V,_e=!Qi(v);let he;if(_e&&(he=B&&B.onVnodeBeforeUnmount)&&qt(he,x,v),Q&6)C(v.component,E,T);else{if(Q&128){v.suspense.unmount(E,T);return}se&&Ei(v,null,x,"beforeUnmount"),Q&64?v.type.remove(v,x,E,we,T):L&&!L.hasOnce&&(O!==We||z>0&&z&64)?M(L,x,E,!1,!0):(O===We&&z&384||!A&&Q&16)&&M(D,x,E),T&&vs(v)}(_e&&(he=B&&B.onVnodeUnmounted)||se)&&at(()=>{he&&qt(he,x,v),se&&Ei(v,null,x,"unmounted")},E)},vs=v=>{const{type:x,el:E,anchor:T,transition:A}=v;if(x===We){Li(E,T);return}if(x===ea){g(v);return}const O=()=>{n(E),A&&!A.persisted&&A.afterLeave&&A.afterLeave()};if(v.shapeFlag&1&&A&&!A.persisted){const{leave:B,delayLeave:q}=A,D=()=>B(E,O);q?q(v.el,O,D):D()}else O()},Li=(v,x)=>{let E;for(;v!==x;)E=y(v),n(v),v=E;n(x)},C=(v,x,E)=>{const{bum:T,scope:A,job:O,subTree:B,um:q,m:D,a:L}=v;ju(D),ju(L),T&&$n(T),A.stop(),O&&(O.flags|=8,Pt(B,v,x,E)),q&&at(q,x),at(()=>{v.isUnmounted=!0},x)},M=(v,x,E,T=!1,A=!1,O=0)=>{for(let B=O;B<v.length;B++)Pt(v[B],x,E,T,A)},H=v=>{if(v.shapeFlag&6)return H(v.component.subTree);if(v.shapeFlag&128)return v.suspense.next();const x=y(v.anchor||v.el),E=x&&x[$y];return E?y(E):x};let te=!1;const Je=(v,x,E)=>{let T;v==null?x._vnode&&(Pt(x._vnode,null,null,!0),T=x._vnode.component):_(x._vnode||null,v,x,null,null,null,E),x._vnode=v,te||(te=!0,iu(T),ru(),te=!1)},we={p:_,um:Pt,m:si,r:vs,mt:Ae,mc:F,pc:ge,pbc:G,n:H,o:t};return{render:Je,hydrate:void 0,createApp:Qy(Je)}}function Zo({type:t,props:e},i){return i==="svg"&&t==="foreignObject"||i==="mathml"&&t==="annotation-xml"&&e&&e.encoding&&e.encoding.includes("html")?void 0:i}function Pi({effect:t,job:e},i){i?(t.flags|=32,e.flags|=4):(t.flags&=-33,e.flags&=-5)}function ub(t,e){return(!t||t&&!t.pendingBranch)&&e&&!e.persisted}function Mu(t,e,i=!1){const r=t.children,n=e.children;if(J(r)&&J(n))for(let s=0;s<r.length;s++){const o=r[s];let a=n[s];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=n[s]=hi(n[s]),a.el=o.el),!i&&a.patchFlag!==-2&&Mu(o,a)),a.type===zn&&(a.patchFlag!==-1?a.el=o.el:a.__elIndex=s+(t.type===We?1:0)),a.type===ii&&!a.el&&(a.el=o.el)}}function db(t){const e=t.slice(),i=[0];let r,n,s,o,a;const c=t.length;for(r=0;r<c;r++){const l=t[r];if(l!==0){if(n=i[i.length-1],t[n]<l){e[r]=n,i.push(r);continue}for(s=0,o=i.length-1;s<o;)a=s+o>>1,t[i[a]]<l?s=a+1:o=a;l<t[i[s]]&&(s>0&&(e[r]=i[s-1]),i[s]=r)}}for(s=i.length,o=i[s-1];s-- >0;)i[s]=o,o=e[o];return i}function Du(t){const e=t.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:Du(e)}function ju(t){if(t)for(let e=0;e<t.length;e++)t[e].flags|=8}function Uu(t){if(t.placeholder)return t.placeholder;const e=t.component;return e?Uu(e.subTree):null}const Fu=t=>t.__isSuspense;function fb(t,e){e&&e.pendingBranch?J(t)?e.effects.push(...t):e.effects.push(t):_y(t)}const We=Symbol.for("v-fgt"),zn=Symbol.for("v-txt"),ii=Symbol.for("v-cmt"),ea=Symbol.for("v-stc"),Dr=[];let lt=null;function de(t=!1){Dr.push(lt=t?null:[])}function hb(){Dr.pop(),lt=Dr[Dr.length-1]||null}let jr=1;function qu(t,e=!1){jr+=t,t<0&&lt&&e&&(lt.hasOnce=!0)}function Bu(t){return t.dynamicChildren=jr>0?lt||qi:null,hb(),jr>0&&lt&&lt.push(t),t}function ve(t,e,i,r,n,s){return Bu(ie(t,e,i,r,n,s,!0))}function Wn(t,e,i,r,n){return Bu(Ne(t,e,i,r,n,!0))}function ta(t){return t?t.__v_isVNode===!0:!1}function Ur(t,e){return t.type===e.type&&t.key===e.key}const Hu=({key:t})=>t??null,Kn=({ref:t,ref_key:e,ref_for:i})=>(typeof t=="number"&&(t=""+t),t!=null?Re(t)||De(t)||Z(t)?{i:ze,r:t,k:e,f:!!i}:t:null);function ie(t,e=null,i=null,r=0,n=null,s=t===We?0:1,o=!1,a=!1){const c={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&Hu(e),ref:e&&Kn(e),scopeId:su,slotScopeIds:null,children:i,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:s,patchFlag:r,dynamicProps:n,dynamicChildren:null,appContext:null,ctx:ze};return a?(ia(c,i),s&128&&t.normalize(c)):i&&(c.shapeFlag|=Re(i)?8:16),jr>0&&!o&&lt&&(c.patchFlag>0||s&6)&&c.patchFlag!==32&&lt.push(c),c}const Ne=pb;function pb(t,e=null,i=null,r=0,n=null,s=!1){if((!t||t===Fy)&&(t=ii),ta(t)){const a=Xi(t,e,!0);return i&&ia(a,i),jr>0&&!s&&lt&&(a.shapeFlag&6?lt[lt.indexOf(t)]=a:lt.push(a)),a.patchFlag=-2,a}if($b(t)&&(t=t.__vccOpts),e){e=gb(e);let{class:a,style:c}=e;a&&!Re(a)&&(e.class=xt(a)),ke(c)&&(Mo(c)&&!J(c)&&(c=Fe({},c)),e.style=xo(c))}const o=Re(t)?1:Fu(t)?128:Py(t)?64:ke(t)?4:Z(t)?2:0;return ie(t,e,i,r,n,o,s,!0)}function gb(t){return t?Mo(t)||Iu(t)?Fe({},t):t:null}function Xi(t,e,i=!1,r=!1){const{props:n,ref:s,patchFlag:o,children:a,transition:c}=t,l=e?zu(n||{},e):n,u={__v_isVNode:!0,__v_skip:!0,type:t.type,props:l,key:l&&Hu(l),ref:e&&e.ref?i&&s?J(s)?s.concat(Kn(e)):[s,Kn(e)]:Kn(e):s,scopeId:t.scopeId,slotScopeIds:t.slotScopeIds,children:a,target:t.target,targetStart:t.targetStart,targetAnchor:t.targetAnchor,staticCount:t.staticCount,shapeFlag:t.shapeFlag,patchFlag:e&&t.type!==We?o===-1?16:o|16:o,dynamicProps:t.dynamicProps,dynamicChildren:t.dynamicChildren,appContext:t.appContext,dirs:t.dirs,transition:c,component:t.component,suspense:t.suspense,ssContent:t.ssContent&&Xi(t.ssContent),ssFallback:t.ssFallback&&Xi(t.ssFallback),placeholder:t.placeholder,el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce};return c&&r&&Fo(u,c.clone(u)),u}function Fr(t=" ",e=0){return Ne(zn,null,t,e)}function fi(t="",e=!1){return e?(de(),Wn(ii,null,t)):Ne(ii,null,t)}function Ft(t){return t==null||typeof t=="boolean"?Ne(ii):J(t)?Ne(We,null,t.slice()):ta(t)?hi(t):Ne(zn,null,String(t))}function hi(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:Xi(t)}function ia(t,e){let i=0;const{shapeFlag:r}=t;if(e==null)e=null;else if(J(e))i=16;else if(typeof e=="object")if(r&65){const n=e.default;n&&(n._c&&(n._d=!1),ia(t,n()),n._c&&(n._d=!0));return}else{i=32;const n=e._;!n&&!Iu(e)?e._ctx=ze:n===3&&ze&&(ze.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else Z(e)?(e={default:e,_ctx:ze},i=32):(e=String(e),r&64?(i=16,e=[Fr(e)]):i=8);t.children=e,t.shapeFlag|=i}function zu(...t){const e={};for(let i=0;i<t.length;i++){const r=t[i];for(const n in r)if(n==="class")e.class!==r.class&&(e.class=xt([e.class,r.class]));else if(n==="style")e.style=xo([e.style,r.style]);else if(kn(n)){const s=e[n],o=r[n];o&&s!==o&&!(J(s)&&s.includes(o))&&(e[n]=s?[].concat(s,o):o)}else n!==""&&(e[n]=r[n])}return e}function qt(t,e,i,r=null){jt(t,e,7,[i,r])}const mb=_u();let yb=0;function bb(t,e,i){const r=t.type,n=(e?e.appContext:t.appContext)||mb,s={uid:yb++,vnode:t,type:r,parent:e,appContext:n,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new Um(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:e?e.provides:Object.create(n.provides),ids:e?e.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:Au(r,n),emitsOptions:Su(r,n),emit:null,emitted:null,propsDefaults:le,inheritAttrs:r.inheritAttrs,ctx:le,data:le,props:le,attrs:le,slots:le,refs:le,setupState:le,setupContext:null,suspense:i,suspenseId:i?i.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return s.ctx={_:s},s.root=e?e.root:s,s.emit=Yy.bind(null,s),t.ce&&t.ce(s),s}let Ke=null;const ra=()=>Ke||ze;let Vn,na;{const t=Pn(),e=(i,r)=>{let n;return(n=t[i])||(n=t[i]=[]),n.push(r),s=>{n.length>1?n.forEach(o=>o(s)):n[0](s)}};Vn=e("__VUE_INSTANCE_SETTERS__",i=>Ke=i),na=e("__VUE_SSR_SETTERS__",i=>Ji=i)}const qr=t=>{const e=Ke;return Vn(t),t.scope.on(),()=>{t.scope.off(),Vn(e)}},Wu=()=>{Ke&&Ke.scope.off(),Vn(null)};function Ku(t){return t.vnode.shapeFlag&4}let Ji=!1;function vb(t,e=!1,i=!1){e&&na(e);const{props:r,children:n}=t.vnode,s=Ku(t);ib(t,r,s,e),ob(t,n,i||e);const o=s?wb(t,e):void 0;return e&&na(!1),o}function wb(t,e){const i=t.type;t.accessCache=Object.create(null),t.proxy=new Proxy(t.ctx,By);const{setup:r}=i;if(r){Mt();const n=t.setupContext=r.length>1?xb(t):null,s=qr(t),o=Wi(r,t,0,[t.props,n]),a=kc(o);if(Dt(),s(),(a||t.sp)&&!Qi(t)&&qo(t),a){if(o.then(Wu,Wu),e)return o.then(c=>{Vu(t,c)}).catch(c=>{Cr(c,t,0)});t.asyncDep=o}else Vu(t,o)}else Gu(t)}function Vu(t,e,i){Z(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:ke(e)&&(t.setupState=Jc(e)),Gu(t)}function Gu(t,e,i){const r=t.type;t.render||(t.render=r.render||Nt);{const n=qr(t);Mt();try{Hy(t)}finally{Dt(),n()}}}const _b={get(t,e){return He(t,"get",""),t[e]}};function xb(t){const e=i=>{t.exposed=i||{}};return{attrs:new Proxy(t.attrs,_b),slots:t.slots,emit:t.emit,expose:e}}function Gn(t){return t.exposed?t.exposeProxy||(t.exposeProxy=new Proxy(Jc(oy(t.exposed)),{get(e,i){if(i in e)return e[i];if(i in Nr)return Nr[i](t)},has(e,i){return i in e||i in Nr}})):t.proxy}const kb=/(?:^|[-_])\w/g,Sb=t=>t.replace(kb,e=>e.toUpperCase()).replace(/[-_]/g,"");function Eb(t,e=!0){return Z(t)?t.displayName||t.name:t.name||e&&t.__name}function Qu(t,e,i=!1){let r=Eb(e);if(!r&&e.__file){const n=e.__file.match(/([^/\\]+)\.\w+$/);n&&(r=n[1])}if(!r&&t){const n=s=>{for(const o in s)if(s[o]===e)return o};r=n(t.components)||t.parent&&n(t.parent.type.components)||n(t.appContext.components)}return r?Sb(r):i?"App":"Anonymous"}function $b(t){return Z(t)&&"__vccOpts"in t}const Bt=(t,e)=>fy(t,e,Ji),Pb="3.5.26";let sa;const Yu=typeof window<"u"&&window.trustedTypes;if(Yu)try{sa=Yu.createPolicy("vue",{createHTML:t=>t})}catch{}const Xu=sa?t=>sa.createHTML(t):t=>t,Cb="http://www.w3.org/2000/svg",Ib="http://www.w3.org/1998/Math/MathML",ri=typeof document<"u"?document:null,Ju=ri&&ri.createElement("template"),Rb={insert:(t,e,i)=>{e.insertBefore(t,i||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,i,r)=>{const n=e==="svg"?ri.createElementNS(Cb,t):e==="mathml"?ri.createElementNS(Ib,t):i?ri.createElement(t,{is:i}):ri.createElement(t);return t==="select"&&r&&r.multiple!=null&&n.setAttribute("multiple",r.multiple),n},createText:t=>ri.createTextNode(t),createComment:t=>ri.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>ri.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,i,r,n,s){const o=i?i.previousSibling:e.lastChild;if(n&&(n===s||n.nextSibling))for(;e.insertBefore(n.cloneNode(!0),i),!(n===s||!(n=n.nextSibling)););else{Ju.innerHTML=Xu(r==="svg"?`<svg>${t}</svg>`:r==="mathml"?`<math>${t}</math>`:t);const a=Ju.content;if(r==="svg"||r==="mathml"){const c=a.firstChild;for(;c.firstChild;)a.appendChild(c.firstChild);a.removeChild(c)}e.insertBefore(a,i)}return[o?o.nextSibling:e.firstChild,i?i.previousSibling:e.lastChild]}},Ab=Symbol("_vtc");function Tb(t,e,i){const r=t[Ab];r&&(e=(e?[e,...r]:[...r]).join(" ")),e==null?t.removeAttribute("class"):i?t.setAttribute("class",e):t.className=e}const Zu=Symbol("_vod"),Ob=Symbol("_vsh"),Lb=Symbol(""),Nb=/(?:^|;)\s*display\s*:/;function Mb(t,e,i){const r=t.style,n=Re(i);let s=!1;if(i&&!n){if(e)if(Re(e))for(const o of e.split(";")){const a=o.slice(0,o.indexOf(":")).trim();i[a]==null&&Qn(r,a,"")}else for(const o in e)i[o]==null&&Qn(r,o,"");for(const o in i)o==="display"&&(s=!0),Qn(r,o,i[o])}else if(n){if(e!==i){const o=r[Lb];o&&(i+=";"+o),r.cssText=i,s=Nb.test(i)}}else e&&t.removeAttribute("style");Zu in t&&(t[Zu]=s?r.display:"",t[Ob]&&(r.display="none"))}const ed=/\s*!important$/;function Qn(t,e,i){if(J(i))i.forEach(r=>Qn(t,e,r));else if(i==null&&(i=""),e.startsWith("--"))t.setProperty(e,i);else{const r=Db(t,e);ed.test(i)?t.setProperty(ci(r),i.replace(ed,""),"important"):t[r]=i}}const td=["Webkit","Moz","ms"],oa={};function Db(t,e){const i=oa[e];if(i)return i;let r=Yt(e);if(r!=="filter"&&r in t)return oa[e]=r;r=$c(r);for(let n=0;n<td.length;n++){const s=td[n]+r;if(s in t)return oa[e]=s}return e}const id="http://www.w3.org/1999/xlink";function rd(t,e,i,r,n,s=jm(e)){r&&e.startsWith("xlink:")?i==null?t.removeAttributeNS(id,e.slice(6,e.length)):t.setAttributeNS(id,e,i):i==null||s&&!Ic(i)?t.removeAttribute(e):t.setAttribute(e,s?"":Qt(i)?String(i):i)}function nd(t,e,i,r,n){if(e==="innerHTML"||e==="textContent"){i!=null&&(t[e]=e==="innerHTML"?Xu(i):i);return}const s=t.tagName;if(e==="value"&&s!=="PROGRESS"&&!s.includes("-")){const a=s==="OPTION"?t.getAttribute("value")||"":t.value,c=i==null?t.type==="checkbox"?"on":"":String(i);(a!==c||!("_value"in t))&&(t.value=c),i==null&&t.removeAttribute(e),t._value=i;return}let o=!1;if(i===""||i==null){const a=typeof t[e];a==="boolean"?i=Ic(i):i==null&&a==="string"?(i="",o=!0):a==="number"&&(i=0,o=!0)}try{t[e]=i}catch{}o&&t.removeAttribute(n||e)}function Zi(t,e,i,r){t.addEventListener(e,i,r)}function jb(t,e,i,r){t.removeEventListener(e,i,r)}const sd=Symbol("_vei");function Ub(t,e,i,r,n=null){const s=t[sd]||(t[sd]={}),o=s[e];if(r&&o)o.value=r;else{const[a,c]=Fb(e);if(r){const l=s[e]=Hb(r,n);Zi(t,a,l,c)}else o&&(jb(t,a,o,c),s[e]=void 0)}}const od=/(?:Once|Passive|Capture)$/;function Fb(t){let e;if(od.test(t)){e={};let r;for(;r=t.match(od);)t=t.slice(0,t.length-r[0].length),e[r[0].toLowerCase()]=!0}return[t[2]===":"?t.slice(3):ci(t.slice(2)),e]}let aa=0;const qb=Promise.resolve(),Bb=()=>aa||(qb.then(()=>aa=0),aa=Date.now());function Hb(t,e){const i=r=>{if(!r._vts)r._vts=Date.now();else if(r._vts<=i.attached)return;jt(zb(r,i.value),e,5,[r])};return i.value=t,i.attached=Bb(),i}function zb(t,e){if(J(e)){const i=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{i.call(t),t._stopped=!0},e.map(r=>n=>!n._stopped&&r&&r(n))}else return e}const ad=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>96&&t.charCodeAt(2)<123,Wb=(t,e,i,r,n,s)=>{const o=n==="svg";e==="class"?Tb(t,r,o):e==="style"?Mb(t,i,r):kn(e)?yo(e)||Ub(t,e,i,r,s):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):Kb(t,e,r,o))?(nd(t,e,r),!t.tagName.includes("-")&&(e==="value"||e==="checked"||e==="selected")&&rd(t,e,r,o,s,e!=="value")):t._isVueCE&&(/[A-Z]/.test(e)||!Re(r))?nd(t,Yt(e),r,s,e):(e==="true-value"?t._trueValue=r:e==="false-value"&&(t._falseValue=r),rd(t,e,r,o))};function Kb(t,e,i,r){if(r)return!!(e==="innerHTML"||e==="textContent"||e in t&&ad(e)&&Z(i));if(e==="spellcheck"||e==="draggable"||e==="translate"||e==="autocorrect"||e==="sandbox"&&t.tagName==="IFRAME"||e==="form"||e==="list"&&t.tagName==="INPUT"||e==="type"&&t.tagName==="TEXTAREA")return!1;if(e==="width"||e==="height"){const n=t.tagName;if(n==="IMG"||n==="VIDEO"||n==="CANVAS"||n==="SOURCE")return!1}return ad(e)&&Re(i)?!1:e in t}const ld=t=>{const e=t.props["onUpdate:modelValue"]||!1;return J(e)?i=>$n(e,i):e};function Vb(t){t.target.composing=!0}function cd(t){const e=t.target;e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}const la=Symbol("_assign");function ud(t,e,i){return e&&(t=t.trim()),i&&(t=_o(t)),t}const dd={created(t,{modifiers:{lazy:e,trim:i,number:r}},n){t[la]=ld(n);const s=r||n.props&&n.props.type==="number";Zi(t,e?"change":"input",o=>{o.target.composing||t[la](ud(t.value,i,s))}),(i||s)&&Zi(t,"change",()=>{t.value=ud(t.value,i,s)}),e||(Zi(t,"compositionstart",Vb),Zi(t,"compositionend",cd),Zi(t,"change",cd))},mounted(t,{value:e}){t.value=e??""},beforeUpdate(t,{value:e,oldValue:i,modifiers:{lazy:r,trim:n,number:s}},o){if(t[la]=ld(o),t.composing)return;const a=(s||t.type==="number")&&!/^0\d/.test(t.value)?_o(t.value):t.value,c=e??"";a!==c&&(document.activeElement===t&&t.type!=="range"&&(r&&e===i||n&&t.value.trim()===c)||(t.value=c))}},Gb=Fe({patchProp:Wb},Rb);let fd;function Qb(){return fd||(fd=lb(Gb))}const Yb=((...t)=>{const e=Qb().createApp(...t),{mount:i}=e;return e.mount=r=>{const n=Jb(r);if(!n)return;const s=e._component;!Z(s)&&!s.render&&!s.template&&(s.template=n.innerHTML),n.nodeType===1&&(n.textContent="");const o=i(n,!1,Xb(n));return n instanceof Element&&(n.removeAttribute("v-cloak"),n.setAttribute("data-v-app","")),o},e});function Xb(t){if(t instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&t instanceof MathMLElement)return"mathml"}function Jb(t){return Re(t)?document.querySelector(t):t}const Zb=1;var Yn;(t=>{t.PackageLoader=new R(R.object({kind:R.union(["autoload","module","umd","styles"]).required().default("autoload"),entry:R.string(),styles:R.array(R.string()),main_export:R.string()})),t.Package=new R(R.object({id:R.string().required(),name:R.string().required(),version:R.string().required(),description:R.string(),author:R.string(),license:R.string(),loader:t.PackageLoader.required()})),t.RegistryMaintainer=new R(R.object({name:R.string().required(),email:R.string()})),t.RegistryRepository=new R(R.object({type:R.string().required(),url:R.string().required()})),t.Registry=new R(R.object({manifest_version:R.number().min(Zb).required(),name:R.string().required(),base_url:R.string().required(),homepage:R.string(),maintainers:R.array(t.RegistryMaintainer),repository:t.RegistryRepository,packages:R.array(t.Package).required()}))})(Yn||(Yn={}));const ca=Symbol("IPEInjectKey"),ev=(t,e)=>(e?e.provide(ca,t):au(ca,t),t),ua=()=>{const t=Tr(ca);if(!t)throw new Error("InPageEdit instance is not provided");return t},hd=(t,...e)=>{const i=Yb(...e);return ev(t,i),i};var tv=Object.create,da=Object.defineProperty,iv=Object.getOwnPropertyDescriptor,pd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),gd=t=>{throw TypeError(t)},rv=(t,e,i)=>e in t?da(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,nv=(t,e)=>da(t,"name",{value:e,configurable:!0}),sv=t=>[,,,tv(t?.[pd("metadata")]??null)],ov=["class","method","getter","setter","accessor","field","value","get","set"],md=t=>t!==void 0&&typeof t!="function"?gd("Function expected"):t,av=(t,e,i,r,n)=>({kind:ov[t],name:e,metadata:r,addInitializer:s=>i._?gd("Already initialized"):n.push(md(s||null))}),lv=(t,e)=>rv(e,pd("metadata"),t[3]),cv=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},uv=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&iv(n,i));nv(n,i);for(var h=r.length-1;h>=0;h--)c=av(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,md(o)&&(n=o);return lv(t,n),p&&da(n,i,p),u?l^4?s:p:n},yd,fa,bd;const vd=t=>{if(!t)return null;try{return t.split(".").reduce((e,i)=>e==null?e:e[i],globalThis)}catch{return null}},wd=(t,e,i)=>{if(/^https?:\/\//i.test(t))return t;const r=o=>o.endsWith("/")?o:o+"/";if(/^https?:\/\//i.test(e)){const o=r(e);return new URL(t,o).href}const n=(()=>{try{return new URL(i).href}catch{return new URL(i,location.origin).href}})(),s=new URL(r(e),n).href;return new URL(t,s).href};yd=[xe(["storage","preferences","resourceLoader","$"])];let Xn=($t=class extends(bd=Ue){constructor(e){super(e,{},"plugin-store"),this.ctx=e,this.regInfoDB=void 0,this._installedPlugins=new Map,this._onlineRegistryQueries=new Map,e.set("store",this),this.regInfoDB=e.storage.createDatabase($t.REGISTRY_INFO_STORAGE_NAME,$t.REGISTRY_INFO_CACHE_TTL,1,"indexedDB")}async start(){this._installUserPlugins(),this._injectPreferenceUI()}async _installUserPlugins(){const e=await this.ctx.preferences.get("pluginStore.plugins",[]);if(e?.length)for(const i of e)this.install(i.registry,i.id,i.source,"user-preference")}async _createManagementApp(){const e=await this.ctx.withInject(["store"]);return hd(e,Ry(()=>Promise.resolve().then(()=>Z_)))}async _injectPreferenceUI(){const e=this.ctx,i=e.$;e.preferences.defineCategory({name:"plugin-store",label:i`Plugin Store`,description:i`Plugin Store`,index:90,autoGenerateForm:!1,customRenderer:async({onUnmount:r})=>{const n=f("div",{id:"ipe-plugin-store-preferences-vue"}),s=await this._createManagementApp();return s.mount(n),r(()=>{s.unmount(),this.ctx.logger.debug("Plugin Store preferences app unmounted")}),f("section",{children:n})}}),e.preferences.registerCustomConfig("plugin-store",R.object({"pluginStore.registries":R.array(R.string()).default([Lt.PLUGIN_REGISTRY_URL]).description(i`Registry URLs`).hidden(),"pluginStore.cdnForNpm":R.string().description(i`CDN to install packages from npm`).default('https://cdn.jsdelivr.net/npm/{{ package }}{{ version ? "@" + version : "" }}').hidden(),"pluginStore.plugins":R.array(R.object({source:R.union(["online_manifest","npm"]).default("online_manifest"),registry:R.string().required(),id:R.string().required()})).description(i`Installed plugins`).default([]).hidden()}),"plugin-store")}async showModal(){const e=this.ctx.modal.show({title:$`Plugin Store`,sizeClass:"small"}),i=f("section",{id:"ipe-plugin-store-vue"});e.setContent(i);const r=await this._createManagementApp();return r.mount(i),e.on(e.Event.Close,()=>{r.unmount()}),e}async install(e,i,r="online_manifest",n="new-added"){const s=await this.getRegistryInfo(e,r);if(!s)return this.ctx.logger.warn(`Registry ${e} not found`),null;const o=`${e}#${i}`;if(this._installedPlugins.has(o))return await this._installedPlugins.get(o)??null;const a=this._installOneByRegistryInfo(e,s,i);this._installedPlugins.set(o,a);const c=await a;return c&&this.ctx.emit("plugin-store/plugin-installed",{ctx:this.ctx,registry:s,id:i,by:n}),c}async uninstall(e,i){const r=this._installedPlugins.get(`${e}#${i}`);if(r===void 0)return!0;this._installedPlugins.delete(`${e}#${i}`);const n=await r;if(n){const s=n.dispose?.()??!0;try{const o=await this.getRegistryCache(e)||await this.getRegistryInfo(e).catch(()=>null);o&&this.ctx.emit("plugin-store/plugin-uninstalled",{ctx:this.ctx,registry:o,id:i})}catch{}return s}return!0}async addToPreferences(e,i){let r=await this.ctx.preferences.get("pluginStore.plugins")||[];return r.some(s=>s.registry===e&&s.id===i)||(r.push({registry:e,id:i}),await this.ctx.preferences.set("pluginStore.plugins",r)),!0}async removeFromPreferences(e,i){let r=await this.ctx.preferences.get("pluginStore.plugins")||[];return r=r.filter(n=>n.registry!==e||n.id!==i),await this.ctx.preferences.set("pluginStore.plugins",r),!0}async installAndSetPreference(e,i){return await this.addToPreferences(e,i),this.install(e,i,"online_manifest","new-added")}async uninstallAndRemovePreference(e,i){return await this.removeFromPreferences(e,i),this.uninstall(e,i)}async _installOneByRegistryInfo(e,i,r){const n=i.base_url,s=i.packages.find(h=>h.id===r);if(!s)return this.ctx.logger.warn(`Package ${r} not found in registry ${e}`),null;const o=s.loader,{kind:a,entry:c="index.js",styles:l=[],main_export:u=null}=o;let d=null;if(a!=="styles"){if(!c)return this.ctx.logger.warn(`Entry url missing for ${r}`,o),null;try{d=wd(c,n,e)}catch(h){return this.ctx.logger.warn(`Failed to resolve entry "${c}" with base "${n}" and registry "${e}"`,h),null}}const y={"data-plugin-registry":e,"data-plugin-id":r};let p=null;switch(a){case"autoload":{p=this.ctx.plugin({inject:["resourceLoader"],name:`plugin-store-${e}-${r}`,apply:h=>{d&&h.resourceLoader.loadScript(d,{...y})}});break}case"module":{if(!d)return this.ctx.logger.warn(`Entry url missing for module kind, package ${r}`),null;const h=await import(d).then(_=>(u?_[u]:_.default)??_);if(!h)return this.ctx.logger.warn(`Main export ${u} not found in module ${d}`),null;p=this.ctx.plugin(h);break}case"umd":{let h=vd(u);if(!h){if(!d)return this.ctx.logger.warn(`Entry url missing for umd kind, package ${r}`),null;await this.ctx.resourceLoader.loadScript(d,{...y}),h=vd(u)}if(!h)return this.ctx.logger.warn(`Main export ${u} not found on globalThis after loading ${d}`),null;p=this.ctx.plugin(h);break}}if(l&&l.length>0){let h=[];try{h=l.map(_=>wd(_,n,e)).filter(Boolean)}catch(_){this.ctx.logger.warn(`Failed to resolve styles for ${r}`,l,_)}p||(p=this.ctx.plugin({name:`plugin-store-${e}-${r}`,apply(){}})),p.ctx.plugin({inject:["resourceLoader"],name:`plugin-store-${e}-${r}-styles`,apply:_=>{h.forEach(k=>_.resourceLoader.loadStyle(k,{...y})),_.on("dispose",()=>{try{h.forEach(k=>_.resourceLoader.removeStyle(k))}catch{}})}})}return p}validateRegistry(e){return Yn.Registry(e)}async getRegistryInfo(e,i="online_manifest",r=!1){try{let s;if(i==="online_manifest")s=await this._fetchOnlineRegistryInfo(e,r),this.logger.debug("Fetched registry info from online manifest",s),this.setRegistryCache(e,s);else throw new Error(`Unsupported registry source: ${i}`);return s}catch(s){this.ctx.logger.warn("Failed to fetch registry info",s)}const n=await this.getRegistryCache(e);if(!n)throw this.ctx.emit("plugin-store/registry-not-found",{ctx:this.ctx,registryUrl:e}),new Error(`Failed to fetch registry info: ${e}`);return n}async _fetchOnlineRegistryInfo(e,i=!1){if(!i&&this._onlineRegistryQueries.has(e))return await this._onlineRegistryQueries.get(e);const n=(async()=>{const s={method:"GET"};i&&(s.cache="no-store");const a=await(await fetch(e,s)).json(),c=this.validateRegistry(a);return this.ctx.emit("plugin-store/registry-fetched",{ctx:this.ctx,registry:c}),c})();return this._onlineRegistryQueries.set(e,n),await n}async getRegistryCache(e){const i=await this.regInfoDB.get(e);if(i)try{return this.validateRegistry(i)}catch(r){this.ctx.logger.warn("Invalid cached registry",r,i),this.regInfoDB.delete(e)}return null}async setRegistryCache(e,i){return this.regInfoDB.set(e,i)}async deleteRegistryCache(e){await this.regInfoDB.delete(e),this.ctx.emit("plugin-store/registry-removed",{ctx:this.ctx,registryUrl:e})}async clearAllRegistryCaches(){await this.regInfoDB.clear(),this.ctx.logger.debug("All registry caches cleared")}async refreshRegistryCache(e){const i=await this.getRegistryInfo(e,"online_manifest",!0);if(!i)throw new Error(`Failed to refresh registry cache: ${e}`);return this.ctx.logger.debug("Registry cache refreshed:",e),i}async refreshAllRegistryCaches(){const e=await this.ctx.preferences.get("pluginStore.registries")||[],i=await Promise.allSettled(e.map(n=>this.refreshRegistryCache(n))),r={};for(const[n,s]of i.entries())s.status==="fulfilled"?r[e[n]]=s.value:r[e[n]]=null;return r}},$t.PluginStoreSchemas=Yn,$t.REGISTRY_INFO_CACHE_TTL=1e3*60*60*24,$t.REGISTRY_INFO_STORAGE_NAME="plugin-store-registry",$t.REGISTRY_ETAG_STORAGE_NAME="psreg-etag",$t);fa=sv(bd),Xn=uv(fa,0,"PluginPluginStore",yd,Xn),cv(fa,1,Xn);const dv=Object.freeze(Object.defineProperty({__proto__:null,PluginPluginStore:Xn},Symbol.toStringTag,{value:"Module"})),ct='@charset "UTF-8";:host{display:block;font-family:var(--schema-font-family, ui-sans-serif, system-ui, -apple-system);color:var(--schema-color-fg, #111827)}*,*:before,*:after{box-sizing:border-box}.wrapper{display:block;background:var(--schema-color-bg, #ffffff)}.form{display:grid;gap:12px}.field{display:grid;gap:6px;padding:8px 10px;border:1px solid var(--schema-color-muted, #e5e7eb);border-radius:var(--schema-radius, 10px);background:var(--schema-surface, #fff)}.label{font-size:12px;color:var(--schema-color-muted-text, #6b7280)}.input,select,textarea{width:100%;padding:8px 10px;border-radius:8px;border:1px solid var(--schema-color-muted, #e5e7eb);background:var(--schema-input-bg, #fff);color:inherit}.checkbox{display:inline-flex;align-items:center;gap:8px}.helper{font-size:12px;color:var(--schema-color-muted-text, #6b7280)}.row{display:grid;gap:8px}.actions{display:flex;gap:8px}.btn{padding:6px 10px;border:1px solid var(--schema-color-muted, #e5e7eb);background:var(--schema-btn-bg, #f8fafc);border-radius:8px;cursor:pointer;color:var(--schema-color-fg)}.btn.primary{background:var(--schema-color-primary, #2563eb);color:#fff;border-color:transparent}.btn:disabled{opacity:.5;cursor:not-allowed}.btn.danger{background:var(--schema-color-danger, #dc2626);color:#fff;border-color:transparent}.group{display:grid;gap:10px}.kv{display:grid;grid-template-columns:1fr 1fr auto;gap:8px;align-items:center}.badge{display:inline-flex;padding:2px 6px;border-radius:999px;font-size:11px;background:var(--schema-badge-bg, #eef2ff);color:var(--schema-badge-fg, #4f46e5)}.hidden{display:none!important}.toolbar{display:flex;gap:6px}.schema-collection-row{position:relative;transition:transform var(--schema-collection-transition-duration, .25s) var(--schema-collection-transition-ease, ease),opacity var(--schema-collection-transition-duration, .25s) var(--schema-collection-transition-ease, ease)}.schema-collection-row.enter{opacity:0}.schema-collection-row.enter.enter-active{opacity:1}.schema-collection-row.leaving{opacity:0}.field.schema-type-array .group,.field.schema-type-array .group .row{position:relative}',_d={arrayAdd:"+",arrayMoveUp:"↑",arrayMoveDown:"↓",arrayRemove:"×",dictAdd:"+",dictRemove:"×",rootLabel:"root"},Se=(t,e)=>{customElements.get(t)||customElements.define(t,e)},fv=(t,e,i)=>{if(!e.length)return;let r=t,n=null,s=null;for(let a=0;a<e.length-1;a++){const c=e[a];let l=r?.[c];l==null?(l=typeof e[a+1]=="number"?[]:{},r[c]=l):typeof l!="object"&&(l=typeof e[a+1]=="number"?[]:{},r[c]=l),n=r,s=c,r=l}const o=e[e.length-1];if(r==null||typeof r!="object"){const a=typeof o=="number"?[]:{};if(n)n[s]=a,r=a;else return}try{r[o]=i}catch{try{const a=Array.isArray(r)?r.slice():{...r};a[o]=i,n&&(n[s]=a)}catch{}}},Br=t=>t.map(String).join("."),hv=t=>t.replace(/[^a-zA-Z0-9_-]/g,"_"),pi=t=>`schema_${hv(Br(t)||"root")}`,Ci=t=>Br(t),ne=(t,...e)=>{const i=new Set(e);i.size&&t.setAttribute("part",Array.from(i).join(" "))},pv=["wrapper","form","field","field-intersect","field-string","field-number","field-boolean","field-date","field-const","field-array","field-object","field-tuple","field-union","field-dict","field-label","field-helper","field-group","field-row","field-actions","field-button","field-button-primary","field-button-danger","field-button-secondary","field-toolbar","field-badge","field-input","field-input-text","field-input-number","field-input-date","field-input-select","field-input-textarea","field-input-checkbox","field-const-value","collection-row","field-checkbox","field-checkbox-text","field-toolbar-select"].join(" ");function ha(t,e){if(e==null)return e;switch(t){case"number":case"natural":case"percent":{if(e==="")return;const i=Number(e);return Number.isNaN(i)?void 0:i}case"boolean":return!!e;case"date":{if(!e)return;const i=new Date(e);return Number.isNaN(+i)?void 0:i}default:return e}}function xd(t){return typeof t=="function"&&!!t?.type}function kd(t){if(!t)throw new Error("schema is required");if(xd(t))return t;try{const e=Schema.from(t);if(xd(e))return e}catch{}if(t?.type){const e=t.type;if(Schema[e])return Schema[e](t.inner??t.list??t.dict)}throw new Error("无法从传入对象生成 Schemastery 实例,请传入 schema 或 schema.toJSON() 的结果。")}function mt(t){return t?.meta??{}}function gv(t){return t.length>0&&t.every(e=>e?.type==="const")}function Ii(t){if(!t)return;const e=t,i=e.meta||{};if(Object.prototype.hasOwnProperty.call(i,"default"))return i.default;const r=e.type;try{const n=t();if(n!==void 0)return n}catch{}switch(r){case"string":return"";case"number":case"natural":case"percent":return 0;case"boolean":return!1;case"array":return[];case"tuple":return[];case"object":return{};case"dict":return{};case"union":{const n=e.list||[];return n.length?Ii(n[0]):void 0}case"const":return e.value;case"date":return;case"intersect":{const n=e.list||[],s=(a,c)=>{if(Array.isArray(a)&&Array.isArray(c))return c.slice();if(a&&c&&typeof a=="object"&&typeof c=="object"){const l={...a};for(const u of Object.keys(c))l[u]=u in l?s(l[u],c[u]):c[u];return l}return c??a};let o={};for(const a of n)o=s(o,Ii(a));return o}default:return}}class Et extends HTMLElement{constructor(){super(),this._path=[],this._i18n=_d,this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=ct,this.$root.appendChild(e)}makeFieldContainer(e,i){const r=document.createElement("div");if(r.className=`field schema-form-item schema-type-${e}`,r.setAttribute("data-path",Br(this._path)),ne(r,"field",`field-${e}`),this._label){const n=document.createElement("label");n.className="label",n.textContent=this._label,ne(n,"field-label"),r.appendChild(n)}if(i&&i!==this._label){const n=document.createElement("div");n.className="helper",n.textContent=i,ne(n,"field-helper"),r.appendChild(n)}return r}set schema(e){this._schema=kd(e),this.render()}get schema(){return this._schema}set path(e){this._path=e??[],this.render()}get path(){return this._path}set label(e){this._label=e,this.render()}get label(){return this._label}set i18n(e){e&&(this._i18n={...this._i18n,...e}),this.render()}get i18n(){return this._i18n}setValue(e){this._value=e,this.render()}getValue(){return this._value}emitChange(e){this._value=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{path:this._path,value:e}}))}}class Sd extends Et{render(){if(this.$input&&this.$root.contains(this.$input)){const s=!!this.$root.querySelector("label.label");if(!(this._label&&!s)){const o=this._value??"";this.$input.value!==o&&document.activeElement!==this.$input&&(this.$input.value=o);return}}this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("string",e.description),r=document.createElement("input");this.$input=r,r.className="input",ne(r,"field-input","field-input-text"),r.type="text",r.name=Ci(this._path),r.id=pi(this._path),e?.pattern?.source&&(r.pattern=e.pattern.source),e?.max!=null&&(r.maxLength=e.max),r.value=this._value??"",r.oninput=()=>this.emitChange(ha("string",r.value));const n=i.querySelector("label.label");n&&(n.htmlFor=r.id),i.appendChild(r),this.$root.appendChild(i)}}Se("schema-form-string",Sd);class Ed extends Et{render(){if(this.$input&&this.$root.contains(this.$input)){const o=!!this.$root.querySelector("label.label");if(!(this._label&&!o)){const a=this._value??"";this.$input.value!==String(a)&&document.activeElement!==this.$input&&(this.$input.value=a);return}}this.$root.innerHTML=`<style>${ct}</style>`;const e=this._schema?.type??"number",i=mt(this._schema),r=this.makeFieldContainer("number",i.description),n=document.createElement("input");this.$input=n,n.className="input",ne(n,"field-input","field-input-number"),n.name=Ci(this._path),n.id=pi(this._path),i?.min!=null&&(n.min=String(i.min)),i?.max!=null&&(n.max=String(i.max)),i?.step!=null&&(n.step=String(i.step)),e==="percent"&&!n.step&&(n.step="0.01"),n.value=this._value??"",n.oninput=()=>this.emitChange(ha(e,n.value));const s=r.querySelector("label.label");s&&(s.htmlFor=n.id),i.role==="slider"?n.type="range":n.type="number",r.appendChild(n),this.$root.appendChild(r)}}Se("schema-form-number",Ed);class $d extends Et{render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("boolean",e.description),r=document.createElement("label");r.className="checkbox",ne(r,"field-checkbox");const n=document.createElement("input");n.type="checkbox",n.checked=!!this._value,n.name=Ci(this._path),n.id=pi(this._path),ne(n,"field-input","field-input-checkbox");const s=document.createElement("span");s.textContent=e.description??this._label??"",ne(s,"field-checkbox-text"),n.onchange=()=>this.emitChange(n.checked);const o=i.querySelector("label.label");o&&(o.htmlFor=n.id),r.append(n,s),i.appendChild(r),this.$root.appendChild(i)}}Se("schema-form-boolean",$d);function Jn(t){return String(t).padStart(2,"0")}function Hr(t){return`${t.getFullYear()}-${Jn(t.getMonth()+1)}-${Jn(t.getDate())}`}function pa(t){return`${Jn(t.getHours())}:${Jn(t.getMinutes())}`}function Zn(t){return`${Hr(t)}T${pa(t)}`}class Pd extends Et{render(){if(this.$input&&this.$root.contains(this.$input)){const o=!!this.$root.querySelector("label.label");if(!(this._label&&!o)){const a=mt(this._schema).role||"date";if(document.activeElement!==this.$input)if(this._value instanceof Date)a==="date"?this.$input.value=Hr(this._value):a==="time"?this.$input.value=pa(this._value):a==="datetime"&&(this.$input.value=Zn(this._value));else if(typeof this._value=="string"&&a!=="time"){const c=new Date(this._value);isNaN(+c)||(a==="date"?this.$input.value=Hr(c):a==="datetime"&&(this.$input.value=Zn(c)))}else this._value||(this.$input.value="");return}}this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("date",e.description),r=document.createElement("input");this.$input=r,r.className="input",ne(r,"field-input","field-input-date");const n=e.role||"date";if(n==="datetime"?r.type="datetime-local":n==="time"?r.type="time":r.type="date",r.name=Ci(this._path),r.id=pi(this._path),this._value instanceof Date)n==="date"?r.value=Hr(this._value):n==="time"?r.value=pa(this._value):n==="datetime"&&(r.value=Zn(this._value));else if(typeof this._value=="string"&&n!=="time"){const o=new Date(this._value);isNaN(+o)||(n==="date"?r.value=Hr(o):n==="datetime"&&(r.value=Zn(o)))}r.oninput=()=>{e.role;let o;if(!r.value)o=void 0;else{const a=new Date(r.value);o=Number.isNaN(+a)?void 0:a}this.emitChange(o)};const s=i.querySelector("label.label");s&&(s.htmlFor=r.id),i.appendChild(r),this.$root.appendChild(i)}}Se("schema-form-date",Pd);class ga extends Et{render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this._schema.value;if(e.role==="raw-html"){if(i instanceof Node){this.$root.append(i);return}else if(typeof i=="function"){this.$root.append(i());return}else if(typeof i=="string"){const o=document.createElement("div");o.innerHTML=String(i),ne(o,"field-const-value"),this.$root.appendChild(o);return}}const r=this.makeFieldContainer("const",e.description),n=document.createElement("section");n.className="const content",n.textContent=String(i),n.id=pi(this._path),ne(n,"field-const-value");const s=r.querySelector("label.label");s&&(s.htmlFor=n.id),r.appendChild(n),this.$root.appendChild(r)}}Se("schema-form-const",ga);class Cd extends Et{render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("intersect",e.description);i.classList.remove("field");const r=document.createElement("div");r.classList.add("group"),ne(r,"field-group");const n=this._schema.list||[],s=n.length>0&&n.every(a=>a?.type==="object"),o=(a,c)=>{if(Array.isArray(a)&&Array.isArray(c))return c.slice();if(a&&c&&typeof a=="object"&&typeof c=="object"){const l={...a};for(const u of Object.keys(c))l[u]=u in l?o(l[u],c[u]):c[u];return l}return c??a};if(s){const a=this._value&&typeof this._value=="object"?this._value:{};n.forEach((c,l)=>{const u=c?.meta?.description??"",d=gi(c,this._path,a,u,this._i18n);d.addEventListener("change",y=>{y.stopPropagation();const p=o(this._value??{},y.detail.value);this.emitChange(p)}),r.appendChild(d)})}else{const a=n[n.length-1],c=gi(a,this._path,this._value,this._label,this._i18n);c.addEventListener("change",l=>{l.stopPropagation(),this.emitChange(l.detail.value)}),r.appendChild(c)}i.appendChild(r),this.$root.appendChild(i)}}Se("schema-form-intersect",Cd);function mv(t){switch(t.type){case"intersect":return"schema-form-intersect";case"string":return"schema-form-string";case"number":case"natural":case"percent":return"schema-form-number";case"boolean":return"schema-form-boolean";case"date":return"schema-form-date";case"const":return"schema-form-const";case"array":return"schema-form-array";case"object":return"schema-form-object";case"tuple":return"schema-form-tuple";case"dict":return"schema-form-dict";case"union":{const e=t.list||[];return e.length===2&&e[0]?.type==="is"&&e[0]?.constructor===Date&&e[1]?.type==="transform"&&(e[1]?.inner?.meta?.role==="datetime"||e[1]?.inner?.meta?.role==="date"||e[1]?.inner?.meta?.role==="time")?"schema-form-date":"schema-form-union"}default:return"schema-form-string"}}function gi(t,e,i,r,n){const s=mv(t),o=document.createElement(s);return o.schema=t,o.path=e,o.label=r,n&&(o.i18n=n),o.setValue?.(i),o.setAttribute("exportparts",pv),o}class Id extends Et{render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("union",e.description),r=this._schema.list||[];if(gv(r)){const n=document.createElement("select");n.className="input",ne(n,"field-input","field-input-select"),n.name=Ci(this._path),n.id=pi(this._path),r.forEach(o=>{const a=document.createElement("option");a.value=String(o.value),a.textContent=String(o.meta?.description||o.value||o.type),this._value===o.value&&(a.selected=!0),n.appendChild(a)}),n.onchange=()=>this.emitChange(ha("string",n.value));const s=i.querySelector("label.label");s&&(s.htmlFor=n.id),i.appendChild(n)}else{const n=document.createElement("div");n.className="toolbar",ne(n,"field-toolbar");const s=document.createElement("select");s.className="input",ne(s,"field-input","field-input-select","field-toolbar-select"),s.name=Ci(this._path)+".__type",s.id=pi(this._path)+"__type";let o=0;r.forEach((u,d)=>{const y=document.createElement("option");y.value=String(d),y.textContent=String(u.meta?.description||u.value||u.type),s.appendChild(y)}),s.onchange=()=>{o=Number(s.value);const u=r[o],d=Ii(u);this.emitChange(d),l()};const a=i.querySelector("label.label");a&&(a.htmlFor=s.id),n.appendChild(s),i.appendChild(n);const c=document.createElement("div");c.className="group",ne(c,"field-group");const l=()=>{c.innerHTML="";const u=r[o],d=gi(u,this._path,this._value,this._label);d instanceof ga||(d.addEventListener("change",y=>{y.stopPropagation(),this.emitChange(y.detail.value)}),c.appendChild(d))};l(),i.appendChild(c)}this.$root.appendChild(i)}}Se("schema-form-union",Id);class Rd extends Et{render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("tuple",e.description),r=document.createElement("div");r.className="group",ne(r,"field-group");const n=Array.isArray(this._value)?this._value:[];(this._schema.list||[]).forEach((s,o)=>{const a=gi(s,[...this._path,o],n[o],`${this._label??""}[${o}]`);a.addEventListener("change",c=>{c.stopPropagation();const l=Array.isArray(this._value)?this._value.slice():[];l[o]=c.detail.value,this.emitChange(l)}),r.appendChild(a)}),i.appendChild(r),this.$root.appendChild(i)}}Se("schema-form-tuple",Rd);class Ad extends Et{render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("object",e.description),r=document.createElement("div");r.className="group",ne(r,"field-group");const n=this._schema.dict||{};Object.keys(n).forEach(s=>{if(n[s]?.meta?.hidden)return;const o=(this._value??{})[s],a=gi(n[s],[...this._path,s],o,s);a.addEventListener("change",c=>{c.stopPropagation();const l={...this._value??{}};l[s]=c.detail.value,this.emitChange(l)}),r.appendChild(a)}),i.appendChild(r),this.$root.appendChild(i)}}Se("schema-form-object",Ad);const ys=class ys extends Et{constructor(){super(...arguments),this._itemIds=[]}generateItemId(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return"i"+ys._idCounter++}ensureItemIds(e){for(;this._itemIds.length<e;)this._itemIds.push(this.generateItemId());this._itemIds.length>e&&(this._itemIds.length=e)}capturePositions(e){const i={};return e.querySelectorAll(".row").forEach(r=>{const n=r.dataset.uid;n&&(i[n]=r.getBoundingClientRect())}),i}playFLIP(e,i){Array.from(e.querySelectorAll(".row")).forEach(r=>{const n=r.dataset.uid;if(!n)return;const s=i[n];if(!s)return;const o=r.getBoundingClientRect(),a=s.left-o.left,c=s.top-o.top;(a||c)&&(r.style.transition="none",r.style.transform=`translate(${a}px, ${c}px)`,requestAnimationFrame(()=>{r.style.transition="transform .25s ease",r.style.transform=""}))})}render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("array",e.description),r=document.createElement("div");r.className="group",ne(r,"field-group");const n=this._schema.inner,s=()=>Array.isArray(this._value)?this._value:[];this.ensureItemIds(s().length);const o=(l,u)=>{r.innerHTML="",s().forEach((d,y)=>{const p=[...this._path,y],h=document.createElement("div");h.className="row schema-collection-row",ne(h,"field-row","collection-row");const _=this._itemIds[y];h.dataset.uid=_,h.setAttribute("data-path",Br(p));const k=gi(n,p,d,`${this._label??""}[${y}]`);k.addEventListener("change",w=>{w.stopPropagation();const S=s().slice();S[y]=w.detail.value,this._value=S,this.emitChange(S)});const P=document.createElement("div");P.className="actions",ne(P,"field-actions");const b=document.createElement("button");b.type="button",b.className="btn",ne(b,"field-button","field-button-secondary"),b.textContent=this._i18n.arrayMoveUp??"↑",b.onclick=()=>{if(y<=0)return;const w=this.capturePositions(r),S=s().slice();[S[y-1],S[y]]=[S[y],S[y-1]],[this._itemIds[y-1],this._itemIds[y]]=[this._itemIds[y],this._itemIds[y-1]],this._value=S,o(w),this.emitChange(S)};const m=document.createElement("button");m.type="button",m.className="btn",ne(m,"field-button","field-button-secondary"),m.textContent=this._i18n.arrayMoveDown??"↓",m.onclick=()=>{const w=s();if(y>=w.length-1)return;const S=this.capturePositions(r),I=w.slice();[I[y+1],I[y]]=[I[y],I[y+1]],[this._itemIds[y+1],this._itemIds[y]]=[this._itemIds[y],this._itemIds[y+1]],this._value=I,o(S),this.emitChange(I)};const g=document.createElement("button");g.type="button",g.className="btn danger",ne(g,"field-button","field-button-danger"),g.textContent=this._i18n.arrayRemove??"×",g.onclick=()=>{h.classList.add("leaving");const w=250;let S=!1;const I=()=>{if(S)return;S=!0,clearTimeout(F);const N=s().filter((K,qe)=>qe!==y);this._itemIds.splice(y,1);const G=this.capturePositions(r);this._value=N,o(G),this.emitChange(N)};h.addEventListener("transitionend",I,{once:!0});const F=setTimeout(I,w+80)},P.append(b,m,g),h.appendChild(k),h.appendChild(P),r.appendChild(h),u&&u===_&&(h.classList.add("enter"),requestAnimationFrame(()=>{h.classList.add("enter-active")}),requestAnimationFrame(()=>{h.classList.remove("enter")}))}),l&&this.playFLIP(r,l)};o();const a=document.createElement("button");a.type="button",a.className="btn primary",ne(a,"field-button","field-button-primary"),a.textContent=this._i18n.arrayAdd??"+",a.onclick=()=>{const l=this.capturePositions(r),u=s().slice(),d=Ii(n);u.push(d);const y=this.generateItemId();this._itemIds.push(y),this._value=u,o(l,y),this.emitChange(u)};const c=document.createElement("div");c.className="actions",ne(c,"field-actions"),c.appendChild(a),i.appendChild(r),i.appendChild(c),this.$root.appendChild(i)}};ys._idCounter=0;let es=ys;Se("schema-form-array",es);class Td extends Et{render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("dict",e.description),r=document.createElement("div");r.className="group",ne(r,"field-group");const n=this._schema.inner,s=this._value??{},o=y=>`d_${y}`,a=()=>{const y={};return r.querySelectorAll(".kv").forEach(p=>{const h=p.dataset.uid;h&&(y[h]=p.getBoundingClientRect())}),y},c=y=>{r.querySelectorAll(".kv").forEach(p=>{const h=p.dataset.uid;if(!h)return;const _=y[h];if(!_)return;const k=p.getBoundingClientRect(),P=_.left-k.left,b=_.top-k.top;(P||b)&&(p.style.transition="none",p.style.transform=`translate(${P}px, ${b}px)`,requestAnimationFrame(()=>{p.style.transition="transform .25s ease",p.style.transform=""}))})},l=(y,p)=>{r.innerHTML="",Object.keys(s).forEach(h=>{const _=[...this._path,h],k=document.createElement("div");k.className="kv schema-collection-row",ne(k,"field-row","collection-row"),k.dataset.uid=o(h),k.setAttribute("data-path",Br(_));const P=document.createElement("input");P.className="input",ne(P,"field-input","field-input-text"),P.value=h,P.name=Ci(_)+".__key",P.id=pi(_)+"__key";const b=gi(n,_,s[h],`${this._label??""}[${h}]`),m=document.createElement("button");m.type="button",m.className="btn danger",ne(m,"field-button","field-button-danger"),m.textContent=this._i18n.dictRemove??"×",m.onclick=()=>{const g=a();delete s[h];const w={...this._value??{}};delete w[h],this._value=w,l(g),this.emitChange(w)},P.onchange=()=>{const g=P.value.trim();if(!g||g===h||s[g]!==void 0)return;const w=a();s[g]=s[h],delete s[h];const S={...this._value??{}};S[g]=S[h],delete S[h],this._value=S,l(w),this.emitChange(S)},b.addEventListener("change",g=>{g.stopPropagation();const w={...this._value??{}};w[h]=g.detail.value,this._value=w,this.emitChange(w)}),k.append(P,b,m),r.appendChild(k),p===h&&(k.classList.add("enter"),requestAnimationFrame(()=>k.classList.add("enter-active")),requestAnimationFrame(()=>k.classList.remove("enter")))}),y&&c(y)};l();const u=document.createElement("button");u.type="button",u.className="btn primary",ne(u,"field-button","field-button-primary"),u.textContent=this._i18n.dictAdd??"+",u.onclick=()=>{let y=Object.keys(s).length+1,p=`k${y}`;for(;s[p]!==void 0;)p=`k${++y}`;const h=a();s[p]=Ii(n);const _={...this._value??{},[p]:s[p]};this._value=_,l(h,p),this.emitChange(_)};const d=document.createElement("div");d.className="actions",ne(d,"field-actions"),d.appendChild(u),i.appendChild(r),i.appendChild(d),this.$root.appendChild(i)}}Se("schema-form-dict",Td);class Od extends HTMLElement{constructor(){super(),this._i18n={..._d},this._i18nCommitted=!1,this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=ct,this.$root.appendChild(e);const i=document.createElement("div");i.className="wrapper",ne(i,"wrapper");const r=document.createElement("form");r.className="form",ne(r,"form"),i.appendChild(r),this.$root.appendChild(i),this.addEventListener("change",n=>{if(!n?.detail)return;const{path:s,value:o}=n.detail;Array.isArray(s)&&s.length===0?this._state=o:fv(this._state??(this._state={}),s,o),this.dispatchEvent(new CustomEvent("form-change",{detail:{path:s,value:o,state:this._state}}))})}set schema(e){this._schema=kd(e);try{this._state=this._schema(null,{autofix:!0})}catch{this._state=Ii(this._schema)}this.render()}get schema(){return this._schema}set schemaJSON(e){this.schema=e}get schemaJSON(){return this._schema?.toJSON?.()}setData(e,i={validate:!0,autofix:!0}){if(!this._schema)throw new Error("请先设置 schema");const r=i.validate?this._schema(e??null,{autofix:i.autofix}):e;this._state=r,this.render()}getData(e={validate:!0,autofix:!0}){if(!this._schema)throw new Error("请先设置 schema");const i=this._state;return e.validate?this._schema(i??null,{autofix:e.autofix}):i}reset(){try{this._state=this._schema(null,{autofix:!0})}catch{this._state=Ii(this._schema)}this.render()}refresh(){this.render()}set i18n(e){this._i18nCommitted||(this._i18n={...this._i18n,...e},this._i18nCommitted=!0,this.render())}get i18n(){return this._i18n}render(){if(!this._schema)return;const e=this.$root.querySelector("form");e.innerHTML="";const i=gi(this._schema,[],this._state,this._i18n.rootLabel,this._i18n);e.appendChild(i)}}Se("schema-form",Od);function yv(){Se("schema-form",Od),Se("schema-form-string",Sd),Se("schema-form-number",Ed),Se("schema-form-boolean",$d),Se("schema-form-date",Pd),Se("schema-form-const",ga),Se("schema-form-union",Id),Se("schema-form-tuple",Rd),Se("schema-form-object",Ad),Se("schema-form-array",es),Se("schema-form-dict",Td),Se("schema-form-intersect",Cd)}const bv=$i({__name:"SchemasteryFormVue",props:gu({schema:{},value:{},validateOnChange:{type:Boolean,default:!1}},{schema:{required:!0},schemaModifiers:{},value:{required:!1,default:{}},valueModifiers:{}}),emits:gu(["change"],["update:schema","update:value"]),setup(t,{expose:e,emit:i}){const r=xu(t,"schema"),n=xu(t,"value"),s=i,o=cu("elRef");let a=!1,c=!1;const l=u=>{if(c)return;const d=o.value,y=t.validateOnChange?d.getData({validate:!0}):u.detail.state;a=!0,n.value=y,Ir(()=>{a=!1}),s("change",u.detail)};return hu(()=>{yv()}),Lr(()=>{const u=o.value;r.value&&(u.schema=r.value),n.value!==void 0&&u.setData(n.value,{validate:!1,autofix:!0}),u.addEventListener("form-change",l)}),Ho(()=>{o.value?.removeEventListener("form-change",l)}),Gi(r,u=>{a||o.value&&u&&o.value.schema!==u&&(c=!0,o.value.schema=u,Ir(()=>{c=!1}))},{deep:!0,immediate:!0}),Gi(n,u=>{if(a||!o.value||u===void 0)return;const d=o.value.getData({validate:!1});JSON.stringify(d)!==JSON.stringify(u)&&(c=!0,o.value.setData(u,{validate:!1}),Ir(()=>{c=!1}))},{deep:!0,immediate:!0}),e({setData(u,d){const y=o.value;y.setData(u,{validate:!!d?.validate}),d?.emit&&(n.value=y.getData({validate:!!d?.validate}))},getData(u){return o.value.getData(u)},setSchema(u,d=!0){o.value.schema=u,d&&(r.value=u)},refresh(){o.value.refresh()},reset(){o.value.reset()},el:o}),(u,d)=>(de(),ve("schema-form",zu({ref_key:"elRef",ref:o},u.$attrs),null,16))}});function Ri(t,e=new WeakMap){if(De(t))return Ri(t.value,e);if(t===null||typeof t!="object")return t;if(e.has(t))return e.get(t);if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if(t instanceof Map){const n=new Map;return e.set(t,n),Array.from(t.entries()).forEach(([s,o])=>{n.set(s,Ri(o,e))}),n}if(t instanceof Set){const n=new Set;return e.set(t,n),Array.from(t).forEach(s=>{n.add(Ri(s,e))}),n}if(Array.isArray(t)){const n=[];e.set(t,n);for(const s of t)n.push(Ri(s,e));return n}const i=oe(t),r={};e.set(t,r);for(const n of Object.keys(i))r[n]=Ri(i[n],e);for(const n of Object.getOwnPropertySymbols(i))r[n]=Ri(i[n],e);return r}const ma=()=>{},vv={id:"preferences-ui-app"},wv={class:"tabbar"},_v={class:"tabbar-tabs"},xv=["onClick","data-value"],kv={class:"tabbar-content"},Sv={key:0},Ev={style:{"max-height":"20em",overflow:"auto"}},$v=$i({__name:"PreferencesApp",setup(t,{expose:e}){const i=ua(),r=!1,n=Yc([]),s=Qe([]),o=Qe(""),a=Bt(()=>s.value.find(h=>h.name===o.value)||null),c=Bt(()=>{const h=n.value.filter(_=>_.category===o.value).map(_=>_.schema);return h.length===0?null:R.intersect(h)}),l=Bt(()=>a.value&&typeof a.value.autoGenerateForm=="boolean"?a.value.autoGenerateForm:!0),u=Qe({});e({getValue(){return Ri(u)},mergeValue(h){u.value={...u.value,...h}},selectTab(h){o.value=h}}),Lr(async()=>{i.inject(["preferences"],async h=>{const _=await h.preferences.getAll();u.value=_,s.value=h.preferences.getConfigCategories(),n.value=h.preferences.getConfigRegistries(),o.value=s.value[0].name})});const d=(h,_)=>{h.preventDefault(),o.value=_;const k=h.currentTarget;k&&k.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},y=cu("customRenderContainerRef"),p=Qe([]);return zo(()=>{p.value.forEach(h=>h()),p.value=[]}),Gi(a,async h=>{p.value.forEach(k=>k()),p.value=[],await Ir();const _=y.value;if(_&&(_.innerText="",h&&typeof h.customRenderer=="function")){let k=ma;const P=g=>{k=g},b=g=>{p.value.push(g)},m=await h.customRenderer({ctx:i,onMounted:P,onUnmount:b});m&&(_.appendChild(m),k?.(_))}},{immediate:!0,deep:!1}),(h,_)=>(de(),ve("div",vv,[ie("div",wv,[ie("div",_v,[(de(!0),ve(We,null,Wo(s.value,k=>(de(),ve("a",{class:xt(["tab",{active:o.value===k.name}]),key:k.name,onClick:P=>d(P,k.name),"data-value":k.name},ye(k.label),11,xv))),128))]),ie("div",kv,[a.value&&a.value.customRenderer?(de(),ve("div",{class:"custom-render-container",ref_key:"customRenderContainerRef",ref:y,key:o.value})):fi("",!0),l.value&&c.value?(de(),Wn(Oe(bv),{class:"auto-schema-form",key:o.value,"data-category":o.value,schema:c.value,value:u.value,"onUpdate:value":_[0]||(_[0]=k=>u.value={...u.value,...k}),"validate-on-change":!1,i18n:{rootLabel:""}},null,8,["data-category","schema","value"])):fi("",!0)])]),Oe(r)?(de(),ve("details",Sv,[ie("pre",Ev,ye(u.value),1)])):fi("",!0)]))}}),ts=(t,e)=>{const i=t.__vccOpts||t;for(const[r,n]of e)i[r]=n;return i},Pv=ts($v,[["__scopeId","data-v-775e2739"]]);var Cv=Object.create,ya=Object.defineProperty,Iv=Object.getOwnPropertyDescriptor,Ld=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Nd=t=>{throw TypeError(t)},Rv=(t,e,i)=>e in t?ya(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Av=(t,e)=>ya(t,"name",{value:e,configurable:!0}),Tv=t=>[,,,Cv(t?.[Ld("metadata")]??null)],Ov=["class","method","getter","setter","accessor","field","value","get","set"],Md=t=>t!==void 0&&typeof t!="function"?Nd("Function expected"):t,Lv=(t,e,i,r,n)=>({kind:Ov[t],name:e,metadata:r,addInitializer:s=>i._?Nd("Already initialized"):n.push(Md(s||null))}),Nv=(t,e)=>Rv(e,Ld("metadata"),t[3]),Mv=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Dv=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&Iv(n,i));Av(n,i);for(var h=r.length-1;h>=0;h--)c=Lv(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,Md(o)&&(n=o);return Nv(t,n),p&&ya(n,i,p),u?l^4?s:p:n},Dd,ba,jd;Dd=[xe(["preferences","modal","$","$$"])];class is extends(jd=Ue){constructor(e){super(e,{},"preferences-ui"),this.ctx=e,this._modal=null,this._form=null,e.set("preferencesUI",this);const i=e.$,r=e.$$;e.preferences.defineCategory({name:"general",label:i`prefs.general.label`,description:i`prefs.general.description`,autoGenerateForm:!0}),e.preferences.defineCategory({name:"editor",label:i`prefs.editor.label`,description:i`prefs.editor.description`,autoGenerateForm:!0}),e.preferences.defineCategory({name:"about",label:r`prefs.about.label`,description:r`prefs.about.description`,index:99,customRenderer:()=>f("section",{className:"theme-ipe-prose",children:[f("h2",{children:"✏️ InPageEdit NEXT"}),f("p",{children:r`prefs.about.intro`}),f("h3",{children:r`prefs.about.portals.header`}),f("ul",{children:[f("li",{children:f("a",{href:this.ctx.Endpoints.HOME_URL,target:"_blank",children:r`prefs.about.portals.officialwebsite`})}),f("li",{children:f("a",{href:`${this.ctx.Endpoints.UPDATE_LOGS_URL}#${this.ctx.version.split("-")[0]}`,target:"_blank",children:r`prefs.about.portals.updatelogs`})})]}),f("h3",{children:r`prefs.about.joinus.header`}),f("ul",{children:[f("li",{children:[f("strong",{children:r`prefs.about.joinus.github`}),":"," ",f("a",{href:this.ctx.Endpoints.GITHUB_URL,target:"_blank",children:`${this.ctx.Endpoints.GITHUB_OWNER}/${this.ctx.Endpoints.GITHUB_REPO}`})]}),f("li",{children:[f("strong",{children:r`prefs.about.joinus.qqgroup`}),": ",this.ctx.Endpoints.QQ_GROUP_ID]})]}),f("hr",{}),f("p",{style:{textAlign:"center"},children:r`prefs.about.copyright`}),f("hr",{})]})}),e.inject(["toolbox"],n=>{n.toolbox.addButton({id:"preferences",icon:f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-settings",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M14.647 4.081a.724 .724 0 0 0 1.08 .448c2.439 -1.485 5.23 1.305 3.745 3.744a.724 .724 0 0 0 .447 1.08c2.775 .673 2.775 4.62 0 5.294a.724 .724 0 0 0 -.448 1.08c1.485 2.439 -1.305 5.23 -3.744 3.745a.724 .724 0 0 0 -1.08 .447c-.673 2.775 -4.62 2.775 -5.294 0a.724 .724 0 0 0 -1.08 -.448c-2.439 1.485 -5.23 -1.305 -3.745 -3.744a.724 .724 0 0 0 -.447 -1.08c-2.775 -.673 -2.775 -4.62 0 -5.294a.724 .724 0 0 0 .448 -1.08c-1.485 -2.439 1.305 -5.23 3.744 -3.745a.722 .722 0 0 0 1.08 -.447c.673 -2.775 4.62 -2.775 5.294 0zm-2.647 4.919a3 3 0 1 0 0 6a3 3 0 0 0 0 -6z"})]}),tooltip:()=>i`Configure Preferences`,group:"group2",index:99,onClick:()=>this.showModal()}),this.addDisposeHandler(s=>{s.toolbox.removeButton("preferences")})})}async start(){Promise.resolve().then(()=>u0).then(({PluginPrefSync:e})=>{this.ctx.plugin(e)}).catch(this.ctx.logger.warn),this.ctx.on("preferences/changed",e=>{this._form?.mergeValue?.(e.input)})}stop(){}showModal(){const{$:e}=this.ctx;if(this._modal&&!this._modal.isDestroyed)return this._modal;const i=this.ctx.modal.show({className:"ipe-preference compact-buttons",sizeClass:"small",outSideClose:!1,center:!0,title:`${e`InPageEdit Preferences`} (${this.ctx.version})`,content:f(bi,{children:f(_i,{})})});i.get$window().classList.add("dialog");const r=f("div",{id:"ipe-preferences-app",style:{minHeight:"calc(85dvh - var(--ipe-modal-spacing) * 2)"}});i.setContent(r),this.ctx.emit("preferences-ui/modal-shown",{ctx:this.ctx,modal:i});const n=this.createPreferencesUIApp(),s=n.mount(r);return this._form=s,this.ctx.emit("preferences-ui/vue-app-mounted",{ctx:this.ctx,app:n,form:s}),i.setButtons([{label:e`Close`,className:"is-ghost",method:()=>{i.close()}},{label:e`Save`,className:"is-primary is-ghost",method:async()=>{const o=s.getValue();try{const a=await this.ctx.preferences.setMany(o);this.logger.info("preferences saved",o,a)}catch(a){this.logger.error("failed to save preferences",a)}i.close(),this.ctx.modal.notify("success",{title:e`Preferences Saved`,content:f("p",{children:e`Some settings may take effect after reloading the page.`})})}}]),this._modal=i,i.on(i.Event.Close,()=>{this.logger.debug("preferences modal closed, vue app unmounting"),n.unmount(),this._modal=null,this._form=null,this.ctx.emit("preferences-ui/modal-closed",{ctx:this.ctx,modal:i})}),i}getCurrentModal(){return this._modal}closeCurrentModal(){return this._modal?.close()}async dispatchFormSave(e){e=e||this._form||void 0;const i=e?.getValue();return i?(this.ctx.preferences.setMany(i),!0):!1}getCurrentFormValue(){return this._form?.getValue()}mergeFormValue(e){return this._form?.mergeValue?.(e),!!this._form?.mergeValue}createPreferencesUIApp(){return hd(this.ctx,Pv)}}ba=Tv(jd),is=Dv(ba,0,"PluginPreferencesUI",Dd,is),Mv(ba,1,is);const jv=Object.freeze(Object.defineProperty({__proto__:null,get PluginPreferencesUI(){return is}},Symbol.toStringTag,{value:"Module"})),Uv=Symbol("@@apply"),Fv=Symbol("@@ctor");function Ud(t,e){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError("instance is not an object");const i=(...s)=>{const o=t[e];if(typeof o!="function")throw new TypeError(`Property "${String(e)}" is not a function`);return o.apply(t,s)};i[Uv]=i,i[Fv]=t;const r=t?.constructor?.name;return r&&(i[Symbol.toStringTag]=r),new Proxy(i,{get(s,o,a){return o==="prototype"?Reflect.get(i,o,a):Reflect.get(t,o,t)},set(s,o,a){return Reflect.set(t,o,a)},has(s,o){return Reflect.has(t,o)},deleteProperty(s,o){return Reflect.deleteProperty(t,o)},ownKeys(){return Reflect.ownKeys(t)},getOwnPropertyDescriptor(s,o){return Object.getOwnPropertyDescriptor(t,o)},defineProperty(s,o,a){return Object.defineProperty(t,o,a)}})}const rs={mbox:"_mbox_5x43w_1",title:"_title_5x43w_12",content:"_content_5x43w_19",close:"_close_5x43w_27"},va=t=>{const{type:e="default",title:i,content:r,closeable:n=!0,titleProps:s,contentProps:o,children:a,...c}=t;let l=i;typeof i>"u"&&e!=="default"&&(l=e[0].toUpperCase()+e.slice(1).toLowerCase());const u=async()=>{if(!d)return Promise.resolve();const{promise:y,resolve:p}=wr();return d.animate([{opacity:"1",height:d.clientHeight+"px"},{opacity:"0",height:"0px",margin:"0px"}],{duration:300,easing:"ease"}).addEventListener("finish",()=>{d.remove(),p()}),y},d=f("div",{className:`theme-ipe ipe-mbox mbox-type-${e||"default"} ${rs.mbox}`,...c,children:[l&&f("div",{className:`ipe-mbox-title ${rs.title}`,...s,children:l}),f("div",{className:`ipe-mbox-content ${rs.content}`,...o,children:a||r}),n&&f("a",{onClick:u,className:`ipe-mbox-close ${rs.close}`,children:"×"})]});return d.close=u,d},ns=t=>{const{label:e,id:i,name:r,value:n,placeholder:s,disabled:o,required:a,labelProps:c,inputProps:l,children:u,...d}=t;return f("div",{className:"theme-ipe ipe-input-box",...d,children:[f("label",{htmlFor:i,style:{display:"block"},...c,children:[e,a&&f(bi,{children:[" ",f("span",{className:"required",children:"*"})]})]}),u??f("input",{id:i,name:r,value:n,disabled:o,placeholder:s,required:a,style:{width:"100%"},...l})]})},qv=t=>{const{id:e,name:i,value:r,label:n,inputProps:s,labelProps:o,children:a,...c}=t;return f("label",{className:"theme-ipe ipe-radio-box",...c,children:[f("input",{type:"radio",id:e,name:i,value:r,...s}),f("span",{className:"ipe-checkbox-box"}),f("span",{...o,children:n||a})]})},Ai=t=>{const{id:e,name:i,label:r,checked:n,inputProps:s,labelProps:o,children:a,...c}=t;return f("label",{className:"theme-ipe ipe-checkbox",...c,children:[f("input",{type:"checkbox",id:e,name:i,checked:n,...s}),f("span",{className:"ipe-checkbox-box"}),f("span",{...o,children:r||a})]})},Bv=(t=0)=>new Promise(e=>setTimeout(e,t)),Fd=t=>f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...t,class:`icon icon-tabler icons-tabler-outline icon-tabler-pencil-bolt ${t.className||""}`,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),f("path",{d:"M13.5 6.5l4 4"}),f("path",{d:"M19 16l-2 3h4l-2 3"})]});var Hv=Object.create,wa=Object.defineProperty,zv=Object.getOwnPropertyDescriptor,qd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Bd=t=>{throw TypeError(t)},Wv=(t,e,i)=>e in t?wa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Kv=(t,e)=>wa(t,"name",{value:e,configurable:!0}),Vv=t=>[,,,Hv(t?.[qd("metadata")]??null)],Gv=["class","method","getter","setter","accessor","field","value","get","set"],Hd=t=>t!==void 0&&typeof t!="function"?Bd("Function expected"):t,Qv=(t,e,i,r,n)=>({kind:Gv[t],name:e,metadata:r,addInitializer:s=>i._?Bd("Already initialized"):n.push(Hd(s||null))}),Yv=(t,e)=>Wv(e,qd("metadata"),t[3]),Xv=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Jv=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&zv(n,i));Kv(n,i);for(var h=r.length-1;h>=0;h--)c=Qv(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,Hd(o)&&(n=o);return Yv(t,n),p&&wa(n,i,p),u?l^4?s:p:n},zd,_a,Wd;zd=[xe(["api","wikiPage","wikiTitle","currentPage","wiki","modal","preferences","$"]),Tt(R.object({"quickEdit.editSummary":R.string().description("Default edit summary for quick edits").default("[IPE-NEXT] Quick edit"),"quickEdit.editMinor":R.boolean().description('Default to checking "minor edit" option').default(!1),"quickEdit.outSideClose":R.boolean().description("Close editor modal by clicking outside").default(!0),"quickEdit.watchList":R.union([R.const(_t.preferences).description("Follow MW preferences"),R.const(_t.nochange).description("Keep the current watchlist status"),R.const(_t.watch).description("Add the page to watchlist"),R.const(_t.unwatch).description("Remove the page from watchlist")]).description("Watchlist options").default(_t.preferences),"quickEdit.keyshortcut.save":R.string().default("ctrl-s").description("save button key shortcut (blank to disable)"),"quickEdit.editFont":R.union([R.const("preferences").description("Follow MW preferences"),R.const("monospace").description("Monospace"),R.const("sans-serif").description("Sans-serif"),R.const("serif").description("Serif"),R.string().description("Custom font (same as CSS `font-family` property)").default("")]).description("Font to use in quick edit's textarea").default("preferences")}).description("Quick edit options").extra("category","editor"))];let ss=(Oi=class extends(Wd=Ue){constructor(e){super(e,{},"quick-edit"),this.ctx=e,this.DEFAULT_OPTIONS={title:"",pageId:0,revision:0,section:void 0,editMinor:!1,editSummary:"",createOnly:!1,reloadAfterSave:!0},this.ctx.root.set("quickEdit",Ud(this,"showModal"))}start(){this.ctx.inject(["toolbox"],e=>{this.injectToolbox(e),e.on("dispose",()=>{this.removeToolbox(e)})})}async showModal(e){const{$:i}=this.ctx;if(typeof e>"u"?e={}:typeof e=="string"&&(e={title:e}),e?.page&&(e.title=e.page,delete e.page),!e.title&&!e.pageId&&!e.revision){this.logger.warn("None of the title, pageId or revision provided. Using defaults.");const g=new URLSearchParams(window.location.search),w=this.ctx.currentPage.wikiTitle;e={...e,title:w?.getPrefixedDBKey(),revision:g.has("oldid")?Number(g.get("oldid")):void 0,pageId:g.has("curid")?Number(g.get("curid")):void 0}}if(!e.revision&&!e.pageId&&e.title){const g=this.ctx.wikiTitle.resolveSpecialPageTarget(e.title);g&&g.title.getNamespaceId()>=0&&(e.title=g.title.getPrefixedDBKey(),e.section??(e.section=g.section))}const r=await this.ctx.preferences.get("quickEdit.outSideClose"),n=await this.ctx.preferences.get("quickEdit.watchList"),s=typeof e.editSummary=="string"?e.editSummary:await this.ctx.preferences.get("quickEdit.editSummary"),o=typeof e.editMinor=="boolean"?e.editMinor:await this.ctx.preferences.get("quickEdit.editMinor"),a=await this.getEditFontOptions(),c={...this.DEFAULT_OPTIONS,editSummary:s,editMinor:o,...e};c.editSummary||(c.editSummary=await this.ctx.preferences.get("quickEdit.editSummary")||""),this.ctx.emit("quick-edit/init-options",{ctx:this.ctx,options:c});const l=this.ctx.modal.createObject({className:"ipe-quickEdit",sizeClass:"large",center:!1,outSideClose:r}).init();l.setTitle(f(bi,{children:["Loading: ",f("u",{children:c.title})]})),l.setContent(f("section",{className:"ipe-quickEdit-loading",style:{height:"70vh",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:f(_i,{})})),l.addButton({side:"right",type:"button",className:"is-danger is-ghost",label:i`Cancel`,method(){l.close()}}),l.show(),this.ctx.emit("quick-edit/show-modal",{ctx:this.ctx,modal:l,options:c});let u;try{if(u=await this.getWikiPageFromPayload(c),u.pageInfo.special)throw new Error(i`Special page is not editable.`)}catch(g){l.off(l.Event.Close),l.close(),this.ctx.modal.notify("error",{content:g instanceof Error?g.message:String(g)});return}const d=c.section==="new"?"":u.revisions[0]?.content||"",y=u.revisions[0]?.revid,p=y&&y!==u.lastrevid,h=c.section==="new",_=u.pageid===0;l.setTitle(f(bi,{children:[h?i`New Section`:i`Quick ${_?"Create":"Edit"}`,": ",f("u",{children:u.pageInfo.title}),p?` (${i`Revision`} ${y})`:""]}));const k=[];_&&k.push(f(va,{title:i`Attention`,type:"important",children:f("p",{children:i`This page does not exist.`})})),p&&k.push(f(va,{title:i`Attention`,type:"warning",children:f("p",{innerHTML:i`You are editing a <em>historical version</em>; the content is not the latest!`})})),this.ctx.emit("quick-edit/edit-notice",{ctx:this.ctx,options:c,modal:l,wikiPage:u,editNotices:k});const P=f("form",{className:"ipe-quickEdit__form",children:[f("div",{className:"ipe-quickEdit__notices",children:k}),f("div",{className:"ipe-quickEdit__content",style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[c.section==="new"&&f(bi,{children:f(ns,{label:i`Section title`,id:"summary",name:"summary",value:"",inputProps:{placeholder:i`Topic for new section, this will be the h2 heading`}})}),f("textarea",{className:`ipe-quickEdit__textarea ${a.className}`,style:{fontFamily:a.fontFamily},name:"text",id:"wpTextbox1",children:d})]}),f("div",{class:"ipe-quickEdit__options",style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[!h&&f(ns,{label:i`Summary`,id:"summary",name:"summary",value:c.editSummary}),f("div",{className:"ipe-input-box",children:[f("label",{htmlFor:"watchlist",style:{display:"block"},children:i`Watchlist`}),f("div",{style:{display:"flex",gap:"1rem",whiteSpace:"nowrap",overflowX:"auto"},children:[_t.preferences,_t.nochange,_t.watch,_t.unwatch].map(g=>f(qv,{name:"watchlist",value:g,inputProps:{checked:n===g,onChange:w=>{w.target&&w.target.closest("label")?.scrollIntoView({behavior:"smooth",inline:"center"})}},children:i`watchlist.${g}`},g))})]}),f("div",{style:{display:"flex",gap:"1rem"},children:[f(Ai,{name:"minor",id:"minor",checked:c.editMinor,children:i`Minor edit`}),f(Ai,{name:"reloadAfterSave",id:"reloadAfterSave",checked:c.reloadAfterSave,children:i`Reload after save`})]})]}),!1]});l.setContent(P);let b=!1;l.addButton({side:"left",className:"is-primary submit-btn",label:i`Submit`,keyPress:await this.ctx.preferences.get("quickEdit.keyshortcut.save")||void 0,method:async()=>{const g=new FormData(P);l.setLoadingState(!0);try{await this.handleSubmit({wikiPage:u,text:g.get("text"),summary:g.get("summary"),minor:g.get("minor")==="on",section:c.section,watchlist:n,createonly:u.pageid===0&&!b,recreate:u.pageid===0&&b}),l.setOptions({beforeClose:ma}),l.close(),this.ctx.modal.notify("success",{title:i`Submission Successful`,content:i`Your changes have been saved.`}),g.get("reloadAfterSave")&&(await Bv(500),location.reload())}catch(w){if(l.setLoadingState(!1),At.is(w)&&(w.code==="pagedeleted"||w.code==="editconflict"||w.code==="articleexists")){b=!0,this.ctx.modal.notify("warning",{title:i`Submission Error`,content:f("div",{children:[f("p",{children:f("strong",{children:w.message})}),f("p",{children:i`You can try to submit again to dismiss the warnings.`})]}),closeAfter:15*1e3});return}this.ctx.modal.notify("error",{title:i`Submission Error`,content:w instanceof Error?w.message:String(w)})}}},0),l.setOptions({beforeClose:()=>{const g=u.revisions[0]?.content||"";return(P.querySelector("textarea")?.value||"")===g?!0:(this.ctx.modal.confirm({className:"is-primary",title:i`Unsaved Changes`,content:i`All edit contents will be lost after closing the modal. Are you sure you want to close?`,center:!0,okBtn:{label:i`Give Up`,className:"is-danger is-ghost"},cancelBtn:{label:i`Continue Editing`,className:"is-primary is-ghost"}},S=>(S&&(l.setOptions({beforeClose:ma}),l.close()),!0)),!1)}}),this.ctx.emit("quick-edit/wiki-page",{ctx:this.ctx,options:c,modal:l,wikiPage:u});const m=g=>P.querySelector("textarea")?.value===d?!0:(g.preventDefault(),i`You have unsaved changes. Are you sure you want to leave?`);window.addEventListener("beforeunload",m),l.on(l.Event.Close,()=>{window.removeEventListener("beforeunload",m)})}async handleSubmit(e){const{wikiPage:i,...r}=e;return this.ctx.emit("quick-edit/submit",{ctx:this.ctx,wikiPage:i,...r}),i.edit({...r})}async getEditFontOptions(){const e=await this.ctx.preferences.get("quickEdit.editFont");return Oi.BUILT_IN_FONT_OPTIONS.includes(e)?{className:`mw-editfont-${e==="preferences"?this.ctx.wiki.userOptions?.editfont||"monospace":e}`,fontFamily:""}:{className:"mw-editfont-custom",fontFamily:e}}async getWikiPageFromPayload(e){if(e.revision)return this.ctx.wikiPage.newFromRevision(e.revision,e.section);if(e.pageId)return this.ctx.wikiPage.newFromPageId(e.pageId,e.section);if(e.title)return this.ctx.wikiPage.newFromTitle(e.title,!1,e.section);throw new Error("Invalid payload")}async injectToolbox(e){const{$:i}=this.ctx,r=this.ctx.currentPage.wikiTitle,n=r&&r.getNamespaceId()>=0;e.toolbox.addButton({id:"quick-edit",group:"group1",index:0,icon:f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-edit",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1"}),f("path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z"}),f("path",{d:"M16 5l3 3"})]}),buttonProps:{disabled:!n},tooltip:()=>n?i`Quick Edit`:i`Not editable`,onClick:()=>{const s=new URLSearchParams(window.location.search).get("oldid");this.showModal({title:r?.getPrefixedText(),revision:s?Number(s):void 0})}})}removeToolbox(e){e.toolbox.removeButton("quick-edit")}createQuickEditButton(e,i){const{$:r}=this.ctx,n=i?.icon??f(Fd,{className:"ipe-icon"}),s=i?.label??r`Quick Edit`;return f("a",{href:"#ipe://quick-edit/",dataset:e,className:`ipe-quick-edit ${e.createOnly?"ipe-quick-edit--create-only":""}`,style:{userSelect:"none",marginLeft:"0.2em"},onClick:o=>{o.preventDefault(),this.showModal(e)},children:[n,s]})}},Oi.BUILT_IN_FONT_OPTIONS=["preferences","monospace","sans-serif","serif"],Oi);_a=Vv(Wd),ss=Jv(_a,0,"PluginQuickEdit",zd,ss),Xv(_a,1,ss);const Zv=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickEdit:ss},Symbol.toStringTag,{value:"Module"})),zr={twinSwapInput:"_twinSwapInput_1gdgl_9",inputWrapper:"_inputWrapper_1gdgl_23",inputLeft:"_inputLeft_1gdgl_27",inputRight:"_inputRight_1gdgl_30",swapButton:"_swapButton_1gdgl_46"},Kd=t=>{const{inputs:e,enableSwap:i=!0,...r}=t,n=e?.length===2?e:[e?.[0]??{},e?.[1]??{}],s=[null,null];let o=0,a=null,c=null;const l=()=>s.some(h=>h&&h.disabled),u=()=>{if(!s[0]||!s[1]||l())return;const h=s[0],_=s[1],k=h.value,P=_.value;h.value=P,_.value=k,h.dispatchEvent(new Event("change")),_.dispatchEvent(new Event("change")),o++,c&&(c.style.transform=`rotateY(${o*-180}deg)`,c.style.transition="transform 200ms ease")},d=h=>{if(!a)return;const _=h??!a.disabled;a.disabled=!_,_&&s.forEach(k=>{k&&(k.disabled=!1)})},y=f("button",{type:"button","aria-label":"Swap values",onClick:u,disabled:l()||!i,ref:h=>a=h,children:f("svg",{ref:h=>c=h,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon-tabler icons-tabler-outline icon-tabler-transfer",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M20 10h-16l5.5 -6"}),f("path",{d:"M4 14h16l-5.5 6"})]})}),p=f("div",{className:`twin-swap-input ${zr.twinSwapInput}`,...r,children:[n.map((h,_)=>{const{label:k,id:P,name:b,value:m,disabled:g,required:w,inputProps:S}=h,I=_===0,F=P||b;return f("div",{className:`${zr.inputWrapper} ${I?zr.inputLeft:zr.inputRight}`,children:[k&&f("label",{htmlFor:F,children:k}),f("input",{ref:N=>s[_]=N,type:"text",id:F,name:b,value:m,disabled:g,required:w,...S})]})}),f("div",{className:zr.swapButton,children:y})]});return p.swap=u,p.toggleEnableSwap=d,p};var ew=Object.create,xa=Object.defineProperty,tw=Object.getOwnPropertyDescriptor,Vd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Gd=t=>{throw TypeError(t)},iw=(t,e,i)=>e in t?xa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,rw=(t,e)=>xa(t,"name",{value:e,configurable:!0}),nw=t=>[,,,ew(t?.[Vd("metadata")]??null)],sw=["class","method","getter","setter","accessor","field","value","get","set"],Qd=t=>t!==void 0&&typeof t!="function"?Gd("Function expected"):t,ow=(t,e,i,r,n)=>({kind:sw[t],name:e,metadata:r,addInitializer:s=>i._?Gd("Already initialized"):n.push(Qd(s||null))}),aw=(t,e)=>iw(e,Vd("metadata"),t[3]),lw=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},cw=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&tw(n,i));rw(n,i);for(var h=r.length-1;h>=0;h--)c=ow(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,Qd(o)&&(n=o);return aw(t,n),p&&xa(n,i,p),u?l^4?s:p:n},Yd,ka,Xd;Yd=[Tt(R.object({"quickMove.reason":R.string().default("[IPE-NEXT] Quick move")}).description("Quick move options").extra("category","editor")),xe(["modal","wiki","$"])];class os extends(Xd=Ue){constructor(e){super(e,{},"quick-move"),this.ctx=e,e.set("quickMove",this)}start(){this.ctx.inject(["toolbox"],e=>{this.injectToolbox(e)})}injectToolbox(e){const i=e.$,r=window.mw?.config.get("wgPageName")||"",n=window.mw?.config.get("wgIsProbablyEditable");e.toolbox.addButton({id:"quick-move",icon:f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-forms",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3"}),f("path",{d:"M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3"}),f("path",{d:"M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7"}),f("path",{d:"M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1"}),f("path",{d:"M17 12h.01"}),f("path",{d:"M13 12h.01"})]}),tooltip:()=>i`Quick Move`,group:"group1",index:1,onClick:()=>{this.showModal(n?{lockFromField:!0,from:r}:{})}})}async showModal(e){const{$:i}=this.ctx,r=await this.ctx.preferences.get("quickMove.reason"),n=this.ctx.modal.createObject({title:i`Quick Move`,content:f(_i,{}),className:"quick-move compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let s=null;return n.setContent(f("form",{ref:o=>s=o,style:{display:"flex",flexDirection:"column",gap:"1rem"},onSubmit:o=>{if(o.preventDefault(),s?.checkValidity(),!s?.reportValidity())return;const a=new FormData(s),c={from:a.get("from")?.toString().trim(),to:a.get("to")?.toString().trim(),reason:a.get("reason")||"",movetalk:a.get("movetalk")==="on",movesubpages:a.get("movesubpages")==="on",noredirect:a.get("noredirect")==="on"};if(!c.from||!c.to){this.ctx.modal.notify("error",{title:i`Failed to move`,content:"From and to are required."});return}this.ctx.emit("quick-move/submit",{ctx:this.ctx,modal:n,payload:c}),n.setLoadingState(!0),this.movePage(c).then(()=>{location.reload()}).catch(l=>{n.setLoadingState(!1),this.ctx.modal.notify("error",{title:i`Failed to move`,content:l instanceof Error?l.message:String(l)})})},children:[f(Kd,{inputs:[{label:i`Move from`,name:"from",value:e?.from,required:!0},{label:i`Move to`,name:"to",value:e?.to,required:!0}]}),f("div",{children:f(Ai,{name:"movetalk",id:"movetalk",checked:e?.movetalk,children:i`Move talk page`})}),f("div",{children:f(Ai,{name:"movesubpages",id:"movesubpages",checked:e?.movesubpages,children:i`Move subpages (up to 100)`})}),this.ctx.wiki.hasRight("suppressredirect")&&f("div",{children:f(Ai,{name:"noredirect",id:"noredirect",checked:e?.noredirect,children:i`Move without leaving a redirect`})}),f(ns,{label:i`Reason`,id:"reason",name:"reason",value:e?.reason??r??""})]})),n.setButtons([{label:i`Move`,className:"is-primary is-ghost",method:()=>{s?.dispatchEvent(new Event("submit"))}}]),n.show()}async movePage(e){const{from:i,to:r,reason:n="",...s}=e;if(!i||!r)throw new Error("From and to titles are required.");if(i===r)throw new Error("From and to titles cannot be the same.");return(await this.ctx.wikiPage.newFromTitle(i)).moveTo(r,n,s)}}ka=nw(Xd),os=cw(ka,0,"PluginQuickMove",Yd,os),lw(ka,1,os);const uw=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickMove(){return os}},Symbol.toStringTag,{value:"Module"}));var dw=Object.create,Sa=Object.defineProperty,fw=Object.getOwnPropertyDescriptor,Jd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Zd=t=>{throw TypeError(t)},hw=(t,e,i)=>e in t?Sa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,pw=(t,e)=>Sa(t,"name",{value:e,configurable:!0}),gw=t=>[,,,dw(t?.[Jd("metadata")]??null)],yw=["class","method","getter","setter","accessor","field","value","get","set"],ef=t=>t!==void 0&&typeof t!="function"?Zd("Function expected"):t,bw=(t,e,i,r,n)=>({kind:yw[t],name:e,metadata:r,addInitializer:s=>i._?Zd("Already initialized"):n.push(ef(s||null))}),vw=(t,e)=>hw(e,Jd("metadata"),t[3]),ww=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},_w=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&fw(n,i));pw(n,i);for(var h=r.length-1;h>=0;h--)c=bw(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,ef(o)&&(n=o);return vw(t,n),p&&Sa(n,i,p),u?l^4?s:p:n},tf,Ea,rf;tf=[xe(["api","wikiPage","modal","preferences","$"]),Tt(R.object({"quickPreview.keyshortcut":R.string().default("ctrl-i").description("Key shortcut to open quick preview in quick edit modal")}).extra("category","editor").description("Quick preview options"))];class as extends(rf=Ue){constructor(e){super(e,{},"quickPreview"),this.ctx=e,this._contentTypeCache=new Map,this._objectUrls=new WeakMap,this.ctx.set("quickPreview",Ud(this,"previewWikitext"))}start(){this.ctx.on("quick-edit/wiki-page",this.injectQuickEdit.bind(this))}stop(){}previewWikitext(e,i,r,n,s){const{$:o}=this.ctx;return r||(r=this.ctx.wikiPage.newBlankPage({title:"API"})),(!n||n.isDestroyed)&&(n=this.ctx.modal.createObject({className:"in-page-edit ipe-quickPreview",sizeClass:"large",center:!1,...s}).init()),n.show(),n.setTitle(o`Preview - Loading...`),n.setContent(f(_i,{})),n.bringToFront(),this.ctx.emit("quick-preview/show-modal",{ctx:this.ctx,text:e,modal:n,wikiPage:r}),r.preview(e,i).then(a=>{const{data:{parse:c}}=a;n.setTitle(o(c.title)`Preview - {{ $1 }}`);let l=null;n.setContent(f("section",{children:f("div",{ref:u=>l=u,className:"mw-parser-output",innerHTML:c.text})})),window.mw?.hook&&typeof jQuery=="function"&&window.mw.hook("wikipage.content").fire(jQuery(l)),this.ctx.emit("quick-preview/loaded",{ctx:this.ctx,modal:n,wikiPage:r,text:e,parseData:c})}).catch(a=>{n.setTitle(o`Preview - Failed`),n.setContent(f(bi,{children:[f("p",{children:o`Failed to preview`}),f("p",{children:a instanceof Error?a.message:String(a)})]}))}),n}async injectQuickEdit({options:e,modal:i,wikiPage:r}){const{$:n}=this.ctx;let s;i.addButton({label:n`Preview`,side:"left",className:"btn btn-secondary",keyPress:await this.ctx.preferences.get("quickPreview.keyshortcut.quickEdit")||void 0,method:()=>{let o=i.get$content().querySelector('textarea[name="text"]')?.value||"";if(e.section==="new"){const a=i.get$content().querySelector('input[name="summary"]')?.value;a&&(o=`==${a}==
25
- ${o}`)}s=this.previewWikitext(o,void 0,r,s,{backdrop:!1,draggable:!0})}},1),i.on(i.Event.Close,()=>{s?.destroy(),s=void 0})}fetchContentType(e){const i=this._contentTypeCache.get(e);if(i)return i;const r=fetch(e,{method:"HEAD"}).then(n=>n.headers.get("content-type")||"").catch(()=>(this._contentTypeCache.delete(e),""));return this._contentTypeCache.set(e,r),r}async getPreviewType(e){if(!e)return"unknown";let i,r;if(e instanceof File)i=e.type,r=e.name.split(".").pop()?.toLowerCase()||"";else{const n=new URL(e,location.origin);n.protocol==="data:"||n.protocol==="blob:"||n.protocol.startsWith("http")?i=await this.fetchContentType(n.href):i="",r=n.pathname.split(".").pop()?.toLowerCase()||""}return i.startsWith("image/")&&!i.includes("pdf")?"image":i.startsWith("video/")?"video":i.startsWith("audio/")?"audio":i.startsWith("text/html")?"html":r==="md"?"markdown":i.startsWith("text/")?"text":["jpg","jpeg","png","gif","bmp","tiff","ico","webp"].includes(r)?"image":["mp4","webm","ogg","flv","avi","mov","wmv","mkv"].includes(r)?"video":["mp3","wav","ogg","flac","aac","m4a","wma"].includes(r)?"audio":["html","htm"].includes(r)?"html":["json","yml","yaml","toml","py"].includes(r)?"text":["pdf"].includes(r)?"pdf":"unknown"}async previewFile(e,i){const r=await this.getPreviewElement(e,i);return r?this.ctx.modal.dialog({className:"in-page-edit ipe-quickPreview",sizeClass:"mediumToLarge",center:!0,title:i??(e instanceof File?e.name:e),content:f("section",{className:"ipe-quickPreview__content",children:r})}):void 0}getObjectUrl(e){if(!this._objectUrls.has(e)){const i=URL.createObjectURL(e);this._objectUrls.set(e,i)}return this._objectUrls.get(e)}async getPreviewElement(e,i){const r=await this.getPreviewType(e),n=e instanceof File?this.getObjectUrl(e):e;switch(r){case"image":return f("img",{src:n,alt:i??(e instanceof File?e.name:e)});case"video":return f("video",{src:n,controls:!0,"aria-label":i});case"audio":return f("audio",{src:n,controls:!0,"aria-label":i});case"pdf":return f("embed",{type:"application/pdf",src:n,"aria-label":i})}return null}previewWikiPage(e){throw new Error("Not implemented")}}Ea=gw(rf),as=_w(Ea,0,"PluginQuickPreview",tf,as),ww(Ea,1,as);const xw=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickPreview(){return as}},Symbol.toStringTag,{value:"Module"})),kw=t=>{let{user:e,target:i,ctx:r}=t;const n=r.getUrl.bind(r);return f("span",{className:"mw-userlinks",children:[f("a",{href:n(`User:${e}`),className:"mw-userlink",target:i,children:e})," ",f("span",{className:"mw-usertoollinks",children:["(",f("a",{href:n(`User_talk:${e}`),className:"mw-usertoollinks-talk",target:i,children:"talk"})," | ",f("a",{href:n(`Special:Contributions/${e}`),className:"mw-usertoollinks-contribs",target:i,children:"contribs"})," | ",f("a",{href:n(`Special:Block/${e}`),className:"mw-usertoollinks-block",target:i,children:"block"}),")"]})]})};var ls=(t=>(t.update="ipe:diff-table/update",t.edit="ipe:diff-table/edit",t))(ls||{});const Sw=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"medium"}).format,nf=t=>{let e=["diff-title"];if(t.type==="from"?e.push("diff-otitle"):t.type==="to"&&e.push("diff-ntitle"),!t.pageid||!t.userid)return f("td",{colSpan:2,className:e,children:f("div",{className:"mw-diff-title--title",children:t.type==="from"?"Original content":t.type==="to"?"Your content":""})});const i=r=>{r.preventDefault(),r.target.dispatchEvent(new CustomEvent("ipe:diff-table/edit",{detail:{revid:t.revid},bubbles:!0}))};return f("td",{colSpan:2,className:e,children:[f("div",{className:"mw-diff-title--title",children:[t.pagetitle||t.timestamp,t.revid?` (rev#${t.revid})`:""]}),f("div",{className:"mw-diff-title--actions",children:f("a",{href:t.ctx.getUrl("",{action:"edit",oldid:t.revid}),onClick:i,children:[f(Fd,{style:"width: 1em; height: 1em"}),"Quick edit"]})}),f("div",{className:"mw-diff-title--user",children:t.username&&f(kw,{ctx:t.ctx,user:t.username,target:"_blank"})}),f("div",{className:"mw-diff-title--timestamp",children:t.timestamp&&Sw(new Date(t.timestamp))}),f("div",{className:"mw-diff-title--comment",children:t.parsedcomment&&f(bi,{children:["(",f("i",{innerHTML:t.parsedcomment}),")"]})})]})},Ew=t=>{const e=t.data;if(!e.prev&&!e.next)return null;const i=(r,n,s)=>{r.preventDefault(),r.target.dispatchEvent(new CustomEvent("ipe:diff-table/update",{detail:{fromrev:n,torev:s},bubbles:!0}))};return f("tr",{className:"mw-diff-title--navigation",children:[f("td",{colSpan:2,children:e.prev?f("a",{href:t.ctx.getUrl("",{diff:e.prev,oldid:e.fromrevid}),onClick:r=>i(r,e.prev,e.fromrevid),children:"← Previous"}):f("i",{children:"Oldest version"})}),f("td",{colSpan:2,children:e.next?f("a",{href:t.ctx.getUrl("",{diff:e.next,oldid:e.torevid}),onClick:r=>i(r,e.torevid,e.next),children:"Next →"}):f("i",{children:"Newest version"})})]})},$w=t=>{const{data:e,...i}=t,r=f("table",{className:"theme-ipe diff diff-type-table","data-mw":"interface",...i,children:[f("colgroup",{children:[f("col",{className:"diff-marker"}),f("col",{className:"diff-content"}),f("col",{className:"diff-marker"}),f("col",{className:"diff-content"})]}),f("tbody",{children:[f("tr",{children:[f(nf,{ctx:t.ctx,type:"from",pageid:e.fromid,pagetitle:e.fromtitle,revid:e.fromrevid,size:e.fromsize,timestamp:e.fromtimestamp,username:e.fromuser,userid:e.fromuserid,comment:e.fromcomment,parsedcomment:e.fromparsedcomment}),f(nf,{ctx:t.ctx,type:"to",pageid:e.toid,pagetitle:e.totitle,revid:e.torevid,size:e.tosize,timestamp:e.totimestamp,username:e.touser,userid:e.touserid,comment:e.tocomment,parsedcomment:e.toparsedcomment})]}),f(Ew,{data:e,ctx:t.ctx}),f("div",{id:"diffbody"}),f("tr",{className:"diff-size",style:{textAlign:"center"},children:[f("td",{colSpan:2,className:"diff-size-old",children:e.fromsize!==void 0&&`${e.fromsize} bytes`}),f("td",{colSpan:2,className:"diff-size-new",children:e.tosize!==void 0&&`${e.tosize} bytes`})]})]})]});return r.querySelector("#diffbody").outerHTML=e.body||f("tr",{children:f("td",{colSpan:4,children:f("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"5rem"},children:f("i",{children:"No changes"})})})}).outerHTML,r},Pw=t=>f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...t,class:`icon icon-tabler icons-tabler-outline icon-tabler-file-diff ${t.className||""}`,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),f("path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z"}),f("path",{d:"M12 10l0 4"}),f("path",{d:"M10 12l4 0"}),f("path",{d:"M10 17l4 0"})]});var Cw=Object.create,$a=Object.defineProperty,Iw=Object.getOwnPropertyDescriptor,sf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),of=t=>{throw TypeError(t)},Rw=(t,e,i)=>e in t?$a(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Aw=(t,e)=>$a(t,"name",{value:e,configurable:!0}),Tw=t=>[,,,Cw(t?.[sf("metadata")]??null)],Ow=["class","method","getter","setter","accessor","field","value","get","set"],af=t=>t!==void 0&&typeof t!="function"?of("Function expected"):t,Lw=(t,e,i,r,n)=>({kind:Ow[t],name:e,metadata:r,addInitializer:s=>i._?of("Already initialized"):n.push(af(s||null))}),Nw=(t,e)=>Rw(e,sf("metadata"),t[3]),Mw=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Dw=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&Iw(n,i));Aw(n,i);for(var h=r.length-1;h>=0;h--)c=Lw(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,af(o)&&(n=o);return Nw(t,n),p&&$a(n,i,p),u?l^4?s:p:n},lf,Pa,cf;lf=[xe(["wiki","getUrl","preferences","$"]),Tt(R.object({"quickDiff.keyshortcut":R.string().default("ctrl-d").description("Key shortcut to open quick diff in quick edit modal")}).description("Quick diff options").extra("category","editor"))];class cs extends(cf=Ue){constructor(e){super(e,{},"quick-diff"),this.ctx=e,this.COMPARE_API_DEFAULT_OPTIONS={prop:["comment","diff","diffsize","ids","parsedcomment","size","timestamp","title","user","rel"].join("|"),difftype:"table"}}start(){this.ctx.set("quickDiff",this),this.ctx.on("quick-edit/wiki-page",this.injectQuickEdit.bind(this)),window.RLQ.push(this.injectHistoryPage.bind(this))}stop(){}injectHistoryPage(){const{$:e}=this.ctx,i=Ds("#mw-history-compare");if(!i)return;Oh(".mw-history-compareselectedversions-button",i).forEach(n=>{n.after(f("button",{className:"cdx-button",onClick:s=>{s.preventDefault();const o=new FormData(i),a=Number(o.get("oldid"))||0,c=Number(o.get("diff"))||0;if(!o.get("title")||!a||!c)return this.logger.warn("Missing title or revision IDs");this.comparePages({fromrev:a,torev:c})},children:e`Quick Diff`}))})}async injectQuickEdit({modal:e,wikiPage:i,options:r}){if(i.pageid===0||r.section==="new")return;const{$:n}=this.ctx;let s;e.addButton({label:n`Diff`,side:"left",keyPress:await this.ctx.preferences.get("quickDiff.keyshortcut")||void 0,className:"btn btn-secondary",method:()=>{const o=i.title,a=i.revisions?.[0]?.content||"",c=e.get$content().querySelector('textarea[name="text"]')?.value||"";return a===c?this.ctx.modal.notify("info",{title:n`Quick Diff`,content:n`No changes`}):(this.ctx.emit("quick-diff/quick-edit-modal",{ctx:this.ctx,modal:e,wikiPage:i}),s=this.comparePages({fromtitle:o,fromtext:a,totitle:o,totext:c,topst:!0},s,{backdrop:!1,draggable:!0}),s)}},2),e.on(e.Event.Close,()=>{s?.destroy(),s=void 0})}comparePages(e,i,r){const{$:n}=this.ctx;return!i||i.isDestroyed?i=this.ctx.modal.createObject({title:n`Loading diff...`,content:"",className:"quick-diff",center:!1,...r}).init():i.removeButton("*"),this.ctx.emit("quick-diff/init-options",{ctx:this.ctx,options:e}),i.setContent(f("section",{style:{height:"70vh",display:"flex",justifyContent:"center",alignItems:"center"},children:f(_i,{})})),i.bringToFront(),window.mw&&mw.loader.getState("mediawiki.diff.styles")!=="ready"&&mw.loader.load(["mediawiki.diff.styles"]),this.ctx.api.post({...this.COMPARE_API_DEFAULT_OPTIONS,...e,action:"compare",format:"json",formatversion:2}).then(s=>{if(!s.data.compare)throw new Error("No compare data received",{cause:s});const{data:{compare:o}}=s;i.setTitle(o.fromtitle&&o.totitle?`${o.fromtitle}${o.fromrevid?` (${o.fromrevid})`:""} ⇔ ${o.totitle}${o.torevid?` (${o.torevid})`:""}`:n`Differences`);let a;i.setContent(f("section",{style:{minHeight:"70vh"},children:f($w,{ref:c=>a=c,data:o,ctx:this.ctx})})),a.addEventListener(ls.update,c=>{c.stopPropagation(),this.comparePages({fromrev:c.detail.fromrev,torev:c.detail.torev},i,r)},{once:!0}),this.ctx.inject(["quickEdit"],c=>{const l=u=>{u.stopPropagation(),c.quickEdit({revision:u.detail.revid})};a.addEventListener(ls.edit,l),i.on(i.Event.Close,()=>{a.removeEventListener(ls.edit,l)})}),o.fromrevid&&o.torevid&&i.addButton({label:n`Original Compare Page`,side:"right",className:"btn btn-secondary",method:()=>{window.location.href=this.ctx.getUrl("",{oldid:o.fromrevid,diff:o.torevid})}}),this.ctx.emit("quick-diff/loaded",{ctx:this.ctx,modal:i,compare:o})}).catch(s=>{i.setContent(f(va,{title:n`Failed to load diff`,type:"error",children:f("pre",{children:s instanceof Error?s.message:String(s)})}))}),i.show()}createQuickDiffButton(e,i){const{$:r}=this.ctx,n=i?.icon??f(Pw,{className:"ipe-icon"}),s=i?.label??r`Quick Diff`;return f("a",{href:"#ipe://quick-diff/",dataset:e,className:"ipe-quick-diff",style:{userSelect:"none",marginLeft:"0.2em"},onClick:o=>{o.preventDefault(),this.comparePages(e)},children:[n,s]})}}Pa=Tw(cf),cs=Dw(Pa,0,"PluginQuickDiff",lf,cs),Mw(Pa,1,cs);const jw=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickDiff(){return cs}},Symbol.toStringTag,{value:"Module"})),bs=class bs extends Ue{constructor(e){super(e,{},"quick-redirect"),this.ctx=e}start(){this.ctx.set("quickRedirect",this);const{$:e}=this.ctx,i=window.mw?.config.get("wgPageName")||"",r=window.mw?.config.get("wgIsProbablyEditable");this.ctx.inject(["toolbox"],n=>{this.ctx=n,n.toolbox.addButton({id:"quick-redirect",icon:f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-file-symlink",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 21v-4a3 3 0 0 1 3 -3h5"}),f("path",{d:"M9 17l3 -3l-3 -3"}),f("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),f("path",{d:"M5 11v-6a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-9.5"})]}),tooltip:()=>e`Quick Redirect`,group:"group1",index:2,onClick:()=>{this.showModal(r?{to:i}:{})}}),this.addDisposeHandler(s=>{s.toolbox.removeButton("quick-redirect")})})}stop(){}async showModal(e){const{$:i}=this.ctx,r=await this.ctx.preferences.get("quickRedirect.reason");e||(e={}),this.ctx.emit("quick-redirect/init-options",{ctx:this.ctx,options:e});const n=this.ctx.modal.createObject({title:i`Quick Redirect`,content:f(_i,{}),className:"quick-redirect compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let s=null;return n.setContent(f("form",{ref:o=>s=o,style:{display:"flex",flexDirection:"column",gap:"1rem"},onSubmit:o=>{if(o.preventDefault(),s?.checkValidity(),!s?.reportValidity())return;const a=new FormData(s),c={from:a.get("from")?.toString().trim(),to:a.get("to")?.toString().trim(),reason:a.get("reason")||"",overwrite:a.get("overwrite")==="on"};if(!c.from||!c.to){this.ctx.modal.notify("error",{title:i`Failed to redirect`,content:i`From and to are required.`});return}this.ctx.emit("quick-redirect/submit",{ctx:this.ctx,payload:c}),n.setLoadingState(!0),this.redirectPage(c).then(l=>{n.close(),this.ctx.modal.notify("success",{title:i`Redirect successful`,content:i`The redirect has been created.`})}).catch(l=>{n.setLoadingState(!1),this.ctx.modal.notify("error",{title:i`Failed to redirect`,content:l instanceof Error?l.message:String(l)})})},children:[f(Kd,{inputs:[{label:i`Redirect from`,name:"from",value:e?.from,required:!0},{label:i`Redirect to`,name:"to",value:e?.to,required:!0}]}),f(ns,{label:i`Reason`,id:"reason",name:"reason",value:e?.reason??r??""}),f("div",{children:f(Ai,{name:"overwrite",id:"overwrite",checked:e?.overwrite,children:i`Force create redirect even if the from page already exists`})})]})),n.setButtons([{label:i`Create Redirect`,className:"is-primary is-ghost",method:()=>{s?.dispatchEvent(new Event("submit"))}}]),this.ctx.emit("quick-redirect/show-modal",{ctx:this.ctx,modal:n}),n.show()}async redirectPage(e){const{from:i,to:r,reason:n="",overwrite:s=!1}=e,o=await this.ctx.wikiPage.newBlankPage({title:i}),a=`#REDIRECT [[:${r}]]`;return o.edit({text:a,summary:n},{createonly:!s})}};bs.inject=["api","wikiPage","modal","$"],bs.PreferencesSchema=R.object({"quickRedirect.reason":R.string().default("[IPE-NEXT] Quick redirect")}).description("Quick redirect options").extra("category","editor");let Ca=bs;const Uw=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickRedirect:Ca},Symbol.toStringTag,{value:"Module"})),uf=t=>f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...t,class:`icon icon-tabler icons-tabler-outline icon-tabler-upload ${t.className||""}`,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),f("path",{d:"M7 9l5 -5l5 5"}),f("path",{d:"M12 4l0 12"})]}),Fw=window?.location?.origin,Wr=({type:t,tag:e,href:i,target:r,children:n,...s})=>(e=e||(i?"a":"button"),typeof r>"u"&&i&&i.startsWith("http")&&!i.startsWith(Fw)&&(r="_blank"),gr(e,{className:`theme-ipe ipe-action-button ipe-modal-btn is-${t||"default"}`,href:e==="a"?i:void 0,target:e==="a"?r:void 0,"data-href":e!=="a"?i:void 0,...s},n));var qw=Object.create,Ia=Object.defineProperty,Bw=Object.getOwnPropertyDescriptor,df=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ff=t=>{throw TypeError(t)},Hw=(t,e,i)=>e in t?Ia(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,zw=(t,e)=>Ia(t,"name",{value:e,configurable:!0}),Ww=t=>[,,,qw(t?.[df("metadata")]??null)],Kw=["class","method","getter","setter","accessor","field","value","get","set"],hf=t=>t!==void 0&&typeof t!="function"?ff("Function expected"):t,Vw=(t,e,i,r,n)=>({kind:Kw[t],name:e,metadata:r,addInitializer:s=>i._?ff("Already initialized"):n.push(hf(s||null))}),Gw=(t,e)=>Hw(e,df("metadata"),t[3]),Qw=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Yw=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&Bw(n,i));zw(n,i);for(var h=r.length-1;h>=0;h--)c=Vw(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,hf(o)&&(n=o);return Gw(t,n),p&&Ia(n,i,p),u?l^4?s:p:n},pf,Ra,gf;const Xw=({$:t})=>f("div",{className:"ipe-quickUpload__preview-placeholder is-na",children:f("span",{children:[f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-file-unknown",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 2l.117 .007a1 1 0 0 1 .876 .876l.007 .117v4l.005 .15a2 2 0 0 0 1.838 1.844l.157 .006h4l.117 .007a1 1 0 0 1 .876 .876l.007 .117v9a3 3 0 0 1 -2.824 2.995l-.176 .005h-10a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-14a3 3 0 0 1 2.824 -2.995l.176 -.005zm0 15a1 1 0 0 0 -.993 .883l-.007 .127a1 1 0 0 0 1.993 .117l.007 -.127a1 1 0 0 0 -1 -1m1.136 -5.727a2.5 2.5 0 0 0 -3.037 .604a1 1 0 0 0 1.434 1.389l.088 -.09a.5 .5 0 1 1 .379 .824a1 1 0 0 0 -.002 2a2.5 2.5 0 0 0 1.137 -4.727"}),f("path",{d:"M19 7h-4l-.001 -4.001z"})]}),f("p",{children:t`No preview available`})]})});pf=[Tt(R.object({"quickUpload.summary":R.string().description("Default summary of the quick upload").default("[IPE-NEXT] Quick upload")})),xe(["modal","$","wikiTitle","wikiFile","quickPreview","preferences"])];class us extends(gf=Ue){constructor(e){super(e,{},"quick-upload"),this.ctx=e}async start(){this.injectToolbox(),this.ctx.set("quickUpload",this)}async stop(){}injectToolbox(){const{$:e}=this.ctx;this.ctx.inject(["toolbox"],i=>{i.toolbox.addButton({id:"quick-upload",group:"group2",index:2,icon:f(uf,{}),tooltip:()=>e`Quick Upload`,onClick:r=>{r.preventDefault(),this.showModal()}}),i.on("dispose",()=>{i.toolbox.removeButton("quick-upload")})})}formatFileSize(e=0){if(e=Number(e),!Number.isFinite(e)||e<0)return"0 B";const i=["B","KB","MB","GB","TB"];let r=0;for(;e>=1024&&r<i.length-1;)e/=1024,r++;return`${new Intl.NumberFormat(void 0,{maximumFractionDigits:2}).format(e)} ${i[r]}`}isFileAccepted(e,i){if(!i)return!0;const r=i.split(",").map(o=>o.trim()).filter(Boolean);if(!r.length)return!0;const n=e.type||"",s=e.name||"";return r.some(o=>{if(o.startsWith("."))return s.toLowerCase().endsWith(o.toLowerCase());if(o.endsWith("/*")){const a=o.slice(0,-1);return n.startsWith(a)}return n===o})}getDefaultPreviewPlaceholder(){const{$:e}=this.ctx;return f("div",{className:"ipe-quickUpload__preview-placeholder",children:f("span",{children:[f(uf,{}),f("p",{children:e`You can drag & drop files to this modal`})]})})}safeId(){return`mu_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`}async showModal(){const{$:e}=this.ctx;let i=!1,r=!1;const n=(C,M,H)=>{this.ctx.modal.notify(C,{title:M,content:H,closeAfter:C==="success"?3e3:8e3})},s=this.ctx.modal.show({className:"ipe-quickUpload compact-buttons",sizeClass:"mediumToLarge",center:!1,title:e`Quick Upload`,content:e`Quick Upload`,outSideClose:!1,beforeClose:()=>i?(n("warning",e`Upload in progress`,e`Please pause or wait for it to finish.`),!1):!0}),o=await this.ctx.preferences.get("quickUpload.summary")||"",a="image/*,video/*,audio/*,application/pdf",c=20;let l=[],u=null;const d={fileInput:null,listEl:null,previewWrapper:null,progressEl:null,progressTextEl:null,summaryInput:null,ignoreWarnings:null},y=(C,M)=>{l=l.map(H=>H.id===C?{...H,...M}:H)},p=C=>{l=l.filter(M=>M.id!==C),u===C&&(u=l[0]?.id??null)},h=(C,M)=>{l=l.map(H=>C.has(H.id)?M(H):H)},_=C=>{const M=[],H=te=>te==null?"":String(te);if(C instanceof Error){M.push(C.message);let te=C;for(;te?.cause&&(te=te.cause,te instanceof Error);)M.push(te.message)}else C?.data?.error?.info?M.push(H(C.data.error.info)):C?.error?.info?M.push(H(C.error.info)):C?.message&&M.push(H(C.message));return M.filter(Boolean)},k=C=>{let M=_(C);M.length===0&&(M=["Upload failed with unknown error."]);const H=M.join(`
23
+ `,...wy(n))}Dt(),jo=!1}function vy(){let t=Pr[Pr.length-1];if(!t)return[];const e=[];for(;t;){const i=e[0];i&&i.vnode===t?i.recurseCount++:e.push({vnode:t,recurseCount:0});const r=t.component&&t.component.parent;t=r&&r.vnode}return e}function wy(t){const e=[];return t.forEach((i,r)=>{e.push(...r===0?[]:[`
24
+ `],..._y(i))}),e}function _y({vnode:t,recurseCount:e}){const i=e>0?`... (${e} recursive calls)`:"",r=t.component?t.component.parent==null:!1,n=` at <${Xu(t.component,t.type,r)}`,s=">"+i;return t.props?[n,...xy(t.props),s]:[n+s]}function xy(t){const e=[],i=Object.keys(t);return i.slice(0,3).forEach(r=>{e.push(...tu(r,t[r]))}),i.length>3&&e.push(" ..."),e}function tu(t,e,i){return Ae(e)?(e=JSON.stringify(e),i?e:[`${t}=${e}`]):typeof e=="number"||typeof e=="boolean"||e==null?i?e:[`${t}=${e}`]:De(e)?(e=tu(t,oe(e.value),!0),i?e:[`${t}=Ref<`,e,">"]):Z(e)?[`${t}=fn${e.name?`<${e.name}>`:""}`]:(e=oe(e),i?e:[`${t}=`,e])}function Wi(t,e,i,r){try{return r?t(...r):t()}catch(n){Cr(n,e,i)}}function jt(t,e,i,r){if(Z(t)){const n=Wi(t,e,i,r);return n&&Ec(n)&&n.catch(s=>{Cr(s,e,i)}),n}if(J(t)){const n=[];for(let s=0;s<t.length;s++)n.push(jt(t[s],e,i,r));return n}}function Cr(t,e,i,r=!0){const n=e?e.vnode:null,{errorHandler:s,throwUnhandledErrorInProduction:o}=e&&e.appContext.config||le;if(e){let a=e.parent;const c=e.proxy,l=`https://vuejs.org/error-reference/#runtime-${i}`;for(;a;){const u=a.ec;if(u){for(let d=0;d<u.length;d++)if(u[d](t,c,l)===!1)return}a=a.parent}if(s){Mt(),Wi(s,null,10,[t,c,l]),Dt();return}}ky(t,i,n,r,o)}function ky(t,e,i,r=!0,n=!1){if(n)throw t}const Ye=[];let Ut=-1;const Ki=[];let di=null,Vi=0;const iu=Promise.resolve();let Mn=null;function Ir(t){const e=Mn||iu;return t?e.then(this?t.bind(this):t):e}function Sy(t){let e=Ut+1,i=Ye.length;for(;e<i;){const r=e+i>>>1,n=Ye[r],s=Ar(n);s<t||s===t&&n.flags&2?e=r+1:i=r}return e}function Uo(t){if(!(t.flags&1)){const e=Ar(t),i=Ye[Ye.length-1];!i||!(t.flags&2)&&e>=Ar(i)?Ye.push(t):Ye.splice(Sy(e),0,t),t.flags|=1,ru()}}function ru(){Mn||(Mn=iu.then(ou))}function Ey(t){J(t)?Ki.push(...t):di&&t.id===-1?di.splice(Vi+1,0,t):t.flags&1||(Ki.push(t),t.flags|=1),ru()}function nu(t,e,i=Ut+1){for(;i<Ye.length;i++){const r=Ye[i];if(r&&r.flags&2){if(t&&r.id!==t.uid)continue;Ye.splice(i,1),i--,r.flags&4&&(r.flags&=-2),r(),r.flags&4||(r.flags&=-2)}}}function su(t){if(Ki.length){const e=[...new Set(Ki)].sort((i,r)=>Ar(i)-Ar(r));if(Ki.length=0,di){di.push(...e);return}for(di=e,Vi=0;Vi<di.length;Vi++){const i=di[Vi];i.flags&4&&(i.flags&=-2),i.flags&8||i(),i.flags&=-2}di=null,Vi=0}}const Ar=t=>t.id==null?t.flags&2?-1:1/0:t.id;function ou(t){try{for(Ut=0;Ut<Ye.length;Ut++){const e=Ye[Ut];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),Wi(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;Ut<Ye.length;Ut++){const e=Ye[Ut];e&&(e.flags&=-2)}Ut=-1,Ye.length=0,su(),Mn=null,(Ye.length||Ki.length)&&ou()}}let ze=null,au=null;function Dn(t){const e=ze;return ze=t,au=t&&t.type.__scopeId||null,e}function Rr(t,e=ze,i){if(!e||t._n)return t;const r=(...n)=>{r._d&&Hu(-1);const s=Dn(e);let o;try{o=t(...n)}finally{Dn(s),r._d&&Hu(1)}return o};return r._n=!0,r._c=!0,r._d=!0,r}function lu(t,e){if(ze===null)return t;const i=Gn(ze),r=t.dirs||(t.dirs=[]);for(let n=0;n<e.length;n++){let[s,o,a,c=le]=e[n];s&&(Z(s)&&(s={mounted:s,updated:s}),s.deep&&ei(o),r.push({dir:s,instance:i,value:o,oldValue:void 0,arg:a,modifiers:c}))}return t}function Ei(t,e,i,r){const n=t.dirs,s=e&&e.dirs;for(let o=0;o<n.length;o++){const a=n[o];s&&(a.oldValue=s[o].value);let c=a.dir[r];c&&(Mt(),jt(c,i,8,[t.el,a,t,e]),Dt())}}function cu(t,e){if(Ke){let i=Ke.provides;const r=Ke.parent&&Ke.parent.provides;r===i&&(i=Ke.provides=Object.create(r)),i[t]=e}}function Tr(t,e,i=!1){const r=na();if(r||Yi){let n=Yi?Yi._context.provides:r?r.parent==null||r.ce?r.vnode.appContext&&r.vnode.appContext.provides:r.parent.provides:void 0;if(n&&t in n)return n[t];if(arguments.length>1)return i&&Z(e)?e.call(r&&r.proxy):e}}const $y=Symbol.for("v-scx"),Py=()=>Tr($y);function Cy(t,e){return Fo(t,null,{flush:"sync"})}function Gi(t,e,i){return Fo(t,e,i)}function Fo(t,e,i=le){const{immediate:r,deep:n,flush:s,once:o}=i,a=Fe({},i),c=e&&r||!e&&s!=="post";let l;if(Ji){if(s==="sync"){const p=Py();l=p.__watcherHandles||(p.__watcherHandles=[])}else if(!c){const p=()=>{};return p.stop=Nt,p.resume=Nt,p.pause=Nt,p}}const u=Ke;a.call=(p,h,_)=>jt(p,u,h,_);let d=!1;s==="post"?a.scheduler=p=>{at(p,u&&u.suspense)}:s!=="sync"&&(d=!0,a.scheduler=(p,h)=>{h?p():Uo(p)}),a.augmentJob=p=>{e&&(p.flags|=4),d&&(p.flags|=2,u&&(p.id=u.uid,p.i=u))};const y=by(t,e,a);return Ji&&(l?l.push(y):c&&y()),y}function Iy(t,e,i){const r=this.proxy,n=Ae(t)?t.includes(".")?uu(r,t):()=>r[t]:t.bind(r,r);let s;Z(e)?s=e:(s=e.handler,i=e);const o=qr(this),a=Fo(n,s.bind(r),i);return o(),a}function uu(t,e){const i=e.split(".");return()=>{let r=t;for(let n=0;n<i.length&&r;n++)r=r[i[n]];return r}}const Ay=Symbol("_vte"),Ry=t=>t.__isTeleport,Ty=Symbol("_leaveCb");function qo(t,e){t.shapeFlag&6&&t.component?(t.transition=e,qo(t.component.subTree,e)):t.shapeFlag&128?(t.ssContent.transition=e.clone(t.ssContent),t.ssFallback.transition=e.clone(t.ssFallback)):t.transition=e}function $i(t,e){return Z(t)?Fe({name:t.name},e,{setup:t}):t}function Bo(t){t.ids=[t.ids[0]+t.ids[2]+++"-",0,0]}function du(t){const e=na(),i=Jc(null);if(e){const n=e.refs===le?e.refs={}:e.refs;Object.defineProperty(n,t,{enumerable:!0,get:()=>i.value,set:s=>i.value=s})}return i}const jn=new WeakMap;function Or(t,e,i,r,n=!1){if(J(t)){t.forEach((h,_)=>Or(h,e&&(J(e)?e[_]:e),i,r,n));return}if(Qi(r)&&!n){r.shapeFlag&512&&r.type.__asyncResolved&&r.component.subTree.component&&Or(t,e,i,r.component.subTree);return}const s=r.shapeFlag&4?Gn(r.component):r.el,o=n?null:s,{i:a,r:c}=t,l=e&&e.r,u=a.refs===le?a.refs={}:a.refs,d=a.setupState,y=oe(d),p=d===le?kc:h=>ue(y,h);if(l!=null&&l!==c){if(fu(e),Ae(l))u[l]=null,p(l)&&(d[l]=null);else if(De(l)){l.value=null;const h=e;h.k&&(u[h.k]=null)}}if(Z(c))Wi(c,a,12,[o,u]);else{const h=Ae(c),_=De(c);if(h||_){const k=()=>{if(t.f){const P=h?p(c)?d[c]:u[c]:c.value;if(n)J(P)&&vo(P,s);else if(J(P))P.includes(s)||P.push(s);else if(h)u[c]=[s],p(c)&&(d[c]=u[c]);else{const b=[s];c.value=b,t.k&&(u[t.k]=b)}}else h?(u[c]=o,p(c)&&(d[c]=o)):_&&(c.value=o,t.k&&(u[t.k]=o))};if(o){const P=()=>{k(),jn.delete(t)};P.id=-1,jn.set(t,P),at(P,i)}else fu(t),k()}}}function fu(t){const e=jn.get(t);e&&(e.flags|=8,jn.delete(t))}const hu=t=>t.nodeType===8;Pn().requestIdleCallback,Pn().cancelIdleCallback;function Oy(t,e){if(hu(t)&&t.data==="["){let i=1,r=t.nextSibling;for(;r;){if(r.nodeType===1){if(e(r)===!1)break}else if(hu(r))if(r.data==="]"){if(--i===0)break}else r.data==="["&&i++;r=r.nextSibling}}else e(t)}const Qi=t=>!!t.type.__asyncLoader;function Ly(t){Z(t)&&(t={loader:t});const{loader:e,loadingComponent:i,errorComponent:r,delay:n=200,hydrate:s,timeout:o,suspensible:a=!0,onError:c}=t;let l=null,u,d=0;const y=()=>(d++,l=null,p()),p=()=>{let h;return l||(h=l=e().catch(_=>{if(_=_ instanceof Error?_:new Error(String(_)),c)return new Promise((k,P)=>{c(_,()=>k(y()),()=>P(_),d+1)});throw _}).then(_=>h!==l&&l?l:(_&&(_.__esModule||_[Symbol.toStringTag]==="Module")&&(_=_.default),u=_,_)))};return $i({name:"AsyncComponentWrapper",__asyncLoader:p,__asyncHydrate(h,_,k){let P=!1;(_.bu||(_.bu=[])).push(()=>P=!0);const b=()=>{P||k()},m=s?()=>{const g=s(b,w=>Oy(h,w));g&&(_.bum||(_.bum=[])).push(g)}:b;u?m():p().then(()=>!_.isUnmounted&&m())},get __asyncResolved(){return u},setup(){const h=Ke;if(Bo(h),u)return()=>Un(u,h);const _=m=>{l=null,Cr(m,h,13,!r)};if(a&&h.suspense||Ji)return p().then(m=>()=>Un(m,h)).catch(m=>(_(m),()=>r?Ne(r,{error:m}):null));const k=Qe(!1),P=Qe(),b=Qe(!!n);return n&&setTimeout(()=>{b.value=!1},n),o!=null&&setTimeout(()=>{if(!k.value&&!P.value){const m=new Error(`Async component timed out after ${o}ms.`);_(m),P.value=m}},o),p().then(()=>{k.value=!0,h.parent&&Ho(h.parent.vnode)&&h.parent.update()}).catch(m=>{_(m),P.value=m}),()=>{if(k.value&&u)return Un(u,h);if(P.value&&r)return Ne(r,{error:P.value});if(i&&!b.value)return Un(i,h)}}})}function Un(t,e){const{ref:i,props:r,children:n,ce:s}=e.vnode,o=Ne(t,r,n);return o.ref=i,o.ce=s,delete e.vnode.ce,o}const Ho=t=>t.type.__isKeepAlive;function Ny(t,e){pu(t,"a",e)}function My(t,e){pu(t,"da",e)}function pu(t,e,i=Ke){const r=t.__wdc||(t.__wdc=()=>{let n=i;for(;n;){if(n.isDeactivated)return;n=n.parent}return t()});if(Fn(e,r,i),i){let n=i.parent;for(;n&&n.parent;)Ho(n.parent.vnode)&&Dy(r,e,i,n),n=n.parent}}function Dy(t,e,i,r){const n=Fn(e,t,r,!0);Wo(()=>{vo(r[e],n)},i)}function Fn(t,e,i=Ke,r=!1){if(i){const n=i[t]||(i[t]=[]),s=e.__weh||(e.__weh=(...o)=>{Mt();const a=qr(i),c=jt(e,i,t,o);return a(),Dt(),c});return r?n.unshift(s):n.push(s),s}}const ti=t=>(e,i=Ke)=>{(!Ji||t==="sp")&&Fn(t,(...r)=>e(...r),i)},gu=ti("bm"),Lr=ti("m"),jy=ti("bu"),Uy=ti("u"),zo=ti("bum"),Wo=ti("um"),Fy=ti("sp"),qy=ti("rtg"),By=ti("rtc");function Hy(t,e=Ke){Fn("ec",t,e)}const zy=Symbol.for("v-ndc");function Ko(t,e,i,r){let n;const s=i,o=J(t);if(o||Ae(t)){const a=o&&ki(t);let c=!1,l=!1;a&&(c=!gt(t),l=Zt(t),t=In(t)),n=new Array(t.length);for(let u=0,d=t.length;u<d;u++)n[u]=e(c?l?zi(St(t[u])):St(t[u]):t[u],u,void 0,s)}else if(typeof t=="number"){n=new Array(t);for(let a=0;a<t;a++)n[a]=e(a+1,a,void 0,s)}else if(ke(t))if(t[Symbol.iterator])n=Array.from(t,(a,c)=>e(a,c,void 0,s));else{const a=Object.keys(t);n=new Array(a.length);for(let c=0,l=a.length;c<l;c++){const u=a[c];n[c]=e(t[u],u,c,s)}}else n=[];return n}function Wy(t,e,i={},r,n){if(ze.ce||ze.parent&&Qi(ze.parent)&&ze.parent.ce){const l=Object.keys(i).length>0;return de(),Wn(We,null,[Ne("slot",i,r)],l?-2:64)}let s=t[e];s&&s._c&&(s._d=!1),de();const o=s&&mu(s(i)),a=i.key||o&&o.key,c=Wn(We,{key:(a&&!Qt(a)?a:`_${e}`)+(!o&&r?"_fb":"")},o||[],o&&t._===1?64:-2);return c.scopeId&&(c.slotScopeIds=[c.scopeId+"-s"]),s&&s._c&&(s._d=!0),c}function mu(t){return t.some(e=>ia(e)?!(e.type===ii||e.type===We&&!mu(e.children)):!0)?t:null}const Vo=t=>t?Gu(t)?Gn(t):Vo(t.parent):null,Nr=Fe(Object.create(null),{$:t=>t,$el:t=>t.vnode.el,$data:t=>t.data,$props:t=>t.props,$attrs:t=>t.attrs,$slots:t=>t.slots,$refs:t=>t.refs,$parent:t=>Vo(t.parent),$root:t=>Vo(t.root),$host:t=>t.ce,$emit:t=>t.emit,$options:t=>wu(t),$forceUpdate:t=>t.f||(t.f=()=>{Uo(t.update)}),$nextTick:t=>t.n||(t.n=Ir.bind(t.proxy)),$watch:t=>Iy.bind(t)}),Go=(t,e)=>t!==le&&!t.__isScriptSetup&&ue(t,e),Ky={get({_:t},e){if(e==="__v_skip")return!0;const{ctx:i,setupState:r,data:n,props:s,accessCache:o,type:a,appContext:c}=t;if(e[0]!=="$"){const y=o[e];if(y!==void 0)switch(y){case 1:return r[e];case 2:return n[e];case 4:return i[e];case 3:return s[e]}else{if(Go(r,e))return o[e]=1,r[e];if(n!==le&&ue(n,e))return o[e]=2,n[e];if(ue(s,e))return o[e]=3,s[e];if(i!==le&&ue(i,e))return o[e]=4,i[e];Qo&&(o[e]=0)}}const l=Nr[e];let u,d;if(l)return e==="$attrs"&&He(t.attrs,"get",""),l(t);if((u=a.__cssModules)&&(u=u[e]))return u;if(i!==le&&ue(i,e))return o[e]=4,i[e];if(d=c.config.globalProperties,ue(d,e))return d[e]},set({_:t},e,i){const{data:r,setupState:n,ctx:s}=t;return Go(n,e)?(n[e]=i,!0):r!==le&&ue(r,e)?(r[e]=i,!0):ue(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(s[e]=i,!0)},has({_:{data:t,setupState:e,accessCache:i,ctx:r,appContext:n,props:s,type:o}},a){let c;return!!(i[a]||t!==le&&a[0]!=="$"&&ue(t,a)||Go(e,a)||ue(s,a)||ue(r,a)||ue(Nr,a)||ue(n.config.globalProperties,a)||(c=o.__cssModules)&&c[a])},defineProperty(t,e,i){return i.get!=null?t._.accessCache[e]=0:ue(i,"value")&&this.set(t,e,i.value,null),Reflect.defineProperty(t,e,i)}};function qn(t){return J(t)?t.reduce((e,i)=>(e[i]=null,e),{}):t}function yu(t,e){return!t||!e?t||e:J(t)&&J(e)?t.concat(e):Fe({},qn(t),qn(e))}let Qo=!0;function Vy(t){const e=wu(t),i=t.proxy,r=t.ctx;Qo=!1,e.beforeCreate&&bu(e.beforeCreate,t,"bc");const{data:n,computed:s,methods:o,watch:a,provide:c,inject:l,created:u,beforeMount:d,mounted:y,beforeUpdate:p,updated:h,activated:_,deactivated:k,beforeDestroy:P,beforeUnmount:b,destroyed:m,unmounted:g,render:w,renderTracked:S,renderTriggered:I,errorCaptured:F,serverPrefetch:N,expose:G,inheritAttrs:K,components:qe,directives:fe,filters:Re}=e;if(l&&Gy(l,r,null),o)for(const me in o){const ge=o[me];Z(ge)&&(r[me]=ge.bind(i))}if(n){const me=n.call(i,i);ke(me)&&(t.data=No(me))}if(Qo=!0,s)for(const me in s){const ge=s[me],ni=Z(ge)?ge.bind(i,i):Z(ge.get)?ge.get.bind(i,i):Nt,ar=!Z(ge)&&Z(ge.set)?ge.set.bind(i):Nt,si=Bt({get:ni,set:ar});Object.defineProperty(r,me,{enumerable:!0,configurable:!0,get:()=>si.value,set:Pt=>si.value=Pt})}if(a)for(const me in a)vu(a[me],r,i,me);if(c){const me=Z(c)?c.call(i):c;Reflect.ownKeys(me).forEach(ge=>{cu(ge,me[ge])})}u&&bu(u,t,"c");function ae(me,ge){J(ge)?ge.forEach(ni=>me(ni.bind(i))):ge&&me(ge.bind(i))}if(ae(gu,d),ae(Lr,y),ae(jy,p),ae(Uy,h),ae(Ny,_),ae(My,k),ae(Hy,F),ae(By,S),ae(qy,I),ae(zo,b),ae(Wo,g),ae(Fy,N),J(G))if(G.length){const me=t.exposed||(t.exposed={});G.forEach(ge=>{Object.defineProperty(me,ge,{get:()=>i[ge],set:ni=>i[ge]=ni,enumerable:!0})})}else t.exposed||(t.exposed={});w&&t.render===Nt&&(t.render=w),K!=null&&(t.inheritAttrs=K),qe&&(t.components=qe),fe&&(t.directives=fe),N&&Bo(t)}function Gy(t,e,i=Nt){J(t)&&(t=Yo(t));for(const r in t){const n=t[r];let s;ke(n)?"default"in n?s=Tr(n.from||r,n.default,!0):s=Tr(n.from||r):s=Tr(n),De(s)?Object.defineProperty(e,r,{enumerable:!0,configurable:!0,get:()=>s.value,set:o=>s.value=o}):e[r]=s}}function bu(t,e,i){jt(J(t)?t.map(r=>r.bind(e.proxy)):t.bind(e.proxy),e,i)}function vu(t,e,i,r){let n=r.includes(".")?uu(i,r):()=>i[r];if(Ae(t)){const s=e[t];Z(s)&&Gi(n,s)}else if(Z(t))Gi(n,t.bind(i));else if(ke(t))if(J(t))t.forEach(s=>vu(s,e,i,r));else{const s=Z(t.handler)?t.handler.bind(i):e[t.handler];Z(s)&&Gi(n,s,t)}}function wu(t){const e=t.type,{mixins:i,extends:r}=e,{mixins:n,optionsCache:s,config:{optionMergeStrategies:o}}=t.appContext,a=s.get(e);let c;return a?c=a:!n.length&&!i&&!r?c=e:(c={},n.length&&n.forEach(l=>Bn(c,l,o,!0)),Bn(c,e,o)),ke(e)&&s.set(e,c),c}function Bn(t,e,i,r=!1){const{mixins:n,extends:s}=e;s&&Bn(t,s,i,!0),n&&n.forEach(o=>Bn(t,o,i,!0));for(const o in e)if(!(r&&o==="expose")){const a=Qy[o]||i&&i[o];t[o]=a?a(t[o],e[o]):e[o]}return t}const Qy={data:_u,props:xu,emits:xu,methods:Mr,computed:Mr,beforeCreate:Xe,created:Xe,beforeMount:Xe,mounted:Xe,beforeUpdate:Xe,updated:Xe,beforeDestroy:Xe,beforeUnmount:Xe,destroyed:Xe,unmounted:Xe,activated:Xe,deactivated:Xe,errorCaptured:Xe,serverPrefetch:Xe,components:Mr,directives:Mr,watch:Xy,provide:_u,inject:Yy};function _u(t,e){return e?t?function(){return Fe(Z(t)?t.call(this,this):t,Z(e)?e.call(this,this):e)}:e:t}function Yy(t,e){return Mr(Yo(t),Yo(e))}function Yo(t){if(J(t)){const e={};for(let i=0;i<t.length;i++)e[t[i]]=t[i];return e}return t}function Xe(t,e){return t?[...new Set([].concat(t,e))]:e}function Mr(t,e){return t?Fe(Object.create(null),t,e):e}function xu(t,e){return t?J(t)&&J(e)?[...new Set([...t,...e])]:Fe(Object.create(null),qn(t),qn(e??{})):e}function Xy(t,e){if(!t)return e;if(!e)return t;const i=Fe(Object.create(null),t);for(const r in e)i[r]=Xe(t[r],e[r]);return i}function ku(){return{app:null,config:{isNativeTag:kc,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}let Jy=0;function Zy(t,e){return function(r,n=null){Z(r)||(r=Fe({},r)),n!=null&&!ke(n)&&(n=null);const s=ku(),o=new WeakSet,a=[];let c=!1;const l=s.app={_uid:Jy++,_component:r,_props:n,_container:null,_context:s,_instance:null,version:Rb,get config(){return s.config},set config(u){},use(u,...d){return o.has(u)||(u&&Z(u.install)?(o.add(u),u.install(l,...d)):Z(u)&&(o.add(u),u(l,...d))),l},mixin(u){return s.mixins.includes(u)||s.mixins.push(u),l},component(u,d){return d?(s.components[u]=d,l):s.components[u]},directive(u,d){return d?(s.directives[u]=d,l):s.directives[u]},mount(u,d,y){if(!c){const p=l._ceVNode||Ne(r,n);return p.appContext=s,y===!0?y="svg":y===!1&&(y=void 0),t(p,u,y),c=!0,l._container=u,u.__vue_app__=l,Gn(p.component)}},onUnmount(u){a.push(u)},unmount(){c&&(jt(a,l._instance,16),t(null,l._container),delete l._container.__vue_app__)},provide(u,d){return s.provides[u]=d,l},runWithContext(u){const d=Yi;Yi=l;try{return u()}finally{Yi=d}}};return l}}let Yi=null;function Su(t,e,i=le){const r=na(),n=Yt(e),s=ci(e),o=Eu(t,n),a=py((c,l)=>{let u,d=le,y;return Cy(()=>{const p=t[n];it(u,p)&&(u=p,l())}),{get(){return c(),i.get?i.get(u):u},set(p){const h=i.set?i.set(p):p;if(!it(h,u)&&!(d!==le&&it(p,d)))return;const _=r.vnode.props;_&&(e in _||n in _||s in _)&&(`onUpdate:${e}`in _||`onUpdate:${n}`in _||`onUpdate:${s}`in _)||(u=p,l()),r.emit(`update:${e}`,h),it(p,h)&&it(p,d)&&!it(h,y)&&l(),d=p,y=h}}});return a[Symbol.iterator]=()=>{let c=0;return{next(){return c<2?{value:c++?o||le:a,done:!1}:{done:!0}}}},a}const Eu=(t,e)=>e==="modelValue"||e==="model-value"?t.modelModifiers:t[`${e}Modifiers`]||t[`${Yt(e)}Modifiers`]||t[`${ci(e)}Modifiers`];function eb(t,e,...i){if(t.isUnmounted)return;const r=t.vnode.props||le;let n=i;const s=e.startsWith("update:"),o=s&&Eu(r,e.slice(7));o&&(o.trim&&(n=i.map(u=>Ae(u)?u.trim():u)),o.number&&(n=i.map(xo)));let a,c=r[a=_o(e)]||r[a=_o(Yt(e))];!c&&s&&(c=r[a=_o(ci(e))]),c&&jt(c,t,6,n);const l=r[a+"Once"];if(l){if(!t.emitted)t.emitted={};else if(t.emitted[a])return;t.emitted[a]=!0,jt(l,t,6,n)}}const tb=new WeakMap;function $u(t,e,i=!1){const r=i?tb:e.emitsCache,n=r.get(t);if(n!==void 0)return n;const s=t.emits;let o={},a=!1;if(!Z(t)){const c=l=>{const u=$u(l,e,!0);u&&(a=!0,Fe(o,u))};!i&&e.mixins.length&&e.mixins.forEach(c),t.extends&&c(t.extends),t.mixins&&t.mixins.forEach(c)}return!s&&!a?(ke(t)&&r.set(t,null),null):(J(s)?s.forEach(c=>o[c]=null):Fe(o,s),ke(t)&&r.set(t,o),o)}function Hn(t,e){return!t||!kn(e)?!1:(e=e.slice(2).replace(/Once$/,""),ue(t,e[0].toLowerCase()+e.slice(1))||ue(t,ci(e))||ue(t,e))}function H0(){}function Pu(t){const{type:e,vnode:i,proxy:r,withProxy:n,propsOptions:[s],slots:o,attrs:a,emit:c,render:l,renderCache:u,props:d,data:y,setupState:p,ctx:h,inheritAttrs:_}=t,k=Dn(t);let P,b;try{if(i.shapeFlag&4){const g=n||r,w=g;P=Ft(l.call(w,g,u,d,p,y,h)),b=a}else{const g=e;P=Ft(g.length>1?g(d,{attrs:a,slots:o,emit:c}):g(d,null)),b=e.props?a:ib(a)}}catch(g){Dr.length=0,Cr(g,t,1),P=Ne(ii)}let m=P;if(b&&_!==!1){const g=Object.keys(b),{shapeFlag:w}=m;g.length&&w&7&&(s&&g.some(bo)&&(b=rb(b,s)),m=Xi(m,b,!1,!0))}return i.dirs&&(m=Xi(m,null,!1,!0),m.dirs=m.dirs?m.dirs.concat(i.dirs):i.dirs),i.transition&&qo(m,i.transition),P=m,Dn(k),P}const ib=t=>{let e;for(const i in t)(i==="class"||i==="style"||kn(i))&&((e||(e={}))[i]=t[i]);return e},rb=(t,e)=>{const i={};for(const r in t)(!bo(r)||!(r.slice(9)in e))&&(i[r]=t[r]);return i};function nb(t,e,i){const{props:r,children:n,component:s}=t,{props:o,children:a,patchFlag:c}=e,l=s.emitsOptions;if(e.dirs||e.transition)return!0;if(i&&c>=0){if(c&1024)return!0;if(c&16)return r?Cu(r,o,l):!!o;if(c&8){const u=e.dynamicProps;for(let d=0;d<u.length;d++){const y=u[d];if(o[y]!==r[y]&&!Hn(l,y))return!0}}}else return(n||a)&&(!a||!a.$stable)?!0:r===o?!1:r?o?Cu(r,o,l):!0:!!o;return!1}function Cu(t,e,i){const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!0;for(let n=0;n<r.length;n++){const s=r[n];if(e[s]!==t[s]&&!Hn(i,s))return!0}return!1}function sb({vnode:t,parent:e},i){for(;e;){const r=e.subTree;if(r.suspense&&r.suspense.activeBranch===t&&(r.el=t.el),r===t)(t=e.vnode).el=i,e=e.parent;else break}}const Iu={},Au=()=>Object.create(Iu),Ru=t=>Object.getPrototypeOf(t)===Iu;function ob(t,e,i,r=!1){const n={},s=Au();t.propsDefaults=Object.create(null),Tu(t,e,n,s);for(const o in t.propsOptions[0])o in n||(n[o]=void 0);i?t.props=r?n:cy(n):t.type.props?t.props=n:t.props=s,t.attrs=s}function ab(t,e,i,r){const{props:n,attrs:s,vnode:{patchFlag:o}}=t,a=oe(n),[c]=t.propsOptions;let l=!1;if((r||o>0)&&!(o&16)){if(o&8){const u=t.vnode.dynamicProps;for(let d=0;d<u.length;d++){let y=u[d];if(Hn(t.emitsOptions,y))continue;const p=e[y];if(c)if(ue(s,y))p!==s[y]&&(s[y]=p,l=!0);else{const h=Yt(y);n[h]=Xo(c,a,h,p,t,!1)}else p!==s[y]&&(s[y]=p,l=!0)}}}else{Tu(t,e,n,s)&&(l=!0);let u;for(const d in a)(!e||!ue(e,d)&&((u=ci(d))===d||!ue(e,u)))&&(c?i&&(i[d]!==void 0||i[u]!==void 0)&&(n[d]=Xo(c,a,d,void 0,t,!0)):delete n[d]);if(s!==a)for(const d in s)(!e||!ue(e,d))&&(delete s[d],l=!0)}l&&Xt(t.attrs,"set","")}function Tu(t,e,i,r){const[n,s]=t.propsOptions;let o=!1,a;if(e)for(let c in e){if(_r(c))continue;const l=e[c];let u;n&&ue(n,u=Yt(c))?!s||!s.includes(u)?i[u]=l:(a||(a={}))[u]=l:Hn(t.emitsOptions,c)||(!(c in r)||l!==r[c])&&(r[c]=l,o=!0)}if(s){const c=oe(i),l=a||le;for(let u=0;u<s.length;u++){const d=s[u];i[d]=Xo(n,c,d,l[d],t,!ue(l,d))}}return o}function Xo(t,e,i,r,n,s){const o=t[i];if(o!=null){const a=ue(o,"default");if(a&&r===void 0){const c=o.default;if(o.type!==Function&&!o.skipFactory&&Z(c)){const{propsDefaults:l}=n;if(i in l)r=l[i];else{const u=qr(n);r=l[i]=c.call(null,e),u()}}else r=c;n.ce&&n.ce._setProp(i,r)}o[0]&&(s&&!a?r=!1:o[1]&&(r===""||r===ci(i))&&(r=!0))}return r}const lb=new WeakMap;function Ou(t,e,i=!1){const r=i?lb:e.propsCache,n=r.get(t);if(n)return n;const s=t.props,o={},a=[];let c=!1;if(!Z(t)){const u=d=>{c=!0;const[y,p]=Ou(d,e,!0);Fe(o,y),p&&a.push(...p)};!i&&e.mixins.length&&e.mixins.forEach(u),t.extends&&u(t.extends),t.mixins&&t.mixins.forEach(u)}if(!s&&!c)return ke(t)&&r.set(t,qi),qi;if(J(s))for(let u=0;u<s.length;u++){const d=Yt(s[u]);Lu(d)&&(o[d]=le)}else if(s)for(const u in s){const d=Yt(u);if(Lu(d)){const y=s[u],p=o[d]=J(y)||Z(y)?{type:y}:Fe({},y),h=p.type;let _=!1,k=!0;if(J(h))for(let P=0;P<h.length;++P){const b=h[P],m=Z(b)&&b.name;if(m==="Boolean"){_=!0;break}else m==="String"&&(k=!1)}else _=Z(h)&&h.name==="Boolean";p[0]=_,p[1]=k,(_||ue(p,"default"))&&a.push(d)}}const l=[o,a];return ke(t)&&r.set(t,l),l}function Lu(t){return t[0]!=="$"&&!_r(t)}const Jo=t=>t==="_"||t==="_ctx"||t==="$stable",Zo=t=>J(t)?t.map(Ft):[Ft(t)],cb=(t,e,i)=>{if(e._n)return e;const r=Rr((...n)=>Zo(e(...n)),i);return r._c=!1,r},Nu=(t,e,i)=>{const r=t._ctx;for(const n in t){if(Jo(n))continue;const s=t[n];if(Z(s))e[n]=cb(n,s,r);else if(s!=null){const o=Zo(s);e[n]=()=>o}}},Mu=(t,e)=>{const i=Zo(e);t.slots.default=()=>i},Du=(t,e,i)=>{for(const r in e)(i||!Jo(r))&&(t[r]=e[r])},ub=(t,e,i)=>{const r=t.slots=Au();if(t.vnode.shapeFlag&32){const n=e._;n?(Du(r,e,i),i&&Ic(r,"_",n,!0)):Nu(e,r)}else e&&Mu(t,e)},db=(t,e,i)=>{const{vnode:r,slots:n}=t;let s=!0,o=le;if(r.shapeFlag&32){const a=e._;a?i&&a===1?s=!1:Du(n,e,i):(s=!e.$stable,Nu(e,n)),o=e}else e&&(Mu(t,e),o={default:1});if(s)for(const a in n)!Jo(a)&&o[a]==null&&delete n[a]},at=mb;function fb(t){return hb(t)}function hb(t,e){const i=Pn();i.__VUE__=!0;const{insert:r,remove:n,patchProp:s,createElement:o,createText:a,createComment:c,setText:l,setElementText:u,parentNode:d,nextSibling:y,setScopeId:p=Nt,insertStaticContent:h}=t,_=(v,x,E,T=null,R=null,O=null,B=void 0,q=null,D=!!x.dynamicChildren)=>{if(v===x)return;v&&!Ur(v,x)&&(T=H(v),Pt(v,R,O,!0),v=null),x.patchFlag===-2&&(D=!1,x.dynamicChildren=null);const{type:L,ref:Q,shapeFlag:z}=x;switch(L){case zn:k(v,x,E,T);break;case ii:P(v,x,E,T);break;case ta:v==null&&b(x,E,T,B);break;case We:qe(v,x,E,T,R,O,B,q,D);break;default:z&1?w(v,x,E,T,R,O,B,q,D):z&6?fe(v,x,E,T,R,O,B,q,D):(z&64||z&128)&&L.process(v,x,E,T,R,O,B,q,D,we)}Q!=null&&R?Or(Q,v&&v.ref,O,x||v,!x):Q==null&&v&&v.ref!=null&&Or(v.ref,null,O,v,!0)},k=(v,x,E,T)=>{if(v==null)r(x.el=a(x.children),E,T);else{const R=x.el=v.el;x.children!==v.children&&l(R,x.children)}},P=(v,x,E,T)=>{v==null?r(x.el=c(x.children||""),E,T):x.el=v.el},b=(v,x,E,T)=>{[v.el,v.anchor]=h(v.children,x,E,T,v.el,v.anchor)},m=({el:v,anchor:x},E,T)=>{let R;for(;v&&v!==x;)R=y(v),r(v,E,T),v=R;r(x,E,T)},g=({el:v,anchor:x})=>{let E;for(;v&&v!==x;)E=y(v),n(v),v=E;n(x)},w=(v,x,E,T,R,O,B,q,D)=>{if(x.type==="svg"?B="svg":x.type==="math"&&(B="mathml"),v==null)S(x,E,T,R,O,B,q,D);else{const L=v.el&&v.el._isVueCE?v.el:null;try{L&&L._beginPatch(),N(v,x,R,O,B,q,D)}finally{L&&L._endPatch()}}},S=(v,x,E,T,R,O,B,q)=>{let D,L;const{props:Q,shapeFlag:z,transition:V,dirs:ee}=v;if(D=v.el=o(v.type,O,Q&&Q.is,Q),z&8?u(D,v.children):z&16&&F(v.children,D,null,T,R,ea(v,O),B,q),ee&&Ei(v,null,T,"created"),I(D,v,v.scopeId,B,T),Q){for(const _e in Q)_e!=="value"&&!_r(_e)&&s(D,_e,null,Q[_e],O,T);"value"in Q&&s(D,"value",null,Q.value,O),(L=Q.onVnodeBeforeMount)&&qt(L,T,v)}ee&&Ei(v,null,T,"beforeMount");const se=pb(R,V);se&&V.beforeEnter(D),r(D,x,E),((L=Q&&Q.onVnodeMounted)||se||ee)&&at(()=>{L&&qt(L,T,v),se&&V.enter(D),ee&&Ei(v,null,T,"mounted")},R)},I=(v,x,E,T,R)=>{if(E&&p(v,E),T)for(let O=0;O<T.length;O++)p(v,T[O]);if(R){let O=R.subTree;if(x===O||Bu(O.type)&&(O.ssContent===x||O.ssFallback===x)){const B=R.vnode;I(v,B,B.scopeId,B.slotScopeIds,R.parent)}}},F=(v,x,E,T,R,O,B,q,D=0)=>{for(let L=D;L<v.length;L++){const Q=v[L]=q?hi(v[L]):Ft(v[L]);_(null,Q,x,E,T,R,O,B,q)}},N=(v,x,E,T,R,O,B)=>{const q=x.el=v.el;let{patchFlag:D,dynamicChildren:L,dirs:Q}=x;D|=v.patchFlag&16;const z=v.props||le,V=x.props||le;let ee;if(E&&Pi(E,!1),(ee=V.onVnodeBeforeUpdate)&&qt(ee,E,x,v),Q&&Ei(x,v,E,"beforeUpdate"),E&&Pi(E,!0),(z.innerHTML&&V.innerHTML==null||z.textContent&&V.textContent==null)&&u(q,""),L?G(v.dynamicChildren,L,q,E,T,ea(x,R),O):B||ge(v,x,q,null,E,T,ea(x,R),O,!1),D>0){if(D&16)K(q,z,V,E,R);else if(D&2&&z.class!==V.class&&s(q,"class",null,V.class,R),D&4&&s(q,"style",z.style,V.style,R),D&8){const se=x.dynamicProps;for(let _e=0;_e<se.length;_e++){const he=se[_e],nt=z[he],st=V[he];(st!==nt||he==="value")&&s(q,he,nt,st,R,E)}}D&1&&v.children!==x.children&&u(q,x.children)}else!B&&L==null&&K(q,z,V,E,R);((ee=V.onVnodeUpdated)||Q)&&at(()=>{ee&&qt(ee,E,x,v),Q&&Ei(x,v,E,"updated")},T)},G=(v,x,E,T,R,O,B)=>{for(let q=0;q<x.length;q++){const D=v[q],L=x[q],Q=D.el&&(D.type===We||!Ur(D,L)||D.shapeFlag&198)?d(D.el):E;_(D,L,Q,null,T,R,O,B,!0)}},K=(v,x,E,T,R)=>{if(x!==E){if(x!==le)for(const O in x)!_r(O)&&!(O in E)&&s(v,O,x[O],null,R,T);for(const O in E){if(_r(O))continue;const B=E[O],q=x[O];B!==q&&O!=="value"&&s(v,O,q,B,R,T)}"value"in E&&s(v,"value",x.value,E.value,R)}},qe=(v,x,E,T,R,O,B,q,D)=>{const L=x.el=v?v.el:a(""),Q=x.anchor=v?v.anchor:a("");let{patchFlag:z,dynamicChildren:V,slotScopeIds:ee}=x;ee&&(q=q?q.concat(ee):ee),v==null?(r(L,E,T),r(Q,E,T),F(x.children||[],E,Q,R,O,B,q,D)):z>0&&z&64&&V&&v.dynamicChildren&&v.dynamicChildren.length===V.length?(G(v.dynamicChildren,V,E,R,O,B,q),(x.key!=null||R&&x===R.subTree)&&ju(v,x,!0)):ge(v,x,E,Q,R,O,B,q,D)},fe=(v,x,E,T,R,O,B,q,D)=>{x.slotScopeIds=q,v==null?x.shapeFlag&512?R.ctx.activate(x,E,T,B,D):Re(x,E,T,R,O,B,D):Pe(v,x,D)},Re=(v,x,E,T,R,O,B)=>{const q=v.component=xb(v,T,R);if(Ho(v)&&(q.ctx.renderer=we),kb(q,!1,B),q.asyncDep){if(R&&R.registerDep(q,ae,B),!v.el){const D=q.subTree=Ne(ii);P(null,D,x,E),v.placeholder=D.el}}else ae(q,v,x,E,R,O,B)},Pe=(v,x,E)=>{const T=x.component=v.component;if(nb(v,x,E))if(T.asyncDep&&!T.asyncResolved){me(T,x,E);return}else T.next=x,T.update();else x.el=v.el,T.vnode=x},ae=(v,x,E,T,R,O,B)=>{const q=()=>{if(v.isMounted){let{next:z,bu:V,u:ee,parent:se,vnode:_e}=v;{const zt=Uu(v);if(zt){z&&(z.el=_e.el,me(v,z,B)),zt.asyncDep.then(()=>{v.isUnmounted||q()});return}}let he=z,nt;Pi(v,!1),z?(z.el=_e.el,me(v,z,B)):z=_e,V&&$n(V),(nt=z.props&&z.props.onVnodeBeforeUpdate)&&qt(nt,se,z,_e),Pi(v,!0);const st=Pu(v),Ht=v.subTree;v.subTree=st,_(Ht,st,d(Ht.el),H(Ht),v,R,O),z.el=st.el,he===null&&sb(v,st.el),ee&&at(ee,R),(nt=z.props&&z.props.onVnodeUpdated)&&at(()=>qt(nt,se,z,_e),R)}else{let z;const{el:V,props:ee}=x,{bm:se,m:_e,parent:he,root:nt,type:st}=v,Ht=Qi(x);Pi(v,!1),se&&$n(se),!Ht&&(z=ee&&ee.onVnodeBeforeMount)&&qt(z,he,x),Pi(v,!0);{nt.ce&&nt.ce._def.shadowRoot!==!1&&nt.ce._injectChildStyle(st);const zt=v.subTree=Pu(v);_(null,zt,E,T,v,R,O),x.el=zt.el}if(_e&&at(_e,R),!Ht&&(z=ee&&ee.onVnodeMounted)){const zt=x;at(()=>qt(z,he,zt),R)}(x.shapeFlag&256||he&&Qi(he.vnode)&&he.vnode.shapeFlag&256)&&v.a&&at(v.a,R),v.isMounted=!0,x=E=T=null}};v.scope.on();const D=v.effect=new Lc(q);v.scope.off();const L=v.update=D.run.bind(D),Q=v.job=D.runIfDirty.bind(D);Q.i=v,Q.id=v.uid,D.scheduler=()=>Uo(Q),Pi(v,!0),L()},me=(v,x,E)=>{x.component=v;const T=v.vnode.props;v.vnode=x,v.next=null,ab(v,x.props,T,E),db(v,x.children,E),Mt(),nu(v),Dt()},ge=(v,x,E,T,R,O,B,q,D=!1)=>{const L=v&&v.children,Q=v?v.shapeFlag:0,z=x.children,{patchFlag:V,shapeFlag:ee}=x;if(V>0){if(V&128){ar(L,z,E,T,R,O,B,q,D);return}else if(V&256){ni(L,z,E,T,R,O,B,q,D);return}}ee&8?(Q&16&&M(L,R,O),z!==L&&u(E,z)):Q&16?ee&16?ar(L,z,E,T,R,O,B,q,D):M(L,R,O,!0):(Q&8&&u(E,""),ee&16&&F(z,E,T,R,O,B,q,D))},ni=(v,x,E,T,R,O,B,q,D)=>{v=v||qi,x=x||qi;const L=v.length,Q=x.length,z=Math.min(L,Q);let V;for(V=0;V<z;V++){const ee=x[V]=D?hi(x[V]):Ft(x[V]);_(v[V],ee,E,null,R,O,B,q,D)}L>Q?M(v,R,O,!0,!1,z):F(x,E,T,R,O,B,q,D,z)},ar=(v,x,E,T,R,O,B,q,D)=>{let L=0;const Q=x.length;let z=v.length-1,V=Q-1;for(;L<=z&&L<=V;){const ee=v[L],se=x[L]=D?hi(x[L]):Ft(x[L]);if(Ur(ee,se))_(ee,se,E,null,R,O,B,q,D);else break;L++}for(;L<=z&&L<=V;){const ee=v[z],se=x[V]=D?hi(x[V]):Ft(x[V]);if(Ur(ee,se))_(ee,se,E,null,R,O,B,q,D);else break;z--,V--}if(L>z){if(L<=V){const ee=V+1,se=ee<Q?x[ee].el:T;for(;L<=V;)_(null,x[L]=D?hi(x[L]):Ft(x[L]),E,se,R,O,B,q,D),L++}}else if(L>V)for(;L<=z;)Pt(v[L],R,O,!0),L++;else{const ee=L,se=L,_e=new Map;for(L=se;L<=V;L++){const ft=x[L]=D?hi(x[L]):Ft(x[L]);ft.key!=null&&_e.set(ft.key,L)}let he,nt=0;const st=V-se+1;let Ht=!1,zt=0;const Yr=new Array(st);for(L=0;L<st;L++)Yr[L]=0;for(L=ee;L<=z;L++){const ft=v[L];if(nt>=st){Pt(ft,R,O,!0);continue}let Wt;if(ft.key!=null)Wt=_e.get(ft.key);else for(he=se;he<=V;he++)if(Yr[he-se]===0&&Ur(ft,x[he])){Wt=he;break}Wt===void 0?Pt(ft,R,O,!0):(Yr[Wt-se]=L+1,Wt>=zt?zt=Wt:Ht=!0,_(ft,x[Wt],E,null,R,O,B,q,D),nt++)}const jf=Ht?gb(Yr):qi;for(he=jf.length-1,L=st-1;L>=0;L--){const ft=se+L,Wt=x[ft],Uf=x[ft+1],Ff=ft+1<Q?Uf.el||qu(Uf):T;Yr[L]===0?_(null,Wt,E,Ff,R,O,B,q,D):Ht&&(he<0||L!==jf[he]?si(Wt,E,Ff,2):he--)}}},si=(v,x,E,T,R=null)=>{const{el:O,type:B,transition:q,children:D,shapeFlag:L}=v;if(L&6){si(v.component.subTree,x,E,T);return}if(L&128){v.suspense.move(x,E,T);return}if(L&64){B.move(v,x,E,we);return}if(B===We){r(O,x,E);for(let z=0;z<D.length;z++)si(D[z],x,E,T);r(v.anchor,x,E);return}if(B===ta){m(v,x,E);return}if(T!==2&&L&1&&q)if(T===0)q.beforeEnter(O),r(O,x,E),at(()=>q.enter(O),R);else{const{leave:z,delayLeave:V,afterLeave:ee}=q,se=()=>{v.ctx.isUnmounted?n(O):r(O,x,E)},_e=()=>{O._isLeaving&&O[Ty](!0),z(O,()=>{se(),ee&&ee()})};V?V(O,se,_e):_e()}else r(O,x,E)},Pt=(v,x,E,T=!1,R=!1)=>{const{type:O,props:B,ref:q,children:D,dynamicChildren:L,shapeFlag:Q,patchFlag:z,dirs:V,cacheIndex:ee}=v;if(z===-2&&(R=!1),q!=null&&(Mt(),Or(q,null,E,v,!0),Dt()),ee!=null&&(x.renderCache[ee]=void 0),Q&256){x.ctx.deactivate(v);return}const se=Q&1&&V,_e=!Qi(v);let he;if(_e&&(he=B&&B.onVnodeBeforeUnmount)&&qt(he,x,v),Q&6)C(v.component,E,T);else{if(Q&128){v.suspense.unmount(E,T);return}se&&Ei(v,null,x,"beforeUnmount"),Q&64?v.type.remove(v,x,E,we,T):L&&!L.hasOnce&&(O!==We||z>0&&z&64)?M(L,x,E,!1,!0):(O===We&&z&384||!R&&Q&16)&&M(D,x,E),T&&vs(v)}(_e&&(he=B&&B.onVnodeUnmounted)||se)&&at(()=>{he&&qt(he,x,v),se&&Ei(v,null,x,"unmounted")},E)},vs=v=>{const{type:x,el:E,anchor:T,transition:R}=v;if(x===We){Li(E,T);return}if(x===ta){g(v);return}const O=()=>{n(E),R&&!R.persisted&&R.afterLeave&&R.afterLeave()};if(v.shapeFlag&1&&R&&!R.persisted){const{leave:B,delayLeave:q}=R,D=()=>B(E,O);q?q(v.el,O,D):D()}else O()},Li=(v,x)=>{let E;for(;v!==x;)E=y(v),n(v),v=E;n(x)},C=(v,x,E)=>{const{bum:T,scope:R,job:O,subTree:B,um:q,m:D,a:L}=v;Fu(D),Fu(L),T&&$n(T),R.stop(),O&&(O.flags|=8,Pt(B,v,x,E)),q&&at(q,x),at(()=>{v.isUnmounted=!0},x)},M=(v,x,E,T=!1,R=!1,O=0)=>{for(let B=O;B<v.length;B++)Pt(v[B],x,E,T,R)},H=v=>{if(v.shapeFlag&6)return H(v.component.subTree);if(v.shapeFlag&128)return v.suspense.next();const x=y(v.anchor||v.el),E=x&&x[Ay];return E?y(E):x};let te=!1;const Je=(v,x,E)=>{let T;v==null?x._vnode&&(Pt(x._vnode,null,null,!0),T=x._vnode.component):_(x._vnode||null,v,x,null,null,null,E),x._vnode=v,te||(te=!0,nu(T),su(),te=!1)},we={p:_,um:Pt,m:si,r:vs,mt:Re,mc:F,pc:ge,pbc:G,n:H,o:t};return{render:Je,hydrate:void 0,createApp:Zy(Je)}}function ea({type:t,props:e},i){return i==="svg"&&t==="foreignObject"||i==="mathml"&&t==="annotation-xml"&&e&&e.encoding&&e.encoding.includes("html")?void 0:i}function Pi({effect:t,job:e},i){i?(t.flags|=32,e.flags|=4):(t.flags&=-33,e.flags&=-5)}function pb(t,e){return(!t||t&&!t.pendingBranch)&&e&&!e.persisted}function ju(t,e,i=!1){const r=t.children,n=e.children;if(J(r)&&J(n))for(let s=0;s<r.length;s++){const o=r[s];let a=n[s];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=n[s]=hi(n[s]),a.el=o.el),!i&&a.patchFlag!==-2&&ju(o,a)),a.type===zn&&(a.patchFlag!==-1?a.el=o.el:a.__elIndex=s+(t.type===We?1:0)),a.type===ii&&!a.el&&(a.el=o.el)}}function gb(t){const e=t.slice(),i=[0];let r,n,s,o,a;const c=t.length;for(r=0;r<c;r++){const l=t[r];if(l!==0){if(n=i[i.length-1],t[n]<l){e[r]=n,i.push(r);continue}for(s=0,o=i.length-1;s<o;)a=s+o>>1,t[i[a]]<l?s=a+1:o=a;l<t[i[s]]&&(s>0&&(e[r]=i[s-1]),i[s]=r)}}for(s=i.length,o=i[s-1];s-- >0;)i[s]=o,o=e[o];return i}function Uu(t){const e=t.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:Uu(e)}function Fu(t){if(t)for(let e=0;e<t.length;e++)t[e].flags|=8}function qu(t){if(t.placeholder)return t.placeholder;const e=t.component;return e?qu(e.subTree):null}const Bu=t=>t.__isSuspense;function mb(t,e){e&&e.pendingBranch?J(t)?e.effects.push(...t):e.effects.push(t):Ey(t)}const We=Symbol.for("v-fgt"),zn=Symbol.for("v-txt"),ii=Symbol.for("v-cmt"),ta=Symbol.for("v-stc"),Dr=[];let lt=null;function de(t=!1){Dr.push(lt=t?null:[])}function yb(){Dr.pop(),lt=Dr[Dr.length-1]||null}let jr=1;function Hu(t,e=!1){jr+=t,t<0&&lt&&e&&(lt.hasOnce=!0)}function zu(t){return t.dynamicChildren=jr>0?lt||qi:null,yb(),jr>0&&lt&&lt.push(t),t}function ve(t,e,i,r,n,s){return zu(ie(t,e,i,r,n,s,!0))}function Wn(t,e,i,r,n){return zu(Ne(t,e,i,r,n,!0))}function ia(t){return t?t.__v_isVNode===!0:!1}function Ur(t,e){return t.type===e.type&&t.key===e.key}const Wu=({key:t})=>t??null,Kn=({ref:t,ref_key:e,ref_for:i})=>(typeof t=="number"&&(t=""+t),t!=null?Ae(t)||De(t)||Z(t)?{i:ze,r:t,k:e,f:!!i}:t:null);function ie(t,e=null,i=null,r=0,n=null,s=t===We?0:1,o=!1,a=!1){const c={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&Wu(e),ref:e&&Kn(e),scopeId:au,slotScopeIds:null,children:i,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:s,patchFlag:r,dynamicProps:n,dynamicChildren:null,appContext:null,ctx:ze};return a?(ra(c,i),s&128&&t.normalize(c)):i&&(c.shapeFlag|=Ae(i)?8:16),jr>0&&!o&&lt&&(c.patchFlag>0||s&6)&&c.patchFlag!==32&&lt.push(c),c}const Ne=bb;function bb(t,e=null,i=null,r=0,n=null,s=!1){if((!t||t===zy)&&(t=ii),ia(t)){const a=Xi(t,e,!0);return i&&ra(a,i),jr>0&&!s&&lt&&(a.shapeFlag&6?lt[lt.indexOf(t)]=a:lt.push(a)),a.patchFlag=-2,a}if(Ab(t)&&(t=t.__vccOpts),e){e=vb(e);let{class:a,style:c}=e;a&&!Ae(a)&&(e.class=xt(a)),ke(c)&&(Do(c)&&!J(c)&&(c=Fe({},c)),e.style=ko(c))}const o=Ae(t)?1:Bu(t)?128:Ry(t)?64:ke(t)?4:Z(t)?2:0;return ie(t,e,i,r,n,o,s,!0)}function vb(t){return t?Do(t)||Ru(t)?Fe({},t):t:null}function Xi(t,e,i=!1,r=!1){const{props:n,ref:s,patchFlag:o,children:a,transition:c}=t,l=e?Ku(n||{},e):n,u={__v_isVNode:!0,__v_skip:!0,type:t.type,props:l,key:l&&Wu(l),ref:e&&e.ref?i&&s?J(s)?s.concat(Kn(e)):[s,Kn(e)]:Kn(e):s,scopeId:t.scopeId,slotScopeIds:t.slotScopeIds,children:a,target:t.target,targetStart:t.targetStart,targetAnchor:t.targetAnchor,staticCount:t.staticCount,shapeFlag:t.shapeFlag,patchFlag:e&&t.type!==We?o===-1?16:o|16:o,dynamicProps:t.dynamicProps,dynamicChildren:t.dynamicChildren,appContext:t.appContext,dirs:t.dirs,transition:c,component:t.component,suspense:t.suspense,ssContent:t.ssContent&&Xi(t.ssContent),ssFallback:t.ssFallback&&Xi(t.ssFallback),placeholder:t.placeholder,el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce};return c&&r&&qo(u,c.clone(u)),u}function Fr(t=" ",e=0){return Ne(zn,null,t,e)}function fi(t="",e=!1){return e?(de(),Wn(ii,null,t)):Ne(ii,null,t)}function Ft(t){return t==null||typeof t=="boolean"?Ne(ii):J(t)?Ne(We,null,t.slice()):ia(t)?hi(t):Ne(zn,null,String(t))}function hi(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:Xi(t)}function ra(t,e){let i=0;const{shapeFlag:r}=t;if(e==null)e=null;else if(J(e))i=16;else if(typeof e=="object")if(r&65){const n=e.default;n&&(n._c&&(n._d=!1),ra(t,n()),n._c&&(n._d=!0));return}else{i=32;const n=e._;!n&&!Ru(e)?e._ctx=ze:n===3&&ze&&(ze.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else Z(e)?(e={default:e,_ctx:ze},i=32):(e=String(e),r&64?(i=16,e=[Fr(e)]):i=8);t.children=e,t.shapeFlag|=i}function Ku(...t){const e={};for(let i=0;i<t.length;i++){const r=t[i];for(const n in r)if(n==="class")e.class!==r.class&&(e.class=xt([e.class,r.class]));else if(n==="style")e.style=ko([e.style,r.style]);else if(kn(n)){const s=e[n],o=r[n];o&&s!==o&&!(J(s)&&s.includes(o))&&(e[n]=s?[].concat(s,o):o)}else n!==""&&(e[n]=r[n])}return e}function qt(t,e,i,r=null){jt(t,e,7,[i,r])}const wb=ku();let _b=0;function xb(t,e,i){const r=t.type,n=(e?e.appContext:t.appContext)||wb,s={uid:_b++,vnode:t,type:r,parent:e,appContext:n,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new Hm(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:e?e.provides:Object.create(n.provides),ids:e?e.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:Ou(r,n),emitsOptions:$u(r,n),emit:null,emitted:null,propsDefaults:le,inheritAttrs:r.inheritAttrs,ctx:le,data:le,props:le,attrs:le,slots:le,refs:le,setupState:le,setupContext:null,suspense:i,suspenseId:i?i.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return s.ctx={_:s},s.root=e?e.root:s,s.emit=eb.bind(null,s),t.ce&&t.ce(s),s}let Ke=null;const na=()=>Ke||ze;let Vn,sa;{const t=Pn(),e=(i,r)=>{let n;return(n=t[i])||(n=t[i]=[]),n.push(r),s=>{n.length>1?n.forEach(o=>o(s)):n[0](s)}};Vn=e("__VUE_INSTANCE_SETTERS__",i=>Ke=i),sa=e("__VUE_SSR_SETTERS__",i=>Ji=i)}const qr=t=>{const e=Ke;return Vn(t),t.scope.on(),()=>{t.scope.off(),Vn(e)}},Vu=()=>{Ke&&Ke.scope.off(),Vn(null)};function Gu(t){return t.vnode.shapeFlag&4}let Ji=!1;function kb(t,e=!1,i=!1){e&&sa(e);const{props:r,children:n}=t.vnode,s=Gu(t);ob(t,r,s,e),ub(t,n,i||e);const o=s?Sb(t,e):void 0;return e&&sa(!1),o}function Sb(t,e){const i=t.type;t.accessCache=Object.create(null),t.proxy=new Proxy(t.ctx,Ky);const{setup:r}=i;if(r){Mt();const n=t.setupContext=r.length>1?$b(t):null,s=qr(t),o=Wi(r,t,0,[t.props,n]),a=Ec(o);if(Dt(),s(),(a||t.sp)&&!Qi(t)&&Bo(t),a){if(o.then(Vu,Vu),e)return o.then(c=>{Qu(t,c)}).catch(c=>{Cr(c,t,0)});t.asyncDep=o}else Qu(t,o)}else Yu(t)}function Qu(t,e,i){Z(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:ke(e)&&(t.setupState=eu(e)),Yu(t)}function Yu(t,e,i){const r=t.type;t.render||(t.render=r.render||Nt);{const n=qr(t);Mt();try{Vy(t)}finally{Dt(),n()}}}const Eb={get(t,e){return He(t,"get",""),t[e]}};function $b(t){const e=i=>{t.exposed=i||{}};return{attrs:new Proxy(t.attrs,Eb),slots:t.slots,emit:t.emit,expose:e}}function Gn(t){return t.exposed?t.exposeProxy||(t.exposeProxy=new Proxy(eu(uy(t.exposed)),{get(e,i){if(i in e)return e[i];if(i in Nr)return Nr[i](t)},has(e,i){return i in e||i in Nr}})):t.proxy}const Pb=/(?:^|[-_])\w/g,Cb=t=>t.replace(Pb,e=>e.toUpperCase()).replace(/[-_]/g,"");function Ib(t,e=!0){return Z(t)?t.displayName||t.name:t.name||e&&t.__name}function Xu(t,e,i=!1){let r=Ib(e);if(!r&&e.__file){const n=e.__file.match(/([^/\\]+)\.\w+$/);n&&(r=n[1])}if(!r&&t){const n=s=>{for(const o in s)if(s[o]===e)return o};r=n(t.components)||t.parent&&n(t.parent.type.components)||n(t.appContext.components)}return r?Cb(r):i?"App":"Anonymous"}function Ab(t){return Z(t)&&"__vccOpts"in t}const Bt=(t,e)=>my(t,e,Ji),Rb="3.5.26";let oa;const Ju=typeof window<"u"&&window.trustedTypes;if(Ju)try{oa=Ju.createPolicy("vue",{createHTML:t=>t})}catch{}const Zu=oa?t=>oa.createHTML(t):t=>t,Tb="http://www.w3.org/2000/svg",Ob="http://www.w3.org/1998/Math/MathML",ri=typeof document<"u"?document:null,ed=ri&&ri.createElement("template"),Lb={insert:(t,e,i)=>{e.insertBefore(t,i||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,i,r)=>{const n=e==="svg"?ri.createElementNS(Tb,t):e==="mathml"?ri.createElementNS(Ob,t):i?ri.createElement(t,{is:i}):ri.createElement(t);return t==="select"&&r&&r.multiple!=null&&n.setAttribute("multiple",r.multiple),n},createText:t=>ri.createTextNode(t),createComment:t=>ri.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>ri.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,i,r,n,s){const o=i?i.previousSibling:e.lastChild;if(n&&(n===s||n.nextSibling))for(;e.insertBefore(n.cloneNode(!0),i),!(n===s||!(n=n.nextSibling)););else{ed.innerHTML=Zu(r==="svg"?`<svg>${t}</svg>`:r==="mathml"?`<math>${t}</math>`:t);const a=ed.content;if(r==="svg"||r==="mathml"){const c=a.firstChild;for(;c.firstChild;)a.appendChild(c.firstChild);a.removeChild(c)}e.insertBefore(a,i)}return[o?o.nextSibling:e.firstChild,i?i.previousSibling:e.lastChild]}},Nb=Symbol("_vtc");function Mb(t,e,i){const r=t[Nb];r&&(e=(e?[e,...r]:[...r]).join(" ")),e==null?t.removeAttribute("class"):i?t.setAttribute("class",e):t.className=e}const td=Symbol("_vod"),Db=Symbol("_vsh"),jb=Symbol(""),Ub=/(?:^|;)\s*display\s*:/;function Fb(t,e,i){const r=t.style,n=Ae(i);let s=!1;if(i&&!n){if(e)if(Ae(e))for(const o of e.split(";")){const a=o.slice(0,o.indexOf(":")).trim();i[a]==null&&Qn(r,a,"")}else for(const o in e)i[o]==null&&Qn(r,o,"");for(const o in i)o==="display"&&(s=!0),Qn(r,o,i[o])}else if(n){if(e!==i){const o=r[jb];o&&(i+=";"+o),r.cssText=i,s=Ub.test(i)}}else e&&t.removeAttribute("style");td in t&&(t[td]=s?r.display:"",t[Db]&&(r.display="none"))}const id=/\s*!important$/;function Qn(t,e,i){if(J(i))i.forEach(r=>Qn(t,e,r));else if(i==null&&(i=""),e.startsWith("--"))t.setProperty(e,i);else{const r=qb(t,e);id.test(i)?t.setProperty(ci(r),i.replace(id,""),"important"):t[r]=i}}const rd=["Webkit","Moz","ms"],aa={};function qb(t,e){const i=aa[e];if(i)return i;let r=Yt(e);if(r!=="filter"&&r in t)return aa[e]=r;r=Cc(r);for(let n=0;n<rd.length;n++){const s=rd[n]+r;if(s in t)return aa[e]=s}return e}const nd="http://www.w3.org/1999/xlink";function sd(t,e,i,r,n,s=Bm(e)){r&&e.startsWith("xlink:")?i==null?t.removeAttributeNS(nd,e.slice(6,e.length)):t.setAttributeNS(nd,e,i):i==null||s&&!Rc(i)?t.removeAttribute(e):t.setAttribute(e,s?"":Qt(i)?String(i):i)}function od(t,e,i,r,n){if(e==="innerHTML"||e==="textContent"){i!=null&&(t[e]=e==="innerHTML"?Zu(i):i);return}const s=t.tagName;if(e==="value"&&s!=="PROGRESS"&&!s.includes("-")){const a=s==="OPTION"?t.getAttribute("value")||"":t.value,c=i==null?t.type==="checkbox"?"on":"":String(i);(a!==c||!("_value"in t))&&(t.value=c),i==null&&t.removeAttribute(e),t._value=i;return}let o=!1;if(i===""||i==null){const a=typeof t[e];a==="boolean"?i=Rc(i):i==null&&a==="string"?(i="",o=!0):a==="number"&&(i=0,o=!0)}try{t[e]=i}catch{}o&&t.removeAttribute(n||e)}function Zi(t,e,i,r){t.addEventListener(e,i,r)}function Bb(t,e,i,r){t.removeEventListener(e,i,r)}const ad=Symbol("_vei");function Hb(t,e,i,r,n=null){const s=t[ad]||(t[ad]={}),o=s[e];if(r&&o)o.value=r;else{const[a,c]=zb(e);if(r){const l=s[e]=Vb(r,n);Zi(t,a,l,c)}else o&&(Bb(t,a,o,c),s[e]=void 0)}}const ld=/(?:Once|Passive|Capture)$/;function zb(t){let e;if(ld.test(t)){e={};let r;for(;r=t.match(ld);)t=t.slice(0,t.length-r[0].length),e[r[0].toLowerCase()]=!0}return[t[2]===":"?t.slice(3):ci(t.slice(2)),e]}let la=0;const Wb=Promise.resolve(),Kb=()=>la||(Wb.then(()=>la=0),la=Date.now());function Vb(t,e){const i=r=>{if(!r._vts)r._vts=Date.now();else if(r._vts<=i.attached)return;jt(Gb(r,i.value),e,5,[r])};return i.value=t,i.attached=Kb(),i}function Gb(t,e){if(J(e)){const i=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{i.call(t),t._stopped=!0},e.map(r=>n=>!n._stopped&&r&&r(n))}else return e}const cd=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>96&&t.charCodeAt(2)<123,Qb=(t,e,i,r,n,s)=>{const o=n==="svg";e==="class"?Mb(t,r,o):e==="style"?Fb(t,i,r):kn(e)?bo(e)||Hb(t,e,i,r,s):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):Yb(t,e,r,o))?(od(t,e,r),!t.tagName.includes("-")&&(e==="value"||e==="checked"||e==="selected")&&sd(t,e,r,o,s,e!=="value")):t._isVueCE&&(/[A-Z]/.test(e)||!Ae(r))?od(t,Yt(e),r,s,e):(e==="true-value"?t._trueValue=r:e==="false-value"&&(t._falseValue=r),sd(t,e,r,o))};function Yb(t,e,i,r){if(r)return!!(e==="innerHTML"||e==="textContent"||e in t&&cd(e)&&Z(i));if(e==="spellcheck"||e==="draggable"||e==="translate"||e==="autocorrect"||e==="sandbox"&&t.tagName==="IFRAME"||e==="form"||e==="list"&&t.tagName==="INPUT"||e==="type"&&t.tagName==="TEXTAREA")return!1;if(e==="width"||e==="height"){const n=t.tagName;if(n==="IMG"||n==="VIDEO"||n==="CANVAS"||n==="SOURCE")return!1}return cd(e)&&Ae(i)?!1:e in t}const ud=t=>{const e=t.props["onUpdate:modelValue"]||!1;return J(e)?i=>$n(e,i):e};function Xb(t){t.target.composing=!0}function dd(t){const e=t.target;e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}const ca=Symbol("_assign");function fd(t,e,i){return e&&(t=t.trim()),i&&(t=xo(t)),t}const hd={created(t,{modifiers:{lazy:e,trim:i,number:r}},n){t[ca]=ud(n);const s=r||n.props&&n.props.type==="number";Zi(t,e?"change":"input",o=>{o.target.composing||t[ca](fd(t.value,i,s))}),(i||s)&&Zi(t,"change",()=>{t.value=fd(t.value,i,s)}),e||(Zi(t,"compositionstart",Xb),Zi(t,"compositionend",dd),Zi(t,"change",dd))},mounted(t,{value:e}){t.value=e??""},beforeUpdate(t,{value:e,oldValue:i,modifiers:{lazy:r,trim:n,number:s}},o){if(t[ca]=ud(o),t.composing)return;const a=(s||t.type==="number")&&!/^0\d/.test(t.value)?xo(t.value):t.value,c=e??"";a!==c&&(document.activeElement===t&&t.type!=="range"&&(r&&e===i||n&&t.value.trim()===c)||(t.value=c))}},Jb=Fe({patchProp:Qb},Lb);let pd;function Zb(){return pd||(pd=fb(Jb))}const ev=((...t)=>{const e=Zb().createApp(...t),{mount:i}=e;return e.mount=r=>{const n=iv(r);if(!n)return;const s=e._component;!Z(s)&&!s.render&&!s.template&&(s.template=n.innerHTML),n.nodeType===1&&(n.textContent="");const o=i(n,!1,tv(n));return n instanceof Element&&(n.removeAttribute("v-cloak"),n.setAttribute("data-v-app","")),o},e});function tv(t){if(t instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&t instanceof MathMLElement)return"mathml"}function iv(t){return Ae(t)?document.querySelector(t):t}const rv=1;var Yn;(t=>{t.PackageLoader=new A(A.object({kind:A.union(["autoload","module","umd","styles"]).required().default("autoload"),entry:A.string(),styles:A.array(A.string()),main_export:A.string()})),t.Package=new A(A.object({id:A.string().required(),name:A.string().required(),version:A.string().required(),description:A.string(),author:A.string(),license:A.string(),loader:t.PackageLoader.required()})),t.RegistryMaintainer=new A(A.object({name:A.string().required(),email:A.string()})),t.RegistryRepository=new A(A.object({type:A.string().required(),url:A.string().required()})),t.Registry=new A(A.object({manifest_version:A.number().min(rv).required(),name:A.string().required(),base_url:A.string().required(),homepage:A.string(),maintainers:A.array(t.RegistryMaintainer),repository:t.RegistryRepository,packages:A.array(t.Package).required()}))})(Yn||(Yn={}));const ua=Symbol("IPEInjectKey"),nv=(t,e)=>(e?e.provide(ua,t):cu(ua,t),t),da=()=>{const t=Tr(ua);if(!t)throw new Error("InPageEdit instance is not provided");return t},gd=(t,...e)=>{const i=ev(...e);return nv(t,i),i};var sv=Object.create,fa=Object.defineProperty,ov=Object.getOwnPropertyDescriptor,md=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),yd=t=>{throw TypeError(t)},av=(t,e,i)=>e in t?fa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,lv=(t,e)=>fa(t,"name",{value:e,configurable:!0}),cv=t=>[,,,sv(t?.[md("metadata")]??null)],uv=["class","method","getter","setter","accessor","field","value","get","set"],bd=t=>t!==void 0&&typeof t!="function"?yd("Function expected"):t,dv=(t,e,i,r,n)=>({kind:uv[t],name:e,metadata:r,addInitializer:s=>i._?yd("Already initialized"):n.push(bd(s||null))}),fv=(t,e)=>av(e,md("metadata"),t[3]),hv=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},pv=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&ov(n,i));lv(n,i);for(var h=r.length-1;h>=0;h--)c=dv(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,bd(o)&&(n=o);return fv(t,n),p&&fa(n,i,p),u?l^4?s:p:n},vd,ha,wd;const _d=t=>{if(!t)return null;try{return t.split(".").reduce((e,i)=>e==null?e:e[i],globalThis)}catch{return null}},xd=(t,e,i)=>{if(/^https?:\/\//i.test(t))return t;const r=o=>o.endsWith("/")?o:o+"/";if(/^https?:\/\//i.test(e)){const o=r(e);return new URL(t,o).href}const n=(()=>{try{return new URL(i).href}catch{return new URL(i,location.origin).href}})(),s=new URL(r(e),n).href;return new URL(t,s).href};vd=[xe(["storage","preferences","resourceLoader","$"])];let Xn=($t=class extends(wd=Ue){constructor(e){super(e,{},"plugin-store"),this.ctx=e,this.regInfoDB=void 0,this._installedPlugins=new Map,this._onlineRegistryQueries=new Map,e.set("store",this),this.regInfoDB=e.storage.createDatabase($t.REGISTRY_INFO_STORAGE_NAME,$t.REGISTRY_INFO_CACHE_TTL,1,"indexedDB")}async start(){this._installUserPlugins(),this._injectPreferenceUI()}async _installUserPlugins(){const e=await this.ctx.preferences.get("pluginStore.plugins",[]);if(e?.length)for(const i of e)this.install(i.registry,i.id,i.source,"user-preference")}async _createManagementApp(){const e=await this.ctx.withInject(["store"]);return gd(e,Ly(()=>Promise.resolve().then(()=>r0)))}async _injectPreferenceUI(){const e=this.ctx,i=e.$;e.preferences.defineCategory({name:"plugin-store",label:i`Plugin Store`,description:i`Plugin Store`,index:90,autoGenerateForm:!1,customRenderer:async({onUnmount:r})=>{const n=f("div",{id:"ipe-plugin-store-preferences-vue"}),s=await this._createManagementApp();return s.mount(n),r(()=>{s.unmount(),this.ctx.logger.debug("Plugin Store preferences app unmounted")}),f("section",{children:n})}}),e.preferences.registerCustomConfig("plugin-store",A.object({"pluginStore.registries":A.array(A.string()).default([Lt.PLUGIN_REGISTRY_URL]).description(i`Registry URLs`).hidden(),"pluginStore.cdnForNpm":A.string().description(i`CDN to install packages from npm`).default('https://cdn.jsdelivr.net/npm/{{ package }}{{ version ? "@" + version : "" }}').hidden(),"pluginStore.plugins":A.array(A.object({source:A.union(["online_manifest","npm"]).default("online_manifest"),registry:A.string().required(),id:A.string().required()})).description(i`Installed plugins`).default([]).hidden()}),"plugin-store")}async showModal(){const e=this.ctx.modal.show({title:$`Plugin Store`,sizeClass:"small"}),i=f("section",{id:"ipe-plugin-store-vue"});e.setContent(i);const r=await this._createManagementApp();return r.mount(i),e.on(e.Event.Close,()=>{r.unmount()}),e}async install(e,i,r="online_manifest",n="new-added"){const s=await this.getRegistryInfo(e,r);if(!s)return this.ctx.logger.warn(`Registry ${e} not found`),null;const o=`${e}#${i}`;if(this._installedPlugins.has(o))return await this._installedPlugins.get(o)??null;const a=this._installOneByRegistryInfo(e,s,i);this._installedPlugins.set(o,a);const c=await a;return c&&this.ctx.emit("plugin-store/plugin-installed",{ctx:this.ctx,registry:s,id:i,by:n}),c}async uninstall(e,i){const r=this._installedPlugins.get(`${e}#${i}`);if(r===void 0)return!0;this._installedPlugins.delete(`${e}#${i}`);const n=await r;if(n){const s=n.dispose?.()??!0;try{const o=await this.getRegistryCache(e)||await this.getRegistryInfo(e).catch(()=>null);o&&this.ctx.emit("plugin-store/plugin-uninstalled",{ctx:this.ctx,registry:o,id:i})}catch{}return s}return!0}async addToPreferences(e,i){let r=await this.ctx.preferences.get("pluginStore.plugins")||[];return r.some(s=>s.registry===e&&s.id===i)||(r.push({registry:e,id:i}),await this.ctx.preferences.set("pluginStore.plugins",r)),!0}async removeFromPreferences(e,i){let r=await this.ctx.preferences.get("pluginStore.plugins")||[];return r=r.filter(n=>n.registry!==e||n.id!==i),await this.ctx.preferences.set("pluginStore.plugins",r),!0}async installAndSetPreference(e,i){return await this.addToPreferences(e,i),this.install(e,i,"online_manifest","new-added")}async uninstallAndRemovePreference(e,i){return await this.removeFromPreferences(e,i),this.uninstall(e,i)}async _installOneByRegistryInfo(e,i,r){const n=i.base_url,s=i.packages.find(h=>h.id===r);if(!s)return this.ctx.logger.warn(`Package ${r} not found in registry ${e}`),null;const o=s.loader,{kind:a,entry:c="index.js",styles:l=[],main_export:u=null}=o;let d=null;if(a!=="styles"){if(!c)return this.ctx.logger.warn(`Entry url missing for ${r}`,o),null;try{d=xd(c,n,e)}catch(h){return this.ctx.logger.warn(`Failed to resolve entry "${c}" with base "${n}" and registry "${e}"`,h),null}}const y={"data-plugin-registry":e,"data-plugin-id":r};let p=null;switch(a){case"autoload":{p=this.ctx.plugin({inject:["resourceLoader"],name:`plugin-store-${e}-${r}`,apply:h=>{d&&h.resourceLoader.loadScript(d,{...y})}});break}case"module":{if(!d)return this.ctx.logger.warn(`Entry url missing for module kind, package ${r}`),null;const h=await import(d).then(_=>(u?_[u]:_.default)??_);if(!h)return this.ctx.logger.warn(`Main export ${u} not found in module ${d}`),null;p=this.ctx.plugin(h);break}case"umd":{let h=_d(u);if(!h){if(!d)return this.ctx.logger.warn(`Entry url missing for umd kind, package ${r}`),null;await this.ctx.resourceLoader.loadScript(d,{...y}),h=_d(u)}if(!h)return this.ctx.logger.warn(`Main export ${u} not found on globalThis after loading ${d}`),null;p=this.ctx.plugin(h);break}}if(l&&l.length>0){let h=[];try{h=l.map(_=>xd(_,n,e)).filter(Boolean)}catch(_){this.ctx.logger.warn(`Failed to resolve styles for ${r}`,l,_)}p||(p=this.ctx.plugin({name:`plugin-store-${e}-${r}`,apply(){}})),p.ctx.plugin({inject:["resourceLoader"],name:`plugin-store-${e}-${r}-styles`,apply:_=>{h.forEach(k=>_.resourceLoader.loadStyle(k,{...y})),_.on("dispose",()=>{try{h.forEach(k=>_.resourceLoader.removeStyle(k))}catch{}})}})}return p}validateRegistry(e){return Yn.Registry(e)}async getRegistryInfo(e,i="online_manifest",r=!1){try{let s;if(i==="online_manifest")s=await this._fetchOnlineRegistryInfo(e,r),this.logger.debug("Fetched registry info from online manifest",s),this.setRegistryCache(e,s);else throw new Error(`Unsupported registry source: ${i}`);return s}catch(s){this.ctx.logger.warn("Failed to fetch registry info",s)}const n=await this.getRegistryCache(e);if(!n)throw this.ctx.emit("plugin-store/registry-not-found",{ctx:this.ctx,registryUrl:e}),new Error(`Failed to fetch registry info: ${e}`);return n}async _fetchOnlineRegistryInfo(e,i=!1){if(!i&&this._onlineRegistryQueries.has(e))return await this._onlineRegistryQueries.get(e);const n=(async()=>{const s={method:"GET"};i&&(s.cache="no-store");const a=await(await fetch(e,s)).json(),c=this.validateRegistry(a);return this.ctx.emit("plugin-store/registry-fetched",{ctx:this.ctx,registry:c}),c})();return this._onlineRegistryQueries.set(e,n),await n}async getRegistryCache(e){const i=await this.regInfoDB.get(e);if(i)try{return this.validateRegistry(i)}catch(r){this.ctx.logger.warn("Invalid cached registry",r,i),this.regInfoDB.delete(e)}return null}async setRegistryCache(e,i){return this.regInfoDB.set(e,i)}async deleteRegistryCache(e){await this.regInfoDB.delete(e),this.ctx.emit("plugin-store/registry-removed",{ctx:this.ctx,registryUrl:e})}async clearAllRegistryCaches(){await this.regInfoDB.clear(),this.ctx.logger.debug("All registry caches cleared")}async refreshRegistryCache(e){const i=await this.getRegistryInfo(e,"online_manifest",!0);if(!i)throw new Error(`Failed to refresh registry cache: ${e}`);return this.ctx.logger.debug("Registry cache refreshed:",e),i}async refreshAllRegistryCaches(){const e=await this.ctx.preferences.get("pluginStore.registries")||[],i=await Promise.allSettled(e.map(n=>this.refreshRegistryCache(n))),r={};for(const[n,s]of i.entries())s.status==="fulfilled"?r[e[n]]=s.value:r[e[n]]=null;return r}},$t.PluginStoreSchemas=Yn,$t.REGISTRY_INFO_CACHE_TTL=1e3*60*60*24,$t.REGISTRY_INFO_STORAGE_NAME="plugin-store-registry",$t.REGISTRY_ETAG_STORAGE_NAME="psreg-etag",$t);ha=cv(wd),Xn=pv(ha,0,"PluginPluginStore",vd,Xn),hv(ha,1,Xn);const gv=Object.freeze(Object.defineProperty({__proto__:null,PluginPluginStore:Xn},Symbol.toStringTag,{value:"Module"})),ct='@charset "UTF-8";:host{display:block;font-family:var(--schema-font-family, ui-sans-serif, system-ui, -apple-system);color:var(--schema-color-fg, #111827)}*,*:before,*:after{box-sizing:border-box}.wrapper{display:block;background:var(--schema-color-bg, #ffffff)}.form{display:grid;gap:12px}.field{display:grid;gap:6px;padding:8px 10px;border:1px solid var(--schema-color-muted, #e5e7eb);border-radius:var(--schema-radius, 10px);background:var(--schema-surface, #fff)}.label{font-size:12px;color:var(--schema-color-muted-text, #6b7280)}.input,select,textarea{width:100%;padding:8px 10px;border-radius:8px;border:1px solid var(--schema-color-muted, #e5e7eb);background:var(--schema-input-bg, #fff);color:inherit}.checkbox{display:inline-flex;align-items:center;gap:8px}.helper{font-size:12px;color:var(--schema-color-muted-text, #6b7280)}.row{display:grid;gap:8px}.actions{display:flex;gap:8px}.btn{padding:6px 10px;border:1px solid var(--schema-color-muted, #e5e7eb);background:var(--schema-btn-bg, #f8fafc);border-radius:8px;cursor:pointer;color:var(--schema-color-fg)}.btn.primary{background:var(--schema-color-primary, #2563eb);color:#fff;border-color:transparent}.btn:disabled{opacity:.5;cursor:not-allowed}.btn.danger{background:var(--schema-color-danger, #dc2626);color:#fff;border-color:transparent}.group{display:grid;gap:10px}.kv{display:grid;grid-template-columns:1fr 1fr auto;gap:8px;align-items:center}.badge{display:inline-flex;padding:2px 6px;border-radius:999px;font-size:11px;background:var(--schema-badge-bg, #eef2ff);color:var(--schema-badge-fg, #4f46e5)}.hidden{display:none!important}.toolbar{display:flex;gap:6px}.schema-collection-row{position:relative;transition:transform var(--schema-collection-transition-duration, .25s) var(--schema-collection-transition-ease, ease),opacity var(--schema-collection-transition-duration, .25s) var(--schema-collection-transition-ease, ease)}.schema-collection-row.enter{opacity:0}.schema-collection-row.enter.enter-active{opacity:1}.schema-collection-row.leaving{opacity:0}.field.schema-type-array .group,.field.schema-type-array .group .row{position:relative}',kd={arrayAdd:"+",arrayMoveUp:"↑",arrayMoveDown:"↓",arrayRemove:"×",dictAdd:"+",dictRemove:"×",rootLabel:"root"},Se=(t,e)=>{customElements.get(t)||customElements.define(t,e)},mv=(t,e,i)=>{if(!e.length)return;let r=t,n=null,s=null;for(let a=0;a<e.length-1;a++){const c=e[a];let l=r?.[c];l==null?(l=typeof e[a+1]=="number"?[]:{},r[c]=l):typeof l!="object"&&(l=typeof e[a+1]=="number"?[]:{},r[c]=l),n=r,s=c,r=l}const o=e[e.length-1];if(r==null||typeof r!="object"){const a=typeof o=="number"?[]:{};if(n)n[s]=a,r=a;else return}try{r[o]=i}catch{try{const a=Array.isArray(r)?r.slice():{...r};a[o]=i,n&&(n[s]=a)}catch{}}},Br=t=>t.map(String).join("."),yv=t=>t.replace(/[^a-zA-Z0-9_-]/g,"_"),pi=t=>`schema_${yv(Br(t)||"root")}`,Ci=t=>Br(t),ne=(t,...e)=>{const i=new Set(e);i.size&&t.setAttribute("part",Array.from(i).join(" "))},bv=["wrapper","form","field","field-intersect","field-string","field-number","field-boolean","field-date","field-const","field-array","field-object","field-tuple","field-union","field-dict","field-label","field-helper","field-group","field-row","field-actions","field-button","field-button-primary","field-button-danger","field-button-secondary","field-toolbar","field-badge","field-input","field-input-text","field-input-number","field-input-date","field-input-select","field-input-textarea","field-input-checkbox","field-const-value","collection-row","field-checkbox","field-checkbox-text","field-toolbar-select"].join(" ");function pa(t,e){if(e==null)return e;switch(t){case"number":case"natural":case"percent":{if(e==="")return;const i=Number(e);return Number.isNaN(i)?void 0:i}case"boolean":return!!e;case"date":{if(!e)return;const i=new Date(e);return Number.isNaN(+i)?void 0:i}default:return e}}function Sd(t){return typeof t=="function"&&!!t?.type}function Ed(t){if(!t)throw new Error("schema is required");if(Sd(t))return t;try{const e=Schema.from(t);if(Sd(e))return e}catch{}if(t?.type){const e=t.type;if(Schema[e])return Schema[e](t.inner??t.list??t.dict)}throw new Error("无法从传入对象生成 Schemastery 实例,请传入 schema 或 schema.toJSON() 的结果。")}function mt(t){return t?.meta??{}}function vv(t){return t.length>0&&t.every(e=>e?.type==="const")}function Ii(t){if(!t)return;const e=t,i=e.meta||{};if(Object.prototype.hasOwnProperty.call(i,"default"))return i.default;const r=e.type;try{const n=t();if(n!==void 0)return n}catch{}switch(r){case"string":return"";case"number":case"natural":case"percent":return 0;case"boolean":return!1;case"array":return[];case"tuple":return[];case"object":return{};case"dict":return{};case"union":{const n=e.list||[];return n.length?Ii(n[0]):void 0}case"const":return e.value;case"date":return;case"intersect":{const n=e.list||[],s=(a,c)=>{if(Array.isArray(a)&&Array.isArray(c))return c.slice();if(a&&c&&typeof a=="object"&&typeof c=="object"){const l={...a};for(const u of Object.keys(c))l[u]=u in l?s(l[u],c[u]):c[u];return l}return c??a};let o={};for(const a of n)o=s(o,Ii(a));return o}default:return}}class Et extends HTMLElement{constructor(){super(),this._path=[],this._i18n=kd,this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=ct,this.$root.appendChild(e)}makeFieldContainer(e,i){const r=document.createElement("div");if(r.className=`field schema-form-item schema-type-${e}`,r.setAttribute("data-path",Br(this._path)),ne(r,"field",`field-${e}`),this._label){const n=document.createElement("label");n.className="label",n.textContent=this._label,ne(n,"field-label"),r.appendChild(n)}if(i&&i!==this._label){const n=document.createElement("div");n.className="helper",n.textContent=i,ne(n,"field-helper"),r.appendChild(n)}return r}set schema(e){this._schema=Ed(e),this.render()}get schema(){return this._schema}set path(e){this._path=e??[],this.render()}get path(){return this._path}set label(e){this._label=e,this.render()}get label(){return this._label}set i18n(e){e&&(this._i18n={...this._i18n,...e}),this.render()}get i18n(){return this._i18n}setValue(e){this._value=e,this.render()}getValue(){return this._value}emitChange(e){this._value=e,this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{path:this._path,value:e}}))}}class $d extends Et{render(){if(this.$input&&this.$root.contains(this.$input)){const s=!!this.$root.querySelector("label.label");if(!(this._label&&!s)){const o=this._value??"";this.$input.value!==o&&document.activeElement!==this.$input&&(this.$input.value=o);return}}this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("string",e.description),r=document.createElement("input");this.$input=r,r.className="input",ne(r,"field-input","field-input-text"),r.type="text",r.name=Ci(this._path),r.id=pi(this._path),e?.pattern?.source&&(r.pattern=e.pattern.source),e?.max!=null&&(r.maxLength=e.max),r.value=this._value??"",r.oninput=()=>this.emitChange(pa("string",r.value));const n=i.querySelector("label.label");n&&(n.htmlFor=r.id),i.appendChild(r),this.$root.appendChild(i)}}Se("schema-form-string",$d);class Pd extends Et{render(){if(this.$input&&this.$root.contains(this.$input)){const o=!!this.$root.querySelector("label.label");if(!(this._label&&!o)){const a=this._value??"";this.$input.value!==String(a)&&document.activeElement!==this.$input&&(this.$input.value=a);return}}this.$root.innerHTML=`<style>${ct}</style>`;const e=this._schema?.type??"number",i=mt(this._schema),r=this.makeFieldContainer("number",i.description),n=document.createElement("input");this.$input=n,n.className="input",ne(n,"field-input","field-input-number"),n.name=Ci(this._path),n.id=pi(this._path),i?.min!=null&&(n.min=String(i.min)),i?.max!=null&&(n.max=String(i.max)),i?.step!=null&&(n.step=String(i.step)),e==="percent"&&!n.step&&(n.step="0.01"),n.value=this._value??"",n.oninput=()=>this.emitChange(pa(e,n.value));const s=r.querySelector("label.label");s&&(s.htmlFor=n.id),i.role==="slider"?n.type="range":n.type="number",r.appendChild(n),this.$root.appendChild(r)}}Se("schema-form-number",Pd);class Cd extends Et{render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("boolean",e.description),r=document.createElement("label");r.className="checkbox",ne(r,"field-checkbox");const n=document.createElement("input");n.type="checkbox",n.checked=!!this._value,n.name=Ci(this._path),n.id=pi(this._path),ne(n,"field-input","field-input-checkbox");const s=document.createElement("span");s.textContent=e.description??this._label??"",ne(s,"field-checkbox-text"),n.onchange=()=>this.emitChange(n.checked);const o=i.querySelector("label.label");o&&(o.htmlFor=n.id),r.append(n,s),i.appendChild(r),this.$root.appendChild(i)}}Se("schema-form-boolean",Cd);function Jn(t){return String(t).padStart(2,"0")}function Hr(t){return`${t.getFullYear()}-${Jn(t.getMonth()+1)}-${Jn(t.getDate())}`}function ga(t){return`${Jn(t.getHours())}:${Jn(t.getMinutes())}`}function Zn(t){return`${Hr(t)}T${ga(t)}`}class Id extends Et{render(){if(this.$input&&this.$root.contains(this.$input)){const o=!!this.$root.querySelector("label.label");if(!(this._label&&!o)){const a=mt(this._schema).role||"date";if(document.activeElement!==this.$input)if(this._value instanceof Date)a==="date"?this.$input.value=Hr(this._value):a==="time"?this.$input.value=ga(this._value):a==="datetime"&&(this.$input.value=Zn(this._value));else if(typeof this._value=="string"&&a!=="time"){const c=new Date(this._value);isNaN(+c)||(a==="date"?this.$input.value=Hr(c):a==="datetime"&&(this.$input.value=Zn(c)))}else this._value||(this.$input.value="");return}}this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("date",e.description),r=document.createElement("input");this.$input=r,r.className="input",ne(r,"field-input","field-input-date");const n=e.role||"date";if(n==="datetime"?r.type="datetime-local":n==="time"?r.type="time":r.type="date",r.name=Ci(this._path),r.id=pi(this._path),this._value instanceof Date)n==="date"?r.value=Hr(this._value):n==="time"?r.value=ga(this._value):n==="datetime"&&(r.value=Zn(this._value));else if(typeof this._value=="string"&&n!=="time"){const o=new Date(this._value);isNaN(+o)||(n==="date"?r.value=Hr(o):n==="datetime"&&(r.value=Zn(o)))}r.oninput=()=>{e.role;let o;if(!r.value)o=void 0;else{const a=new Date(r.value);o=Number.isNaN(+a)?void 0:a}this.emitChange(o)};const s=i.querySelector("label.label");s&&(s.htmlFor=r.id),i.appendChild(r),this.$root.appendChild(i)}}Se("schema-form-date",Id);class ma extends Et{render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this._schema.value;if(e.role==="raw-html"){if(i instanceof Node){this.$root.append(i);return}else if(typeof i=="function"){this.$root.append(i());return}else if(typeof i=="string"){const o=document.createElement("div");o.innerHTML=String(i),ne(o,"field-const-value"),this.$root.appendChild(o);return}}const r=this.makeFieldContainer("const",e.description),n=document.createElement("section");n.className="const content",n.textContent=String(i),n.id=pi(this._path),ne(n,"field-const-value");const s=r.querySelector("label.label");s&&(s.htmlFor=n.id),r.appendChild(n),this.$root.appendChild(r)}}Se("schema-form-const",ma);class Ad extends Et{render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("intersect",e.description);i.classList.remove("field");const r=document.createElement("div");r.classList.add("group"),ne(r,"field-group");const n=this._schema.list||[],s=n.length>0&&n.every(a=>a?.type==="object"),o=(a,c)=>{if(Array.isArray(a)&&Array.isArray(c))return c.slice();if(a&&c&&typeof a=="object"&&typeof c=="object"){const l={...a};for(const u of Object.keys(c))l[u]=u in l?o(l[u],c[u]):c[u];return l}return c??a};if(s){const a=this._value&&typeof this._value=="object"?this._value:{};n.forEach((c,l)=>{const u=c?.meta?.description??"",d=gi(c,this._path,a,u,this._i18n);d.addEventListener("change",y=>{y.stopPropagation();const p=o(this._value??{},y.detail.value);this.emitChange(p)}),r.appendChild(d)})}else{const a=n[n.length-1],c=gi(a,this._path,this._value,this._label,this._i18n);c.addEventListener("change",l=>{l.stopPropagation(),this.emitChange(l.detail.value)}),r.appendChild(c)}i.appendChild(r),this.$root.appendChild(i)}}Se("schema-form-intersect",Ad);function wv(t){switch(t.type){case"intersect":return"schema-form-intersect";case"string":return"schema-form-string";case"number":case"natural":case"percent":return"schema-form-number";case"boolean":return"schema-form-boolean";case"date":return"schema-form-date";case"const":return"schema-form-const";case"array":return"schema-form-array";case"object":return"schema-form-object";case"tuple":return"schema-form-tuple";case"dict":return"schema-form-dict";case"union":{const e=t.list||[];return e.length===2&&e[0]?.type==="is"&&e[0]?.constructor===Date&&e[1]?.type==="transform"&&(e[1]?.inner?.meta?.role==="datetime"||e[1]?.inner?.meta?.role==="date"||e[1]?.inner?.meta?.role==="time")?"schema-form-date":"schema-form-union"}default:return"schema-form-string"}}function gi(t,e,i,r,n){const s=wv(t),o=document.createElement(s);return o.schema=t,o.path=e,o.label=r,n&&(o.i18n=n),o.setValue?.(i),o.setAttribute("exportparts",bv),o}class Rd extends Et{render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("union",e.description),r=this._schema.list||[];if(vv(r)){const n=document.createElement("select");n.className="input",ne(n,"field-input","field-input-select"),n.name=Ci(this._path),n.id=pi(this._path),r.forEach(o=>{const a=document.createElement("option");a.value=String(o.value),a.textContent=String(o.meta?.description||o.value||o.type),this._value===o.value&&(a.selected=!0),n.appendChild(a)}),n.onchange=()=>this.emitChange(pa("string",n.value));const s=i.querySelector("label.label");s&&(s.htmlFor=n.id),i.appendChild(n)}else{const n=document.createElement("div");n.className="toolbar",ne(n,"field-toolbar");const s=document.createElement("select");s.className="input",ne(s,"field-input","field-input-select","field-toolbar-select"),s.name=Ci(this._path)+".__type",s.id=pi(this._path)+"__type";let o=0;r.forEach((u,d)=>{const y=document.createElement("option");y.value=String(d),y.textContent=String(u.meta?.description||u.value||u.type),s.appendChild(y)}),s.onchange=()=>{o=Number(s.value);const u=r[o],d=Ii(u);this.emitChange(d),l()};const a=i.querySelector("label.label");a&&(a.htmlFor=s.id),n.appendChild(s),i.appendChild(n);const c=document.createElement("div");c.className="group",ne(c,"field-group");const l=()=>{c.innerHTML="";const u=r[o],d=gi(u,this._path,this._value,this._label);d instanceof ma||(d.addEventListener("change",y=>{y.stopPropagation(),this.emitChange(y.detail.value)}),c.appendChild(d))};l(),i.appendChild(c)}this.$root.appendChild(i)}}Se("schema-form-union",Rd);class Td extends Et{render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("tuple",e.description),r=document.createElement("div");r.className="group",ne(r,"field-group");const n=Array.isArray(this._value)?this._value:[];(this._schema.list||[]).forEach((s,o)=>{const a=gi(s,[...this._path,o],n[o],`${this._label??""}[${o}]`);a.addEventListener("change",c=>{c.stopPropagation();const l=Array.isArray(this._value)?this._value.slice():[];l[o]=c.detail.value,this.emitChange(l)}),r.appendChild(a)}),i.appendChild(r),this.$root.appendChild(i)}}Se("schema-form-tuple",Td);class Od extends Et{render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("object",e.description),r=document.createElement("div");r.className="group",ne(r,"field-group");const n=this._schema.dict||{};Object.keys(n).forEach(s=>{if(n[s]?.meta?.hidden)return;const o=(this._value??{})[s],a=gi(n[s],[...this._path,s],o,s);a.addEventListener("change",c=>{c.stopPropagation();const l={...this._value??{}};l[s]=c.detail.value,this.emitChange(l)}),r.appendChild(a)}),i.appendChild(r),this.$root.appendChild(i)}}Se("schema-form-object",Od);const ys=class ys extends Et{constructor(){super(...arguments),this._itemIds=[]}generateItemId(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return"i"+ys._idCounter++}ensureItemIds(e){for(;this._itemIds.length<e;)this._itemIds.push(this.generateItemId());this._itemIds.length>e&&(this._itemIds.length=e)}capturePositions(e){const i={};return e.querySelectorAll(".row").forEach(r=>{const n=r.dataset.uid;n&&(i[n]=r.getBoundingClientRect())}),i}playFLIP(e,i){Array.from(e.querySelectorAll(".row")).forEach(r=>{const n=r.dataset.uid;if(!n)return;const s=i[n];if(!s)return;const o=r.getBoundingClientRect(),a=s.left-o.left,c=s.top-o.top;(a||c)&&(r.style.transition="none",r.style.transform=`translate(${a}px, ${c}px)`,requestAnimationFrame(()=>{r.style.transition="transform .25s ease",r.style.transform=""}))})}render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("array",e.description),r=document.createElement("div");r.className="group",ne(r,"field-group");const n=this._schema.inner,s=()=>Array.isArray(this._value)?this._value:[];this.ensureItemIds(s().length);const o=(l,u)=>{r.innerHTML="",s().forEach((d,y)=>{const p=[...this._path,y],h=document.createElement("div");h.className="row schema-collection-row",ne(h,"field-row","collection-row");const _=this._itemIds[y];h.dataset.uid=_,h.setAttribute("data-path",Br(p));const k=gi(n,p,d,`${this._label??""}[${y}]`);k.addEventListener("change",w=>{w.stopPropagation();const S=s().slice();S[y]=w.detail.value,this._value=S,this.emitChange(S)});const P=document.createElement("div");P.className="actions",ne(P,"field-actions");const b=document.createElement("button");b.type="button",b.className="btn",ne(b,"field-button","field-button-secondary"),b.textContent=this._i18n.arrayMoveUp??"↑",b.onclick=()=>{if(y<=0)return;const w=this.capturePositions(r),S=s().slice();[S[y-1],S[y]]=[S[y],S[y-1]],[this._itemIds[y-1],this._itemIds[y]]=[this._itemIds[y],this._itemIds[y-1]],this._value=S,o(w),this.emitChange(S)};const m=document.createElement("button");m.type="button",m.className="btn",ne(m,"field-button","field-button-secondary"),m.textContent=this._i18n.arrayMoveDown??"↓",m.onclick=()=>{const w=s();if(y>=w.length-1)return;const S=this.capturePositions(r),I=w.slice();[I[y+1],I[y]]=[I[y],I[y+1]],[this._itemIds[y+1],this._itemIds[y]]=[this._itemIds[y],this._itemIds[y+1]],this._value=I,o(S),this.emitChange(I)};const g=document.createElement("button");g.type="button",g.className="btn danger",ne(g,"field-button","field-button-danger"),g.textContent=this._i18n.arrayRemove??"×",g.onclick=()=>{h.classList.add("leaving");const w=250;let S=!1;const I=()=>{if(S)return;S=!0,clearTimeout(F);const N=s().filter((K,qe)=>qe!==y);this._itemIds.splice(y,1);const G=this.capturePositions(r);this._value=N,o(G),this.emitChange(N)};h.addEventListener("transitionend",I,{once:!0});const F=setTimeout(I,w+80)},P.append(b,m,g),h.appendChild(k),h.appendChild(P),r.appendChild(h),u&&u===_&&(h.classList.add("enter"),requestAnimationFrame(()=>{h.classList.add("enter-active")}),requestAnimationFrame(()=>{h.classList.remove("enter")}))}),l&&this.playFLIP(r,l)};o();const a=document.createElement("button");a.type="button",a.className="btn primary",ne(a,"field-button","field-button-primary"),a.textContent=this._i18n.arrayAdd??"+",a.onclick=()=>{const l=this.capturePositions(r),u=s().slice(),d=Ii(n);u.push(d);const y=this.generateItemId();this._itemIds.push(y),this._value=u,o(l,y),this.emitChange(u)};const c=document.createElement("div");c.className="actions",ne(c,"field-actions"),c.appendChild(a),i.appendChild(r),i.appendChild(c),this.$root.appendChild(i)}};ys._idCounter=0;let es=ys;Se("schema-form-array",es);class Ld extends Et{render(){this.$root.innerHTML=`<style>${ct}</style>`;const e=mt(this._schema),i=this.makeFieldContainer("dict",e.description),r=document.createElement("div");r.className="group",ne(r,"field-group");const n=this._schema.inner,s=this._value??{},o=y=>`d_${y}`,a=()=>{const y={};return r.querySelectorAll(".kv").forEach(p=>{const h=p.dataset.uid;h&&(y[h]=p.getBoundingClientRect())}),y},c=y=>{r.querySelectorAll(".kv").forEach(p=>{const h=p.dataset.uid;if(!h)return;const _=y[h];if(!_)return;const k=p.getBoundingClientRect(),P=_.left-k.left,b=_.top-k.top;(P||b)&&(p.style.transition="none",p.style.transform=`translate(${P}px, ${b}px)`,requestAnimationFrame(()=>{p.style.transition="transform .25s ease",p.style.transform=""}))})},l=(y,p)=>{r.innerHTML="",Object.keys(s).forEach(h=>{const _=[...this._path,h],k=document.createElement("div");k.className="kv schema-collection-row",ne(k,"field-row","collection-row"),k.dataset.uid=o(h),k.setAttribute("data-path",Br(_));const P=document.createElement("input");P.className="input",ne(P,"field-input","field-input-text"),P.value=h,P.name=Ci(_)+".__key",P.id=pi(_)+"__key";const b=gi(n,_,s[h],`${this._label??""}[${h}]`),m=document.createElement("button");m.type="button",m.className="btn danger",ne(m,"field-button","field-button-danger"),m.textContent=this._i18n.dictRemove??"×",m.onclick=()=>{const g=a();delete s[h];const w={...this._value??{}};delete w[h],this._value=w,l(g),this.emitChange(w)},P.onchange=()=>{const g=P.value.trim();if(!g||g===h||s[g]!==void 0)return;const w=a();s[g]=s[h],delete s[h];const S={...this._value??{}};S[g]=S[h],delete S[h],this._value=S,l(w),this.emitChange(S)},b.addEventListener("change",g=>{g.stopPropagation();const w={...this._value??{}};w[h]=g.detail.value,this._value=w,this.emitChange(w)}),k.append(P,b,m),r.appendChild(k),p===h&&(k.classList.add("enter"),requestAnimationFrame(()=>k.classList.add("enter-active")),requestAnimationFrame(()=>k.classList.remove("enter")))}),y&&c(y)};l();const u=document.createElement("button");u.type="button",u.className="btn primary",ne(u,"field-button","field-button-primary"),u.textContent=this._i18n.dictAdd??"+",u.onclick=()=>{let y=Object.keys(s).length+1,p=`k${y}`;for(;s[p]!==void 0;)p=`k${++y}`;const h=a();s[p]=Ii(n);const _={...this._value??{},[p]:s[p]};this._value=_,l(h,p),this.emitChange(_)};const d=document.createElement("div");d.className="actions",ne(d,"field-actions"),d.appendChild(u),i.appendChild(r),i.appendChild(d),this.$root.appendChild(i)}}Se("schema-form-dict",Ld);class Nd extends HTMLElement{constructor(){super(),this._i18n={...kd},this._i18nCommitted=!1,this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=ct,this.$root.appendChild(e);const i=document.createElement("div");i.className="wrapper",ne(i,"wrapper");const r=document.createElement("form");r.className="form",ne(r,"form"),i.appendChild(r),this.$root.appendChild(i),this.addEventListener("change",n=>{if(!n?.detail)return;const{path:s,value:o}=n.detail;Array.isArray(s)&&s.length===0?this._state=o:mv(this._state??(this._state={}),s,o),this.dispatchEvent(new CustomEvent("form-change",{detail:{path:s,value:o,state:this._state}}))})}set schema(e){this._schema=Ed(e);try{this._state=this._schema(null,{autofix:!0})}catch{this._state=Ii(this._schema)}this.render()}get schema(){return this._schema}set schemaJSON(e){this.schema=e}get schemaJSON(){return this._schema?.toJSON?.()}setData(e,i={validate:!0,autofix:!0}){if(!this._schema)throw new Error("请先设置 schema");const r=i.validate?this._schema(e??null,{autofix:i.autofix}):e;this._state=r,this.render()}getData(e={validate:!0,autofix:!0}){if(!this._schema)throw new Error("请先设置 schema");const i=this._state;return e.validate?this._schema(i??null,{autofix:e.autofix}):i}reset(){try{this._state=this._schema(null,{autofix:!0})}catch{this._state=Ii(this._schema)}this.render()}refresh(){this.render()}set i18n(e){this._i18nCommitted||(this._i18n={...this._i18n,...e},this._i18nCommitted=!0,this.render())}get i18n(){return this._i18n}render(){if(!this._schema)return;const e=this.$root.querySelector("form");e.innerHTML="";const i=gi(this._schema,[],this._state,this._i18n.rootLabel,this._i18n);e.appendChild(i)}}Se("schema-form",Nd);function _v(){Se("schema-form",Nd),Se("schema-form-string",$d),Se("schema-form-number",Pd),Se("schema-form-boolean",Cd),Se("schema-form-date",Id),Se("schema-form-const",ma),Se("schema-form-union",Rd),Se("schema-form-tuple",Td),Se("schema-form-object",Od),Se("schema-form-array",es),Se("schema-form-dict",Ld),Se("schema-form-intersect",Ad)}const xv=$i({__name:"SchemasteryFormVue",props:yu({schema:{},value:{},validateOnChange:{type:Boolean,default:!1}},{schema:{required:!0},schemaModifiers:{},value:{required:!1,default:{}},valueModifiers:{}}),emits:yu(["change"],["update:schema","update:value"]),setup(t,{expose:e,emit:i}){const r=Su(t,"schema"),n=Su(t,"value"),s=i,o=du("elRef");let a=!1,c=!1;const l=u=>{if(c)return;const d=o.value,y=t.validateOnChange?d.getData({validate:!0}):u.detail.state;a=!0,n.value=y,Ir(()=>{a=!1}),s("change",u.detail)};return gu(()=>{_v()}),Lr(()=>{const u=o.value;r.value&&(u.schema=r.value),n.value!==void 0&&u.setData(n.value,{validate:!1,autofix:!0}),u.addEventListener("form-change",l)}),zo(()=>{o.value?.removeEventListener("form-change",l)}),Gi(r,u=>{a||o.value&&u&&o.value.schema!==u&&(c=!0,o.value.schema=u,Ir(()=>{c=!1}))},{deep:!0,immediate:!0}),Gi(n,u=>{if(a||!o.value||u===void 0)return;const d=o.value.getData({validate:!1});JSON.stringify(d)!==JSON.stringify(u)&&(c=!0,o.value.setData(u,{validate:!1}),Ir(()=>{c=!1}))},{deep:!0,immediate:!0}),e({setData(u,d){const y=o.value;y.setData(u,{validate:!!d?.validate}),d?.emit&&(n.value=y.getData({validate:!!d?.validate}))},getData(u){return o.value.getData(u)},setSchema(u,d=!0){o.value.schema=u,d&&(r.value=u)},refresh(){o.value.refresh()},reset(){o.value.reset()},el:o}),(u,d)=>(de(),ve("schema-form",Ku({ref_key:"elRef",ref:o},u.$attrs),null,16))}});function Ai(t,e=new WeakMap){if(De(t))return Ai(t.value,e);if(t===null||typeof t!="object")return t;if(e.has(t))return e.get(t);if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if(t instanceof Map){const n=new Map;return e.set(t,n),Array.from(t.entries()).forEach(([s,o])=>{n.set(s,Ai(o,e))}),n}if(t instanceof Set){const n=new Set;return e.set(t,n),Array.from(t).forEach(s=>{n.add(Ai(s,e))}),n}if(Array.isArray(t)){const n=[];e.set(t,n);for(const s of t)n.push(Ai(s,e));return n}const i=oe(t),r={};e.set(t,r);for(const n of Object.keys(i))r[n]=Ai(i[n],e);for(const n of Object.getOwnPropertySymbols(i))r[n]=Ai(i[n],e);return r}const ya=()=>{},kv={id:"preferences-ui-app"},Sv={class:"tabbar"},Ev={class:"tabbar-tabs"},$v=["onClick","data-value"],Pv={class:"tabbar-content"},Cv={key:0},Iv={style:{"max-height":"20em",overflow:"auto"}},Av=$i({__name:"PreferencesApp",setup(t,{expose:e}){const i=da(),r=!1,n=Jc([]),s=Qe([]),o=Qe(""),a=Bt(()=>s.value.find(h=>h.name===o.value)||null),c=Bt(()=>{const h=n.value.filter(_=>_.category===o.value).map(_=>_.schema);return h.length===0?null:A.intersect(h)}),l=Bt(()=>a.value&&typeof a.value.autoGenerateForm=="boolean"?a.value.autoGenerateForm:!0),u=Qe({});e({getValue(){return Ai(u)},mergeValue(h){u.value={...u.value,...h}},selectTab(h){o.value=h}}),Lr(async()=>{i.inject(["preferences"],async h=>{const _=await h.preferences.getAll();u.value=_,s.value=h.preferences.getConfigCategories(),n.value=h.preferences.getConfigRegistries(),o.value=s.value[0].name})});const d=(h,_)=>{h.preventDefault(),o.value=_;const k=h.currentTarget;k&&k.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},y=du("customRenderContainerRef"),p=Qe([]);return Wo(()=>{p.value.forEach(h=>h()),p.value=[]}),Gi(a,async h=>{p.value.forEach(k=>k()),p.value=[],await Ir();const _=y.value;if(_&&(_.innerText="",h&&typeof h.customRenderer=="function")){let k=ya;const P=g=>{k=g},b=g=>{p.value.push(g)},m=await h.customRenderer({ctx:i,onMounted:P,onUnmount:b});m&&(_.appendChild(m),k?.(_))}},{immediate:!0,deep:!1}),(h,_)=>(de(),ve("div",kv,[ie("div",Sv,[ie("div",Ev,[(de(!0),ve(We,null,Ko(s.value,k=>(de(),ve("a",{class:xt(["tab",{active:o.value===k.name}]),key:k.name,onClick:P=>d(P,k.name),"data-value":k.name},ye(k.label),11,$v))),128))]),ie("div",Pv,[a.value&&a.value.customRenderer?(de(),ve("div",{class:"custom-render-container",ref_key:"customRenderContainerRef",ref:y,key:o.value})):fi("",!0),l.value&&c.value?(de(),Wn(Oe(xv),{class:"auto-schema-form",key:o.value,"data-category":o.value,schema:c.value,value:u.value,"onUpdate:value":_[0]||(_[0]=k=>u.value={...u.value,...k}),"validate-on-change":!1,i18n:{rootLabel:""}},null,8,["data-category","schema","value"])):fi("",!0)])]),Oe(r)?(de(),ve("details",Cv,[ie("pre",Iv,ye(u.value),1)])):fi("",!0)]))}}),ts=(t,e)=>{const i=t.__vccOpts||t;for(const[r,n]of e)i[r]=n;return i},Rv=ts(Av,[["__scopeId","data-v-775e2739"]]);var Tv=Object.create,ba=Object.defineProperty,Ov=Object.getOwnPropertyDescriptor,Md=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Dd=t=>{throw TypeError(t)},Lv=(t,e,i)=>e in t?ba(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Nv=(t,e)=>ba(t,"name",{value:e,configurable:!0}),Mv=t=>[,,,Tv(t?.[Md("metadata")]??null)],Dv=["class","method","getter","setter","accessor","field","value","get","set"],jd=t=>t!==void 0&&typeof t!="function"?Dd("Function expected"):t,jv=(t,e,i,r,n)=>({kind:Dv[t],name:e,metadata:r,addInitializer:s=>i._?Dd("Already initialized"):n.push(jd(s||null))}),Uv=(t,e)=>Lv(e,Md("metadata"),t[3]),Fv=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},qv=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&Ov(n,i));Nv(n,i);for(var h=r.length-1;h>=0;h--)c=jv(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,jd(o)&&(n=o);return Uv(t,n),p&&ba(n,i,p),u?l^4?s:p:n},Ud,va,Fd;Ud=[xe(["preferences","modal","$","$$"])];class is extends(Fd=Ue){constructor(e){super(e,{},"preferences-ui"),this.ctx=e,this._modal=null,this._form=null,e.set("preferencesUI",this);const i=e.$,r=e.$$;e.preferences.defineCategory({name:"general",label:i`prefs.general.label`,description:i`prefs.general.description`,autoGenerateForm:!0}),e.preferences.defineCategory({name:"editor",label:i`prefs.editor.label`,description:i`prefs.editor.description`,autoGenerateForm:!0}),e.preferences.defineCategory({name:"about",label:r`prefs.about.label`,description:r`prefs.about.description`,index:99,customRenderer:()=>f("section",{className:"theme-ipe-prose",children:[f("h2",{children:"✏️ InPageEdit NEXT"}),f("p",{children:r`prefs.about.intro`}),f("h3",{children:r`prefs.about.portals.header`}),f("ul",{children:[f("li",{children:f("a",{href:this.ctx.Endpoints.HOME_URL,target:"_blank",children:r`prefs.about.portals.officialwebsite`})}),f("li",{children:f("a",{href:`${this.ctx.Endpoints.UPDATE_LOGS_URL}#${this.ctx.version.split("-")[0]}`,target:"_blank",children:r`prefs.about.portals.updatelogs`})})]}),f("h3",{children:r`prefs.about.joinus.header`}),f("ul",{children:[f("li",{children:[f("strong",{children:r`prefs.about.joinus.github`}),":"," ",f("a",{href:this.ctx.Endpoints.GITHUB_URL,target:"_blank",children:`${this.ctx.Endpoints.GITHUB_OWNER}/${this.ctx.Endpoints.GITHUB_REPO}`})]}),f("li",{children:[f("strong",{children:r`prefs.about.joinus.qqgroup`}),": ",this.ctx.Endpoints.QQ_GROUP_ID]})]}),f("hr",{}),f("p",{style:{textAlign:"center"},children:r`prefs.about.copyright`}),f("hr",{})]})}),e.inject(["toolbox"],n=>{n.toolbox.addButton({id:"preferences",icon:f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-settings",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M14.647 4.081a.724 .724 0 0 0 1.08 .448c2.439 -1.485 5.23 1.305 3.745 3.744a.724 .724 0 0 0 .447 1.08c2.775 .673 2.775 4.62 0 5.294a.724 .724 0 0 0 -.448 1.08c1.485 2.439 -1.305 5.23 -3.744 3.745a.724 .724 0 0 0 -1.08 .447c-.673 2.775 -4.62 2.775 -5.294 0a.724 .724 0 0 0 -1.08 -.448c-2.439 1.485 -5.23 -1.305 -3.745 -3.744a.724 .724 0 0 0 -.447 -1.08c-2.775 -.673 -2.775 -4.62 0 -5.294a.724 .724 0 0 0 .448 -1.08c-1.485 -2.439 1.305 -5.23 3.744 -3.745a.722 .722 0 0 0 1.08 -.447c.673 -2.775 4.62 -2.775 5.294 0zm-2.647 4.919a3 3 0 1 0 0 6a3 3 0 0 0 0 -6z"})]}),tooltip:()=>i`Configure Preferences`,group:"group2",index:99,onClick:()=>this.showModal()}),this.addDisposeHandler(s=>{s.toolbox.removeButton("preferences")})})}async start(){Promise.resolve().then(()=>p0).then(({PluginPrefSync:e})=>{this.ctx.plugin(e)}).catch(this.ctx.logger.warn),this.ctx.on("preferences/changed",e=>{this._form?.mergeValue?.(e.input)})}stop(){}showModal(){const{$:e}=this.ctx;if(this._modal&&!this._modal.isDestroyed)return this._modal;const i=this.ctx.modal.show({className:"ipe-preference compact-buttons",sizeClass:"small",outSideClose:!1,center:!0,title:`${e`InPageEdit Preferences`} (${this.ctx.version})`,content:f(bi,{children:f(_i,{})})});i.get$window().classList.add("dialog");const r=f("div",{id:"ipe-preferences-app",style:{minHeight:"calc(85dvh - var(--ipe-modal-spacing) * 2)"}});i.setContent(r),this.ctx.emit("preferences-ui/modal-shown",{ctx:this.ctx,modal:i});const n=this.createPreferencesUIApp(),s=n.mount(r);return this._form=s,this.ctx.emit("preferences-ui/vue-app-mounted",{ctx:this.ctx,app:n,form:s}),i.setButtons([{label:e`Close`,className:"is-ghost",method:()=>{i.close()}},{label:e`Save`,className:"is-primary is-ghost",method:async()=>{const o=s.getValue();try{const a=await this.ctx.preferences.setMany(o);this.logger.info("preferences saved",o,a)}catch(a){this.logger.error("failed to save preferences",a)}i.close(),this.ctx.modal.notify("success",{title:e`Preferences Saved`,content:f("p",{children:e`Some settings may take effect after reloading the page.`})})}}]),this._modal=i,i.on(i.Event.Close,()=>{this.logger.debug("preferences modal closed, vue app unmounting"),n.unmount(),this._modal=null,this._form=null,this.ctx.emit("preferences-ui/modal-closed",{ctx:this.ctx,modal:i})}),i}getCurrentModal(){return this._modal}closeCurrentModal(){return this._modal?.close()}async dispatchFormSave(e){e=e||this._form||void 0;const i=e?.getValue();return i?(this.ctx.preferences.setMany(i),!0):!1}getCurrentFormValue(){return this._form?.getValue()}mergeFormValue(e){return this._form?.mergeValue?.(e),!!this._form?.mergeValue}createPreferencesUIApp(){return gd(this.ctx,Rv)}}va=Mv(Fd),is=qv(va,0,"PluginPreferencesUI",Ud,is),Fv(va,1,is);const Bv=Object.freeze(Object.defineProperty({__proto__:null,get PluginPreferencesUI(){return is}},Symbol.toStringTag,{value:"Module"})),Hv=Symbol("@@apply"),zv=Symbol("@@ctor");function qd(t,e){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError("instance is not an object");const i=(...s)=>{const o=t[e];if(typeof o!="function")throw new TypeError(`Property "${String(e)}" is not a function`);return o.apply(t,s)};i[Hv]=i,i[zv]=t;const r=t?.constructor?.name;return r&&(i[Symbol.toStringTag]=r),new Proxy(i,{get(s,o,a){return o==="prototype"?Reflect.get(i,o,a):Reflect.get(t,o,t)},set(s,o,a){return Reflect.set(t,o,a)},has(s,o){return Reflect.has(t,o)},deleteProperty(s,o){return Reflect.deleteProperty(t,o)},ownKeys(){return Reflect.ownKeys(t)},getOwnPropertyDescriptor(s,o){return Object.getOwnPropertyDescriptor(t,o)},defineProperty(s,o,a){return Object.defineProperty(t,o,a)}})}const rs={mbox:"_mbox_5x43w_1",title:"_title_5x43w_12",content:"_content_5x43w_19",close:"_close_5x43w_27"},wa=t=>{const{type:e="default",title:i,content:r,closeable:n=!0,titleProps:s,contentProps:o,children:a,...c}=t;let l=i;typeof i>"u"&&e!=="default"&&(l=e[0].toUpperCase()+e.slice(1).toLowerCase());const u=async()=>{if(!d)return Promise.resolve();const{promise:y,resolve:p}=wr();return d.animate([{opacity:"1",height:d.clientHeight+"px"},{opacity:"0",height:"0px",margin:"0px"}],{duration:300,easing:"ease"}).addEventListener("finish",()=>{d.remove(),p()}),y},d=f("div",{className:`theme-ipe ipe-mbox mbox-type-${e||"default"} ${rs.mbox}`,...c,children:[l&&f("div",{className:`ipe-mbox-title ${rs.title}`,...s,children:l}),f("div",{className:`ipe-mbox-content ${rs.content}`,...o,children:a||r}),n&&f("a",{onClick:u,className:`ipe-mbox-close ${rs.close}`,children:"×"})]});return d.close=u,d},ns=t=>{const{label:e,id:i,name:r,value:n,placeholder:s,disabled:o,required:a,labelProps:c,inputProps:l,children:u,...d}=t;return f("div",{className:"theme-ipe ipe-input-box",...d,children:[f("label",{htmlFor:i,style:{display:"block"},...c,children:[e,a&&f(bi,{children:[" ",f("span",{className:"required",children:"*"})]})]}),u??f("input",{id:i,name:r,value:n,disabled:o,placeholder:s,required:a,style:{width:"100%"},...l})]})},Wv=t=>{const{id:e,name:i,value:r,label:n,inputProps:s,labelProps:o,children:a,...c}=t;return f("label",{className:"theme-ipe ipe-radio-box",...c,children:[f("input",{type:"radio",id:e,name:i,value:r,...s}),f("span",{className:"ipe-checkbox-box"}),f("span",{...o,children:n||a})]})},Ri=t=>{const{id:e,name:i,label:r,checked:n,inputProps:s,labelProps:o,children:a,...c}=t;return f("label",{className:"theme-ipe ipe-checkbox",...c,children:[f("input",{type:"checkbox",id:e,name:i,checked:n,...s}),f("span",{className:"ipe-checkbox-box"}),f("span",{...o,children:r||a})]})},Kv=(t=0)=>new Promise(e=>setTimeout(e,t)),Bd=t=>f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...t,class:`icon icon-tabler icons-tabler-outline icon-tabler-pencil-bolt ${t.className||""}`,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),f("path",{d:"M13.5 6.5l4 4"}),f("path",{d:"M19 16l-2 3h4l-2 3"})]});var Vv=Object.create,_a=Object.defineProperty,Gv=Object.getOwnPropertyDescriptor,Hd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),zd=t=>{throw TypeError(t)},Qv=(t,e,i)=>e in t?_a(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Yv=(t,e)=>_a(t,"name",{value:e,configurable:!0}),Xv=t=>[,,,Vv(t?.[Hd("metadata")]??null)],Jv=["class","method","getter","setter","accessor","field","value","get","set"],Wd=t=>t!==void 0&&typeof t!="function"?zd("Function expected"):t,Zv=(t,e,i,r,n)=>({kind:Jv[t],name:e,metadata:r,addInitializer:s=>i._?zd("Already initialized"):n.push(Wd(s||null))}),ew=(t,e)=>Qv(e,Hd("metadata"),t[3]),tw=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},iw=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&Gv(n,i));Yv(n,i);for(var h=r.length-1;h>=0;h--)c=Zv(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,Wd(o)&&(n=o);return ew(t,n),p&&_a(n,i,p),u?l^4?s:p:n},Kd,xa,Vd;Kd=[xe(["api","wikiPage","wikiTitle","currentPage","wiki","modal","preferences","$"]),Tt(A.object({"quickEdit.editSummary":A.string().description("Default edit summary for quick edits").default("[IPE-NEXT] Quick edit"),"quickEdit.editMinor":A.boolean().description('Default to checking "minor edit" option').default(!1),"quickEdit.outSideClose":A.boolean().description("Close editor modal by clicking outside").default(!0),"quickEdit.watchList":A.union([A.const(_t.preferences).description("Follow MW preferences"),A.const(_t.nochange).description("Keep the current watchlist status"),A.const(_t.watch).description("Add the page to watchlist"),A.const(_t.unwatch).description("Remove the page from watchlist")]).description("Watchlist options").default(_t.preferences),"quickEdit.keyshortcut.save":A.string().default("ctrl-s").description("save button key shortcut (blank to disable)"),"quickEdit.editFont":A.union([A.const("preferences").description("Follow MW preferences"),A.const("monospace").description("Monospace"),A.const("sans-serif").description("Sans-serif"),A.const("serif").description("Serif"),A.string().description("Custom font (same as CSS `font-family` property)").default("")]).description("Font to use in quick edit's textarea").default("preferences")}).description("Quick edit options").extra("category","editor"))];let ss=(Oi=class extends(Vd=Ue){constructor(e){super(e,{},"quick-edit"),this.ctx=e,this.DEFAULT_OPTIONS={title:"",pageId:0,revision:0,section:void 0,editMinor:!1,editSummary:"",createOnly:!1,reloadAfterSave:!0},this.ctx.root.set("quickEdit",qd(this,"showModal"))}start(){this.ctx.inject(["toolbox"],e=>{this.injectToolbox(e),e.on("dispose",()=>{this.removeToolbox(e)})})}async showModal(e){const{$:i}=this.ctx;if(typeof e>"u"?e={}:typeof e=="string"&&(e={title:e}),e?.page&&(e.title=e.page,delete e.page),!e.title&&!e.pageId&&!e.revision){this.logger.warn("None of the title, pageId or revision provided. Using defaults.");const g=new URLSearchParams(window.location.search),w=this.ctx.currentPage.wikiTitle;e={...e,title:w?.getPrefixedDBKey(),revision:g.has("oldid")?Number(g.get("oldid")):void 0,pageId:g.has("curid")?Number(g.get("curid")):void 0}}if(!e.revision&&!e.pageId&&e.title){const g=this.ctx.wikiTitle.resolveSpecialPageTarget(e.title);g&&g.title.getNamespaceId()>=0&&(e.title=g.title.getPrefixedDBKey(),e.section??(e.section=g.section))}const r=await this.ctx.preferences.get("quickEdit.outSideClose"),n=await this.ctx.preferences.get("quickEdit.watchList"),s=typeof e.editSummary=="string"?e.editSummary:await this.ctx.preferences.get("quickEdit.editSummary"),o=typeof e.editMinor=="boolean"?e.editMinor:await this.ctx.preferences.get("quickEdit.editMinor"),a=await this.getEditFontOptions(),c={...this.DEFAULT_OPTIONS,editSummary:s,editMinor:o,...e};c.editSummary||(c.editSummary=await this.ctx.preferences.get("quickEdit.editSummary")||""),this.ctx.emit("quick-edit/init-options",{ctx:this.ctx,options:c});const l=this.ctx.modal.createObject({className:"ipe-quickEdit",sizeClass:"large",center:!1,outSideClose:r}).init();l.setTitle(f(bi,{children:["Loading: ",f("u",{children:c.title})]})),l.setContent(f("section",{className:"ipe-quickEdit-loading",style:{height:"70vh",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:f(_i,{})})),l.addButton({side:"right",type:"button",className:"is-danger is-ghost",label:i`Cancel`,method(){l.close()}}),l.show(),this.ctx.emit("quick-edit/show-modal",{ctx:this.ctx,modal:l,options:c});let u;try{if(u=await this.getWikiPageFromPayload(c),u.pageInfo.special)throw new Error(i`Special page is not editable.`)}catch(g){l.off(l.Event.Close),l.close(),this.ctx.modal.notify("error",{content:g instanceof Error?g.message:String(g)});return}const d=c.section==="new"?"":u.revisions[0]?.content||"",y=u.revisions[0]?.revid,p=y&&y!==u.lastrevid,h=c.section==="new",_=u.pageid===0;l.setTitle(f(bi,{children:[h?i`New Section`:i`Quick ${_?"Create":"Edit"}`,": ",f("u",{children:u.pageInfo.title}),p?` (${i`Revision`} ${y})`:""]}));const k=[];_&&k.push(f(wa,{title:i`Attention`,type:"important",children:f("p",{children:i`This page does not exist.`})})),p&&k.push(f(wa,{title:i`Attention`,type:"warning",children:f("p",{innerHTML:i`You are editing a <em>historical version</em>; the content is not the latest!`})})),this.ctx.emit("quick-edit/edit-notice",{ctx:this.ctx,options:c,modal:l,wikiPage:u,editNotices:k});const P=f("form",{className:"ipe-quickEdit__form",children:[f("div",{className:"ipe-quickEdit__notices",children:k}),f("div",{className:"ipe-quickEdit__content",style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[c.section==="new"&&f(bi,{children:f(ns,{label:i`Section title`,id:"summary",name:"summary",value:"",inputProps:{placeholder:i`Topic for new section, this will be the h2 heading`}})}),f("textarea",{className:`ipe-quickEdit__textarea ${a.className}`,style:{fontFamily:a.fontFamily},name:"text",id:"wpTextbox1",children:d})]}),f("div",{class:"ipe-quickEdit__options",style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[!h&&f(ns,{label:i`Summary`,id:"summary",name:"summary",value:c.editSummary}),f("div",{className:"ipe-input-box",children:[f("label",{htmlFor:"watchlist",style:{display:"block"},children:i`Watchlist`}),f("div",{style:{display:"flex",gap:"1rem",whiteSpace:"nowrap",overflowX:"auto"},children:[_t.preferences,_t.nochange,_t.watch,_t.unwatch].map(g=>f(Wv,{name:"watchlist",value:g,inputProps:{checked:n===g,onChange:w=>{w.target&&w.target.closest("label")?.scrollIntoView({behavior:"smooth",inline:"center"})}},children:i`watchlist.${g}`},g))})]}),f("div",{style:{display:"flex",gap:"1rem"},children:[f(Ri,{name:"minor",id:"minor",checked:c.editMinor,children:i`Minor edit`}),f(Ri,{name:"reloadAfterSave",id:"reloadAfterSave",checked:c.reloadAfterSave,children:i`Reload after save`})]})]}),!1]});l.setContent(P);let b=!1;l.addButton({side:"left",className:"is-primary submit-btn",label:i`Submit`,keyPress:await this.ctx.preferences.get("quickEdit.keyshortcut.save")||void 0,method:async()=>{const g=new FormData(P);l.setLoadingState(!0);try{await this.handleSubmit({wikiPage:u,text:g.get("text"),summary:g.get("summary"),minor:g.get("minor")==="on",section:c.section,watchlist:n,createonly:u.pageid===0&&!b,recreate:u.pageid===0&&b}),l.setOptions({beforeClose:ya}),l.close(),this.ctx.modal.notify("success",{title:i`Submission Successful`,content:i`Your changes have been saved.`}),g.get("reloadAfterSave")&&(await Kv(500),location.reload())}catch(w){if(l.setLoadingState(!1),Rt.is(w)&&(w.code==="pagedeleted"||w.code==="editconflict"||w.code==="articleexists")){b=!0,this.ctx.modal.notify("warning",{title:i`Submission Error`,content:f("div",{children:[f("p",{children:f("strong",{children:w.message})}),f("p",{children:i`You can try to submit again to dismiss the warnings.`})]}),closeAfter:15*1e3});return}this.ctx.modal.notify("error",{title:i`Submission Error`,content:w instanceof Error?w.message:String(w)})}}},0),l.setOptions({beforeClose:()=>{const g=u.revisions[0]?.content||"";return(P.querySelector("textarea")?.value||"")===g?!0:(this.ctx.modal.confirm({className:"is-primary",title:i`Unsaved Changes`,content:i`All edit contents will be lost after closing the modal. Are you sure you want to close?`,center:!0,okBtn:{label:i`Give Up`,className:"is-danger is-ghost"},cancelBtn:{label:i`Continue Editing`,className:"is-primary is-ghost"}},S=>(S&&(l.setOptions({beforeClose:ya}),l.close()),!0)),!1)}}),this.ctx.emit("quick-edit/wiki-page",{ctx:this.ctx,options:c,modal:l,wikiPage:u});const m=g=>P.querySelector("textarea")?.value===d?!0:(g.preventDefault(),i`You have unsaved changes. Are you sure you want to leave?`);window.addEventListener("beforeunload",m),l.on(l.Event.Close,()=>{window.removeEventListener("beforeunload",m)})}async handleSubmit(e){const{wikiPage:i,...r}=e;return this.ctx.emit("quick-edit/submit",{ctx:this.ctx,wikiPage:i,...r}),i.edit({...r})}async getEditFontOptions(){const e=await this.ctx.preferences.get("quickEdit.editFont");return Oi.BUILT_IN_FONT_OPTIONS.includes(e)?{className:`mw-editfont-${e==="preferences"?this.ctx.wiki.userOptions?.editfont||"monospace":e}`,fontFamily:""}:{className:"mw-editfont-custom",fontFamily:e}}async getWikiPageFromPayload(e){if(e.revision)return this.ctx.wikiPage.newFromRevision(e.revision,e.section);if(e.pageId)return this.ctx.wikiPage.newFromPageId(e.pageId,e.section);if(e.title)return this.ctx.wikiPage.newFromTitle(e.title,!1,e.section);throw new Error("Invalid payload")}async injectToolbox(e){const{$:i}=this.ctx,r=this.ctx.currentPage.wikiTitle,n=r&&r.getNamespaceId()>=0;e.toolbox.addButton({id:"quick-edit",group:"group1",index:0,icon:f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-edit",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1"}),f("path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z"}),f("path",{d:"M16 5l3 3"})]}),buttonProps:{disabled:!n},tooltip:()=>n?i`Quick Edit`:i`Not editable`,onClick:()=>{const s=new URLSearchParams(window.location.search).get("oldid");this.showModal({title:r?.getPrefixedText(),revision:s?Number(s):void 0})}})}removeToolbox(e){e.toolbox.removeButton("quick-edit")}createQuickEditButton(e,i){const{$:r}=this.ctx,n=i?.icon??f(Bd,{className:"ipe-icon"}),s=i?.label??r`Quick Edit`;return f("a",{href:"#ipe://quick-edit/",dataset:e,className:`ipe-quick-edit ${e.createOnly?"ipe-quick-edit--create-only":""}`,style:{userSelect:"none",marginLeft:"0.2em"},onClick:o=>{o.preventDefault(),this.showModal(e)},children:[n,s]})}},Oi.BUILT_IN_FONT_OPTIONS=["preferences","monospace","sans-serif","serif"],Oi);xa=Xv(Vd),ss=iw(xa,0,"PluginQuickEdit",Kd,ss),tw(xa,1,ss);const rw=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickEdit:ss},Symbol.toStringTag,{value:"Module"})),zr={twinSwapInput:"_twinSwapInput_1gdgl_9",inputWrapper:"_inputWrapper_1gdgl_23",inputLeft:"_inputLeft_1gdgl_27",inputRight:"_inputRight_1gdgl_30",swapButton:"_swapButton_1gdgl_46"},Gd=t=>{const{inputs:e,enableSwap:i=!0,...r}=t,n=e?.length===2?e:[e?.[0]??{},e?.[1]??{}],s=[null,null];let o=0,a=null,c=null;const l=()=>s.some(h=>h&&h.disabled),u=()=>{if(!s[0]||!s[1]||l())return;const h=s[0],_=s[1],k=h.value,P=_.value;h.value=P,_.value=k,h.dispatchEvent(new Event("change")),_.dispatchEvent(new Event("change")),o++,c&&(c.style.transform=`rotateY(${o*-180}deg)`,c.style.transition="transform 200ms ease")},d=h=>{if(!a)return;const _=h??!a.disabled;a.disabled=!_,_&&s.forEach(k=>{k&&(k.disabled=!1)})},y=f("button",{type:"button","aria-label":"Swap values",onClick:u,disabled:l()||!i,ref:h=>a=h,children:f("svg",{ref:h=>c=h,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon-tabler icons-tabler-outline icon-tabler-transfer",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M20 10h-16l5.5 -6"}),f("path",{d:"M4 14h16l-5.5 6"})]})}),p=f("div",{className:`twin-swap-input ${zr.twinSwapInput}`,...r,children:[n.map((h,_)=>{const{label:k,id:P,name:b,value:m,disabled:g,required:w,inputProps:S}=h,I=_===0,F=P||b;return f("div",{className:`${zr.inputWrapper} ${I?zr.inputLeft:zr.inputRight}`,children:[k&&f("label",{htmlFor:F,children:k}),f("input",{ref:N=>s[_]=N,type:"text",id:F,name:b,value:m,disabled:g,required:w,...S})]})}),f("div",{className:zr.swapButton,children:y})]});return p.swap=u,p.toggleEnableSwap=d,p};var nw=Object.create,ka=Object.defineProperty,sw=Object.getOwnPropertyDescriptor,Qd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Yd=t=>{throw TypeError(t)},ow=(t,e,i)=>e in t?ka(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,aw=(t,e)=>ka(t,"name",{value:e,configurable:!0}),lw=t=>[,,,nw(t?.[Qd("metadata")]??null)],cw=["class","method","getter","setter","accessor","field","value","get","set"],Xd=t=>t!==void 0&&typeof t!="function"?Yd("Function expected"):t,uw=(t,e,i,r,n)=>({kind:cw[t],name:e,metadata:r,addInitializer:s=>i._?Yd("Already initialized"):n.push(Xd(s||null))}),dw=(t,e)=>ow(e,Qd("metadata"),t[3]),fw=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},hw=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&sw(n,i));aw(n,i);for(var h=r.length-1;h>=0;h--)c=uw(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,Xd(o)&&(n=o);return dw(t,n),p&&ka(n,i,p),u?l^4?s:p:n},Jd,Sa,Zd;Jd=[Tt(A.object({"quickMove.reason":A.string().default("[IPE-NEXT] Quick move")}).description("Quick move options").extra("category","editor")),xe(["modal","wiki","$"])];class os extends(Zd=Ue){constructor(e){super(e,{},"quick-move"),this.ctx=e,e.set("quickMove",this)}start(){this.ctx.inject(["toolbox"],e=>{this.injectToolbox(e)})}injectToolbox(e){const i=e.$,r=window.mw?.config.get("wgPageName")||"",n=window.mw?.config.get("wgIsProbablyEditable");e.toolbox.addButton({id:"quick-move",icon:f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-forms",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3"}),f("path",{d:"M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3"}),f("path",{d:"M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7"}),f("path",{d:"M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1"}),f("path",{d:"M17 12h.01"}),f("path",{d:"M13 12h.01"})]}),tooltip:()=>i`Quick Move`,group:"group1",index:1,onClick:()=>{this.showModal(n?{lockFromField:!0,from:r}:{})}})}async showModal(e){const{$:i}=this.ctx,r=await this.ctx.preferences.get("quickMove.reason"),n=this.ctx.modal.createObject({title:i`Quick Move`,content:f(_i,{}),className:"quick-move compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let s=null;return n.setContent(f("form",{ref:o=>s=o,style:{display:"flex",flexDirection:"column",gap:"1rem"},onSubmit:o=>{if(o.preventDefault(),s?.checkValidity(),!s?.reportValidity())return;const a=new FormData(s),c={from:a.get("from")?.toString().trim(),to:a.get("to")?.toString().trim(),reason:a.get("reason")||"",movetalk:a.get("movetalk")==="on",movesubpages:a.get("movesubpages")==="on",noredirect:a.get("noredirect")==="on"};if(!c.from||!c.to){this.ctx.modal.notify("error",{title:i`Failed to move`,content:"From and to are required."});return}this.ctx.emit("quick-move/submit",{ctx:this.ctx,modal:n,payload:c}),n.setLoadingState(!0),this.movePage(c).then(()=>{location.reload()}).catch(l=>{n.setLoadingState(!1),this.ctx.modal.notify("error",{title:i`Failed to move`,content:l instanceof Error?l.message:String(l)})})},children:[f(Gd,{inputs:[{label:i`Move from`,name:"from",value:e?.from,required:!0},{label:i`Move to`,name:"to",value:e?.to,required:!0}]}),f("div",{children:f(Ri,{name:"movetalk",id:"movetalk",checked:e?.movetalk,children:i`Move talk page`})}),f("div",{children:f(Ri,{name:"movesubpages",id:"movesubpages",checked:e?.movesubpages,children:i`Move subpages (up to 100)`})}),this.ctx.wiki.hasRight("suppressredirect")&&f("div",{children:f(Ri,{name:"noredirect",id:"noredirect",checked:e?.noredirect,children:i`Move without leaving a redirect`})}),f(ns,{label:i`Reason`,id:"reason",name:"reason",value:e?.reason??r??""})]})),n.setButtons([{label:i`Move`,className:"is-primary is-ghost",method:()=>{s?.dispatchEvent(new Event("submit"))}}]),n.show()}async movePage(e){const{from:i,to:r,reason:n="",...s}=e;if(!i||!r)throw new Error("From and to titles are required.");if(i===r)throw new Error("From and to titles cannot be the same.");return(await this.ctx.wikiPage.newFromTitle(i)).moveTo(r,n,s)}}Sa=lw(Zd),os=hw(Sa,0,"PluginQuickMove",Jd,os),fw(Sa,1,os);const pw=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickMove(){return os}},Symbol.toStringTag,{value:"Module"}));var gw=Object.create,Ea=Object.defineProperty,yw=Object.getOwnPropertyDescriptor,ef=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),tf=t=>{throw TypeError(t)},bw=(t,e,i)=>e in t?Ea(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,vw=(t,e)=>Ea(t,"name",{value:e,configurable:!0}),ww=t=>[,,,gw(t?.[ef("metadata")]??null)],_w=["class","method","getter","setter","accessor","field","value","get","set"],rf=t=>t!==void 0&&typeof t!="function"?tf("Function expected"):t,xw=(t,e,i,r,n)=>({kind:_w[t],name:e,metadata:r,addInitializer:s=>i._?tf("Already initialized"):n.push(rf(s||null))}),kw=(t,e)=>bw(e,ef("metadata"),t[3]),Sw=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Ew=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&yw(n,i));vw(n,i);for(var h=r.length-1;h>=0;h--)c=xw(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,rf(o)&&(n=o);return kw(t,n),p&&Ea(n,i,p),u?l^4?s:p:n},nf,$a,sf;nf=[xe(["api","wikiPage","modal","preferences","$"]),Tt(A.object({"quickPreview.keyshortcut":A.string().default("ctrl-i").description("Key shortcut to open quick preview in quick edit modal")}).extra("category","editor").description("Quick preview options"))];class as extends(sf=Ue){constructor(e){super(e,{},"quickPreview"),this.ctx=e,this._contentTypeCache=new Map,this._objectUrls=new WeakMap,this.ctx.set("quickPreview",qd(this,"previewWikitext"))}start(){this.ctx.on("quick-edit/wiki-page",this.injectQuickEdit.bind(this))}stop(){}previewWikitext(e,i,r,n,s){const{$:o}=this.ctx;return r||(r=this.ctx.wikiPage.newBlankPage({title:"API"})),(!n||n.isDestroyed)&&(n=this.ctx.modal.createObject({className:"in-page-edit ipe-quickPreview",sizeClass:"large",center:!1,...s}).init()),n.show(),n.setTitle(o`Preview - Loading...`),n.setContent(f(_i,{})),n.bringToFront(),this.ctx.emit("quick-preview/show-modal",{ctx:this.ctx,text:e,modal:n,wikiPage:r}),r.preview(e,i).then(a=>{const{data:{parse:c}}=a;n.setTitle(o(c.title)`Preview - {{ $1 }}`);let l=null;n.setContent(f("section",{children:f("div",{ref:u=>l=u,className:"mw-parser-output",innerHTML:c.text})})),window.mw?.hook&&typeof jQuery=="function"&&window.mw.hook("wikipage.content").fire(jQuery(l)),this.ctx.emit("quick-preview/loaded",{ctx:this.ctx,modal:n,wikiPage:r,text:e,parseData:c})}).catch(a=>{n.setTitle(o`Preview - Failed`),n.setContent(f(bi,{children:[f("p",{children:o`Failed to preview`}),f("p",{children:a instanceof Error?a.message:String(a)})]}))}),n}async injectQuickEdit({options:e,modal:i,wikiPage:r}){const{$:n}=this.ctx;let s;i.addButton({label:n`Preview`,side:"left",className:"btn btn-secondary",keyPress:await this.ctx.preferences.get("quickPreview.keyshortcut.quickEdit")||void 0,method:()=>{let o=i.get$content().querySelector('textarea[name="text"]')?.value||"";if(e.section==="new"){const a=i.get$content().querySelector('input[name="summary"]')?.value;a&&(o=`==${a}==
25
+ ${o}`)}s=this.previewWikitext(o,void 0,r,s,{backdrop:!1,draggable:!0})}},1),i.on(i.Event.Close,()=>{s?.destroy(),s=void 0})}fetchContentType(e){const i=this._contentTypeCache.get(e);if(i)return i;const r=fetch(e,{method:"HEAD"}).then(n=>n.headers.get("content-type")||"").catch(()=>(this._contentTypeCache.delete(e),""));return this._contentTypeCache.set(e,r),r}async getPreviewType(e){if(!e)return"unknown";let i,r;if(e instanceof File)i=e.type,r=e.name.split(".").pop()?.toLowerCase()||"";else{const n=new URL(e,location.origin);n.protocol==="data:"||n.protocol==="blob:"||n.protocol.startsWith("http")?i=await this.fetchContentType(n.href):i="",r=n.pathname.split(".").pop()?.toLowerCase()||""}return i.startsWith("image/")&&!i.includes("pdf")?"image":i.startsWith("video/")?"video":i.startsWith("audio/")?"audio":i.startsWith("text/html")?"html":r==="md"?"markdown":i.startsWith("text/")?"text":["jpg","jpeg","png","gif","bmp","tiff","ico","webp"].includes(r)?"image":["mp4","webm","ogg","flv","avi","mov","wmv","mkv"].includes(r)?"video":["mp3","wav","ogg","flac","aac","m4a","wma"].includes(r)?"audio":["html","htm"].includes(r)?"html":["json","yml","yaml","toml","py"].includes(r)?"text":["pdf"].includes(r)?"pdf":"unknown"}async previewFile(e,i){const r=await this.getPreviewElement(e,i);return r?this.ctx.modal.dialog({className:"in-page-edit ipe-quickPreview",sizeClass:"mediumToLarge",center:!0,title:i??(e instanceof File?e.name:e),content:f("section",{className:"ipe-quickPreview__content",children:r})}):void 0}getObjectUrl(e){if(!this._objectUrls.has(e)){const i=URL.createObjectURL(e);this._objectUrls.set(e,i)}return this._objectUrls.get(e)}async getPreviewElement(e,i){const r=await this.getPreviewType(e),n=e instanceof File?this.getObjectUrl(e):e;switch(r){case"image":return f("img",{src:n,alt:i??(e instanceof File?e.name:e)});case"video":return f("video",{src:n,controls:!0,"aria-label":i});case"audio":return f("audio",{src:n,controls:!0,"aria-label":i});case"pdf":return f("embed",{type:"application/pdf",src:n,"aria-label":i})}return null}previewWikiPage(e){throw new Error("Not implemented")}}$a=ww(sf),as=Ew($a,0,"PluginQuickPreview",nf,as),Sw($a,1,as);const $w=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickPreview(){return as}},Symbol.toStringTag,{value:"Module"})),Pw=t=>{let{user:e,target:i,ctx:r}=t;const n=r.getUrl.bind(r);return f("span",{className:"mw-userlinks",children:[f("a",{href:n(`User:${e}`),className:"mw-userlink",target:i,children:e})," ",f("span",{className:"mw-usertoollinks",children:["(",f("a",{href:n(`User_talk:${e}`),className:"mw-usertoollinks-talk",target:i,children:"talk"})," | ",f("a",{href:n(`Special:Contributions/${e}`),className:"mw-usertoollinks-contribs",target:i,children:"contribs"})," | ",f("a",{href:n(`Special:Block/${e}`),className:"mw-usertoollinks-block",target:i,children:"block"}),")"]})]})};var ls=(t=>(t.update="ipe:diff-table/update",t.edit="ipe:diff-table/edit",t))(ls||{});const Cw=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"medium"}).format,of=t=>{let e=["diff-title"];if(t.type==="from"?e.push("diff-otitle"):t.type==="to"&&e.push("diff-ntitle"),!t.pageid||!t.userid)return f("td",{colSpan:2,className:e,children:f("div",{className:"mw-diff-title--title",children:t.type==="from"?"Original content":t.type==="to"?"Your content":""})});const i=r=>{r.preventDefault(),r.target.dispatchEvent(new CustomEvent("ipe:diff-table/edit",{detail:{revid:t.revid},bubbles:!0}))};return f("td",{colSpan:2,className:e,children:[f("div",{className:"mw-diff-title--title",children:[t.pagetitle||t.timestamp,t.revid?` (rev#${t.revid})`:""]}),f("div",{className:"mw-diff-title--actions",children:f("a",{href:t.ctx.getUrl("",{action:"edit",oldid:t.revid}),onClick:i,children:[f(Bd,{style:"width: 1em; height: 1em"}),"Quick edit"]})}),f("div",{className:"mw-diff-title--user",children:t.username&&f(Pw,{ctx:t.ctx,user:t.username,target:"_blank"})}),f("div",{className:"mw-diff-title--timestamp",children:t.timestamp&&Cw(new Date(t.timestamp))}),f("div",{className:"mw-diff-title--comment",children:t.parsedcomment&&f(bi,{children:["(",f("i",{innerHTML:t.parsedcomment}),")"]})})]})},Iw=t=>{const e=t.data;if(!e.prev&&!e.next)return null;const i=(r,n,s)=>{r.preventDefault(),r.target.dispatchEvent(new CustomEvent("ipe:diff-table/update",{detail:{fromrev:n,torev:s},bubbles:!0}))};return f("tr",{className:"mw-diff-title--navigation",children:[f("td",{colSpan:2,children:e.prev?f("a",{href:t.ctx.getUrl("",{diff:e.prev,oldid:e.fromrevid}),onClick:r=>i(r,e.prev,e.fromrevid),children:"← Previous"}):f("i",{children:"Oldest version"})}),f("td",{colSpan:2,children:e.next?f("a",{href:t.ctx.getUrl("",{diff:e.next,oldid:e.torevid}),onClick:r=>i(r,e.torevid,e.next),children:"Next →"}):f("i",{children:"Newest version"})})]})},Aw=t=>{const{data:e,...i}=t,r=f("table",{className:"theme-ipe diff diff-type-table","data-mw":"interface",...i,children:[f("colgroup",{children:[f("col",{className:"diff-marker"}),f("col",{className:"diff-content"}),f("col",{className:"diff-marker"}),f("col",{className:"diff-content"})]}),f("tbody",{children:[f("tr",{children:[f(of,{ctx:t.ctx,type:"from",pageid:e.fromid,pagetitle:e.fromtitle,revid:e.fromrevid,size:e.fromsize,timestamp:e.fromtimestamp,username:e.fromuser,userid:e.fromuserid,comment:e.fromcomment,parsedcomment:e.fromparsedcomment}),f(of,{ctx:t.ctx,type:"to",pageid:e.toid,pagetitle:e.totitle,revid:e.torevid,size:e.tosize,timestamp:e.totimestamp,username:e.touser,userid:e.touserid,comment:e.tocomment,parsedcomment:e.toparsedcomment})]}),f(Iw,{data:e,ctx:t.ctx}),f("div",{id:"diffbody"}),f("tr",{className:"diff-size",style:{textAlign:"center"},children:[f("td",{colSpan:2,className:"diff-size-old",children:e.fromsize!==void 0&&`${e.fromsize} bytes`}),f("td",{colSpan:2,className:"diff-size-new",children:e.tosize!==void 0&&`${e.tosize} bytes`})]})]})]});return r.querySelector("#diffbody").outerHTML=e.body||f("tr",{children:f("td",{colSpan:4,children:f("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"5rem"},children:f("i",{children:"No changes"})})})}).outerHTML,r},Rw=t=>f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...t,class:`icon icon-tabler icons-tabler-outline icon-tabler-file-diff ${t.className||""}`,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),f("path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z"}),f("path",{d:"M12 10l0 4"}),f("path",{d:"M10 12l4 0"}),f("path",{d:"M10 17l4 0"})]});var Tw=Object.create,Pa=Object.defineProperty,Ow=Object.getOwnPropertyDescriptor,af=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),lf=t=>{throw TypeError(t)},Lw=(t,e,i)=>e in t?Pa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Nw=(t,e)=>Pa(t,"name",{value:e,configurable:!0}),Mw=t=>[,,,Tw(t?.[af("metadata")]??null)],Dw=["class","method","getter","setter","accessor","field","value","get","set"],cf=t=>t!==void 0&&typeof t!="function"?lf("Function expected"):t,jw=(t,e,i,r,n)=>({kind:Dw[t],name:e,metadata:r,addInitializer:s=>i._?lf("Already initialized"):n.push(cf(s||null))}),Uw=(t,e)=>Lw(e,af("metadata"),t[3]),Fw=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},qw=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&Ow(n,i));Nw(n,i);for(var h=r.length-1;h>=0;h--)c=jw(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,cf(o)&&(n=o);return Uw(t,n),p&&Pa(n,i,p),u?l^4?s:p:n},uf,Ca,df;uf=[xe(["wiki","getUrl","preferences","$"]),Tt(A.object({"quickDiff.keyshortcut":A.string().default("ctrl-d").description("Key shortcut to open quick diff in quick edit modal")}).description("Quick diff options").extra("category","editor"))];class cs extends(df=Ue){constructor(e){super(e,{},"quick-diff"),this.ctx=e,this.COMPARE_API_DEFAULT_OPTIONS={prop:["comment","diff","diffsize","ids","parsedcomment","size","timestamp","title","user","rel"].join("|"),difftype:"table"}}start(){this.ctx.set("quickDiff",this),this.ctx.on("quick-edit/wiki-page",this.injectQuickEdit.bind(this)),window.RLQ.push(this.injectHistoryPage.bind(this))}stop(){}injectHistoryPage(){const{$:e}=this.ctx,i=Ds("#mw-history-compare");if(!i)return;Nh(".mw-history-compareselectedversions-button",i).forEach(n=>{n.after(f("button",{className:"cdx-button",onClick:s=>{s.preventDefault();const o=new FormData(i),a=Number(o.get("oldid"))||0,c=Number(o.get("diff"))||0;if(!o.get("title")||!a||!c)return this.logger.warn("Missing title or revision IDs");this.comparePages({fromrev:a,torev:c})},children:e`Quick Diff`}))})}async injectQuickEdit({modal:e,wikiPage:i,options:r}){if(i.pageid===0||r.section==="new")return;const{$:n}=this.ctx;let s;e.addButton({label:n`Diff`,side:"left",keyPress:await this.ctx.preferences.get("quickDiff.keyshortcut")||void 0,className:"btn btn-secondary",method:()=>{const o=i.title,a=i.revisions?.[0]?.content||"",c=e.get$content().querySelector('textarea[name="text"]')?.value||"";return a===c?this.ctx.modal.notify("info",{title:n`Quick Diff`,content:n`No changes`}):(this.ctx.emit("quick-diff/quick-edit-modal",{ctx:this.ctx,modal:e,wikiPage:i}),s=this.comparePages({fromtitle:o,fromtext:a,totitle:o,totext:c,topst:!0},s,{backdrop:!1,draggable:!0}),s)}},2),e.on(e.Event.Close,()=>{s?.destroy(),s=void 0})}comparePages(e,i,r){const{$:n}=this.ctx;return!i||i.isDestroyed?i=this.ctx.modal.createObject({title:n`Loading diff...`,content:"",className:"quick-diff",center:!1,...r}).init():i.removeButton("*"),this.ctx.emit("quick-diff/init-options",{ctx:this.ctx,options:e}),i.setContent(f("section",{style:{height:"70vh",display:"flex",justifyContent:"center",alignItems:"center"},children:f(_i,{})})),i.bringToFront(),window.mw&&mw.loader.getState("mediawiki.diff.styles")!=="ready"&&mw.loader.load(["mediawiki.diff.styles"]),this.ctx.api.post({...this.COMPARE_API_DEFAULT_OPTIONS,...e,action:"compare",format:"json",formatversion:2}).then(s=>{if(!s.data.compare)throw new Error("No compare data received",{cause:s});const{data:{compare:o}}=s;i.setTitle(o.fromtitle&&o.totitle?`${o.fromtitle}${o.fromrevid?` (${o.fromrevid})`:""} ⇔ ${o.totitle}${o.torevid?` (${o.torevid})`:""}`:n`Differences`);let a;i.setContent(f("section",{style:{minHeight:"70vh"},children:f(Aw,{ref:c=>a=c,data:o,ctx:this.ctx})})),a.addEventListener(ls.update,c=>{c.stopPropagation(),this.comparePages({fromrev:c.detail.fromrev,torev:c.detail.torev},i,r)},{once:!0}),this.ctx.inject(["quickEdit"],c=>{const l=u=>{u.stopPropagation(),c.quickEdit({revision:u.detail.revid})};a.addEventListener(ls.edit,l),i.on(i.Event.Close,()=>{a.removeEventListener(ls.edit,l)})}),o.fromrevid&&o.torevid&&i.addButton({label:n`Original Compare Page`,side:"right",className:"btn btn-secondary",method:()=>{window.location.href=this.ctx.getUrl("",{oldid:o.fromrevid,diff:o.torevid})}}),this.ctx.emit("quick-diff/loaded",{ctx:this.ctx,modal:i,compare:o})}).catch(s=>{i.setContent(f(wa,{title:n`Failed to load diff`,type:"error",children:f("pre",{children:s instanceof Error?s.message:String(s)})}))}),i.show()}createQuickDiffButton(e,i){const{$:r}=this.ctx,n=i?.icon??f(Rw,{className:"ipe-icon"}),s=i?.label??r`Quick Diff`;return f("a",{href:"#ipe://quick-diff/",dataset:e,className:"ipe-quick-diff",style:{userSelect:"none",marginLeft:"0.2em"},onClick:o=>{o.preventDefault(),this.comparePages(e)},children:[n,s]})}}Ca=Mw(df),cs=qw(Ca,0,"PluginQuickDiff",uf,cs),Fw(Ca,1,cs);const Bw=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickDiff(){return cs}},Symbol.toStringTag,{value:"Module"})),bs=class bs extends Ue{constructor(e){super(e,{},"quick-redirect"),this.ctx=e}start(){this.ctx.set("quickRedirect",this);const{$:e}=this.ctx,i=window.mw?.config.get("wgPageName")||"",r=window.mw?.config.get("wgIsProbablyEditable");this.ctx.inject(["toolbox"],n=>{this.ctx=n,n.toolbox.addButton({id:"quick-redirect",icon:f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-file-symlink",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 21v-4a3 3 0 0 1 3 -3h5"}),f("path",{d:"M9 17l3 -3l-3 -3"}),f("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),f("path",{d:"M5 11v-6a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-9.5"})]}),tooltip:()=>e`Quick Redirect`,group:"group1",index:2,onClick:()=>{this.showModal(r?{to:i}:{})}}),this.addDisposeHandler(s=>{s.toolbox.removeButton("quick-redirect")})})}stop(){}async showModal(e){const{$:i}=this.ctx,r=await this.ctx.preferences.get("quickRedirect.reason");e||(e={}),this.ctx.emit("quick-redirect/init-options",{ctx:this.ctx,options:e});const n=this.ctx.modal.createObject({title:i`Quick Redirect`,content:f(_i,{}),className:"quick-redirect compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let s=null;return n.setContent(f("form",{ref:o=>s=o,style:{display:"flex",flexDirection:"column",gap:"1rem"},onSubmit:o=>{if(o.preventDefault(),s?.checkValidity(),!s?.reportValidity())return;const a=new FormData(s),c={from:a.get("from")?.toString().trim(),to:a.get("to")?.toString().trim(),reason:a.get("reason")||"",overwrite:a.get("overwrite")==="on"};if(!c.from||!c.to){this.ctx.modal.notify("error",{title:i`Failed to redirect`,content:i`From and to are required.`});return}this.ctx.emit("quick-redirect/submit",{ctx:this.ctx,payload:c}),n.setLoadingState(!0),this.redirectPage(c).then(l=>{n.close(),this.ctx.modal.notify("success",{title:i`Redirect successful`,content:i`The redirect has been created.`})}).catch(l=>{n.setLoadingState(!1),this.ctx.modal.notify("error",{title:i`Failed to redirect`,content:l instanceof Error?l.message:String(l)})})},children:[f(Gd,{inputs:[{label:i`Redirect from`,name:"from",value:e?.from,required:!0},{label:i`Redirect to`,name:"to",value:e?.to,required:!0}]}),f(ns,{label:i`Reason`,id:"reason",name:"reason",value:e?.reason??r??""}),f("div",{children:f(Ri,{name:"overwrite",id:"overwrite",checked:e?.overwrite,children:i`Force create redirect even if the from page already exists`})})]})),n.setButtons([{label:i`Create Redirect`,className:"is-primary is-ghost",method:()=>{s?.dispatchEvent(new Event("submit"))}}]),this.ctx.emit("quick-redirect/show-modal",{ctx:this.ctx,modal:n}),n.show()}async redirectPage(e){const{from:i,to:r,reason:n="",overwrite:s=!1}=e,o=await this.ctx.wikiPage.newBlankPage({title:i}),a=`#REDIRECT [[:${r}]]`;return o.edit({text:a,summary:n},{createonly:!s})}};bs.inject=["api","wikiPage","modal","$"],bs.PreferencesSchema=A.object({"quickRedirect.reason":A.string().default("[IPE-NEXT] Quick redirect")}).description("Quick redirect options").extra("category","editor");let Ia=bs;const Hw=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickRedirect:Ia},Symbol.toStringTag,{value:"Module"})),ff=t=>f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...t,class:`icon icon-tabler icons-tabler-outline icon-tabler-upload ${t.className||""}`,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),f("path",{d:"M7 9l5 -5l5 5"}),f("path",{d:"M12 4l0 12"})]}),zw=window?.location?.origin,Wr=({type:t,tag:e,href:i,target:r,children:n,...s})=>(e=e||(i?"a":"button"),typeof r>"u"&&i&&i.startsWith("http")&&!i.startsWith(zw)&&(r="_blank"),gr(e,{className:`theme-ipe ipe-action-button ipe-modal-btn is-${t||"default"}`,href:e==="a"?i:void 0,target:e==="a"?r:void 0,"data-href":e!=="a"?i:void 0,...s},n));var Ww=Object.create,Aa=Object.defineProperty,Kw=Object.getOwnPropertyDescriptor,hf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),pf=t=>{throw TypeError(t)},Vw=(t,e,i)=>e in t?Aa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Gw=(t,e)=>Aa(t,"name",{value:e,configurable:!0}),Qw=t=>[,,,Ww(t?.[hf("metadata")]??null)],Yw=["class","method","getter","setter","accessor","field","value","get","set"],gf=t=>t!==void 0&&typeof t!="function"?pf("Function expected"):t,Xw=(t,e,i,r,n)=>({kind:Yw[t],name:e,metadata:r,addInitializer:s=>i._?pf("Already initialized"):n.push(gf(s||null))}),Jw=(t,e)=>Vw(e,hf("metadata"),t[3]),Zw=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},e_=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&Kw(n,i));Gw(n,i);for(var h=r.length-1;h>=0;h--)c=Xw(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,gf(o)&&(n=o);return Jw(t,n),p&&Aa(n,i,p),u?l^4?s:p:n},mf,Ra,yf;const t_=({$:t})=>f("div",{className:"ipe-quickUpload__preview-placeholder is-na",children:f("span",{children:[f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"icon icon-tabler icons-tabler-filled icon-tabler-file-unknown",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 2l.117 .007a1 1 0 0 1 .876 .876l.007 .117v4l.005 .15a2 2 0 0 0 1.838 1.844l.157 .006h4l.117 .007a1 1 0 0 1 .876 .876l.007 .117v9a3 3 0 0 1 -2.824 2.995l-.176 .005h-10a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-14a3 3 0 0 1 2.824 -2.995l.176 -.005zm0 15a1 1 0 0 0 -.993 .883l-.007 .127a1 1 0 0 0 1.993 .117l.007 -.127a1 1 0 0 0 -1 -1m1.136 -5.727a2.5 2.5 0 0 0 -3.037 .604a1 1 0 0 0 1.434 1.389l.088 -.09a.5 .5 0 1 1 .379 .824a1 1 0 0 0 -.002 2a2.5 2.5 0 0 0 1.137 -4.727"}),f("path",{d:"M19 7h-4l-.001 -4.001z"})]}),f("p",{children:t`No preview available`})]})});mf=[Tt(A.object({"quickUpload.summary":A.string().description("Default summary of the quick upload").default("[IPE-NEXT] Quick upload")})),xe(["modal","$","wikiTitle","wikiFile","quickPreview","preferences"])];class us extends(yf=Ue){constructor(e){super(e,{},"quick-upload"),this.ctx=e}async start(){this.injectToolbox(),this.ctx.set("quickUpload",this)}async stop(){}injectToolbox(){const{$:e}=this.ctx;this.ctx.inject(["toolbox"],i=>{i.toolbox.addButton({id:"quick-upload",group:"group2",index:2,icon:f(ff,{}),tooltip:()=>e`Quick Upload`,onClick:r=>{r.preventDefault(),this.showModal()}}),i.on("dispose",()=>{i.toolbox.removeButton("quick-upload")})})}formatFileSize(e=0){if(e=Number(e),!Number.isFinite(e)||e<0)return"0 B";const i=["B","KB","MB","GB","TB"];let r=0;for(;e>=1024&&r<i.length-1;)e/=1024,r++;return`${new Intl.NumberFormat(void 0,{maximumFractionDigits:2}).format(e)} ${i[r]}`}isFileAccepted(e,i){if(!i)return!0;const r=i.split(",").map(o=>o.trim()).filter(Boolean);if(!r.length)return!0;const n=e.type||"",s=e.name||"";return r.some(o=>{if(o.startsWith("."))return s.toLowerCase().endsWith(o.toLowerCase());if(o.endsWith("/*")){const a=o.slice(0,-1);return n.startsWith(a)}return n===o})}getDefaultPreviewPlaceholder(){const{$:e}=this.ctx;return f("div",{className:"ipe-quickUpload__preview-placeholder",children:f("span",{children:[f(ff,{}),f("p",{children:e`You can drag & drop files to this modal`})]})})}safeId(){return`mu_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`}async showModal(){const{$:e}=this.ctx;let i=!1,r=!1;const n=(C,M,H)=>{this.ctx.modal.notify(C,{title:M,content:H,closeAfter:C==="success"?3e3:8e3})},s=this.ctx.modal.show({className:"ipe-quickUpload compact-buttons",sizeClass:"mediumToLarge",center:!1,title:e`Quick Upload`,content:e`Quick Upload`,outSideClose:!1,beforeClose:()=>i?(n("warning",e`Upload in progress`,e`Please pause or wait for it to finish.`),!1):!0}),o=await this.ctx.preferences.get("quickUpload.summary")||"",a="image/*,video/*,audio/*,application/pdf",c=20;let l=[],u=null;const d={fileInput:null,listEl:null,previewWrapper:null,progressEl:null,progressTextEl:null,summaryInput:null,ignoreWarnings:null},y=(C,M)=>{l=l.map(H=>H.id===C?{...H,...M}:H)},p=C=>{l=l.filter(M=>M.id!==C),u===C&&(u=l[0]?.id??null)},h=(C,M)=>{l=l.map(H=>C.has(H.id)?M(H):H)},_=C=>{const M=[],H=te=>te==null?"":String(te);if(C instanceof Error){M.push(C.message);let te=C;for(;te?.cause&&(te=te.cause,te instanceof Error);)M.push(te.message)}else C?.data?.error?.info?M.push(H(C.data.error.info)):C?.error?.info?M.push(H(C.error.info)):C?.message&&M.push(H(C.message));return M.filter(Boolean)},k=C=>{let M=_(C);M.length===0&&(M=["Upload failed with unknown error."]);const H=M.join(`
26
26
  `),te=H.toLowerCase();return te.includes("file is larger")||te.includes("files larger than")||te.includes("maximum upload size")?{message:`File too large
27
27
  ${H}`,retryable:!1}:te.includes("network")||te.includes("timeout")||te.includes("timed out")?{message:`Network issue
28
- ${H}`,retryable:!0}:{message:H,retryable:!0}},P=C=>C.status==="warning"?!0:C.status==="error"?C.retryable!==!1:!1,b=(C,M)=>C==="retry"?M.filter(H=>P(H)):C==="resume"?M.filter(H=>(H.status==="queued"||H.status==="paused")&&H.retryable!==!1):M.filter(H=>H.status==="queued"||H.status==="paused"),m=C=>{const M=new Set(C.map(H=>H.id));h(M,H=>H.retryable===!1?H:{...H,status:"queued",message:void 0})},g=()=>l.find(C=>C.id===u)||null,w=C=>{u=C,fe(),Ae()},S=()=>{const C={ok:0,warn:0,err:0,paused:0};for(const M of l)M.status==="success"?C.ok++:M.status==="warning"?C.warn++:M.status==="error"?C.err++:M.status==="paused"&&C.paused++;return C},I=(C,M)=>{const H=M>0?Math.floor(C/M*100):0;d.progressTextEl&&(d.progressTextEl.textContent=`${C}/${M} (${H}%)`),d.progressEl&&(d.progressEl.style.width=`${Math.max(0,Math.min(100,H))}%`)},F=C=>(C||"").replace(/\s+/g," ").trim(),N=()=>{l=[],u=null,I(0,0),d.summaryInput&&(d.summaryInput.value=String(o||"")),d.ignoreWarnings&&(d.ignoreWarnings.checked=!1),fe(),Ae()},G=C=>{const M=C.filter(te=>this.isFileAccepted(te,String(a)));if(!M.length)return;const H=M.map(te=>({id:this.safeId(),file:te,filename:te.name,text:"",status:"queued",retryable:!0}));l=[...l,...H],!u&&l.length&&(u=l[0].id),fe(),Ae()},K=C=>{const M={};M.filename=F(C.filename||C.file.name),M.file=C.file;const H=(d.summaryInput?.value||"").trim()||"";return M.comment=H,M.text=C.text||"",d.ignoreWarnings?.checked&&(M.ignorewarnings="1"),M},qe=C=>{switch(C){case"queued":return"Queued";case"uploading":return"Uploading";case"success":return"Uploaded";case"warning":return"Warning";case"error":return"Failed";case"paused":return"Paused";default:return C}},fe=()=>{if(d.listEl){if(d.listEl.innerHTML="",i||I(0,l.length),l.length){const C=f("ul",{style:{listStyle:"none",padding:0,margin:0,display:"grid",gap:"6px"}});l.forEach(M=>{const H=M.id===u,te=f("li",{style:{border:"1px solid var(--ipe-border-color, rgba(0,0,0,.12))",borderRadius:"8px",padding:"8px",cursor:"pointer",background:H?"rgba(59,130,246,.08)":"transparent",minWidth:0},onClick:()=>w(M.id),children:[f("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[f("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:[f("div",{style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",wordBreak:"break-word",fontSize:"13px"},children:f("strong",{style:{fontWeight:600},children:M.filename})}),f("div",{style:{fontSize:"12px",opacity:.75},children:qe(M.status)})]}),f("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:f("button",{type:"button",className:"ipe-btn is-text",title:"Remove",onClick:Je=>{Je.preventDefault(),Je.stopPropagation(),p(M.id),fe(),Ae()},children:"×"})})]}),M.message?f("div",{style:{fontSize:"12px",opacity:.8,marginTop:"4px",whiteSpace:"pre-wrap"},children:M.message}):null]});C.appendChild(te)}),d.listEl.appendChild(C)}else{d.listEl.appendChild(f("div",{style:{opacity:.75,padding:"8px 0"},children:f("p",{children:"No files selected."})})),Li();return}Li()}},Ae=async()=>{if(!d.previewWrapper)return;d.previewWrapper.innerHTML="";const C=g();if(!C){d.previewWrapper.appendChild(this.getDefaultPreviewPlaceholder());return}const M=C.file,H=f("section",{style:{display:"grid",gap:"6px"},children:[f("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:"12px"},children:[f("strong",{style:{wordBreak:"break-word"},children:M.name}),f("span",{style:{fontSize:"12px",opacity:.8},children:this.formatFileSize(M.size)})]}),f("div",{style:{display:"flex",gap:"10px",alignItems:"center",flexWrap:"wrap"},children:[f("span",{style:{fontSize:"12px",opacity:.8},children:M.type||e`Unknown type`}),C.fileUrl?f("a",{href:C.fileUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px"},children:e`Open file page`}):null]})]}),te=await this.ctx.quickPreview.getPreviewElement(M)||f(Xw,{$:e}),Je=f("div",{className:"ipe-quickUpload__preview-content",style:{marginTop:"10px"},children:te}),we=C.status==="success",Ce=f("div",{className:"ipe-input-box",style:{marginTop:"8px",opacity:we?.55:1,filter:we?"grayscale(1)":void 0,pointerEvents:we?"none":void 0},children:[f("label",{htmlFor:"mu_filename",children:e`Target filename`}),f("input",{id:"mu_filename",name:"mu_filename",type:"text",value:C.filename,disabled:i||we,onInput:x=>{const E=x.target.value;y(C.id,{filename:E}),fe()}})]}),v=f("div",{className:"ipe-input-box",style:{marginTop:"8px",opacity:we?.55:1,filter:we?"grayscale(1)":void 0,pointerEvents:we?"none":void 0},children:[f("label",{htmlFor:"mu_text",children:"File description"}),f("textarea",{id:"mu_text",placeholder:`This file is for...
29
- [[Category:XXX]]`,disabled:i||we,value:C.text||"",onInput:x=>{const E=x.target.value;y(C.id,{text:E}),fe()}})]});d.previewWrapper.appendChild(H),d.previewWrapper.appendChild(Je),d.previewWrapper.appendChild(Ce),d.previewWrapper.appendChild(v)},Pe=async C=>{y(C.id,{status:"uploading",message:void 0}),fe(),await Ae();const M=K(C);this.ctx.emit("analytics/event",{feature:"quick-upload",page:M.filename?.toString()||void 0});try{const H=await this.ctx.wikiFile.upload(M);if(H.data?.upload?.result==="Success"){const te=this.ctx.wikiFile.getFileUrl(`File:${H.data.upload.filename}`);y(C.id,{status:"success",fileUrl:te,result:H.data.upload,retryable:!0}),fe(),await Ae();return}throw H}catch(H){let te=[];if(H?.data?.upload){const Ce=H.data.upload;if(Ce.result==="Success"){const E=Ce.filename||M.filename,T=this.ctx.wikiFile.getFileUrl(`File:${E}`);y(C.id,{status:"success",fileUrl:T,result:Ce,retryable:!0}),fe(),await Ae();return}if(Array.isArray(Ce.warnings?.duplicate)&&Ce.warnings.duplicate.length>0){te.push(`Duplicate of: ${Ce.warnings.duplicate.join(", ")}`),y(C.id,{status:"warning",message:te.join(`
30
- `),result:Ce,retryable:!0}),fe(),await Ae();return}if(Ce.warnings?.exists){te.push("A file with the same name already exists."),y(C.id,{status:"warning",message:te.join(`
31
- `),result:Ce,retryable:!0}),fe(),await Ae();return}const{message:v,retryable:x}=k(H);y(C.id,{status:"error",message:v,retryable:x}),fe(),await Ae();return}const{message:Je,retryable:we}=k(H);y(C.id,{status:"error",message:Je,retryable:we}),fe(),await Ae()}},ae=async(C="all")=>{if(i)return;let M=b(C,l);if(C==="retry"){if(M.length===0){n("warning","Nothing to retry",f("div",{children:"There are no retryable failed/warning items."}));return}}else if(C==="resume"){if(M.length===0){n("warning","Nothing to resume",f("div",{children:"There are no queued paused items to continue."}));return}}else{if(l.length===0){n("warning",e`No files selected`,f("div",{children:e`Please select one or more files.`}));return}if(l.length>c){this.ctx.modal.confirm({title:e`Confirm bulk upload`,content:f("div",{children:[e`You are about to upload`," ",f("strong",{children:l.length})," ",e`files at once. Are you sure?`]}),center:!0,okBtn:{label:e`Upload`,className:"is-primary is-ghost"},cancelBtn:{label:e`Cancel`,className:"is-danger is-ghost"}},H=>(H&&ae("all"),!0));return}}C==="retry"&&(m(M),fe(),await Ae(),M=b("retry",l)),i=!0,r=!1,Li();try{const H=M.length;let te=0;I(0,H);for(const x of M){if(r){const T=new Set(M.slice(te).map(A=>A.id));h(T,A=>A.status==="queued"||A.status==="uploading"?{...A,status:"paused",message:"Paused by user",retryable:!0}:A),fe(),await Ae();break}const E=l.find(T=>T.id===x.id);if(!E){te++,I(te,H);continue}await Pe(E),te++,I(te,H)}const{ok:Je,warn:we,err:Ce,paused:v}=S();v>0?n("warning","Upload paused",f("div",{children:[f("div",{children:["Uploaded: ",f("strong",{children:Je})]}),f("div",{children:["Warnings: ",f("strong",{children:we})]}),f("div",{children:["Errors: ",f("strong",{children:Ce})]}),f("div",{children:["Paused: ",f("strong",{children:v})]})]})):Ce===0&&we===0?n("success","Upload completed",f("div",{children:[f("strong",{children:"All files uploaded successfully."}),f("div",{children:["Uploaded: ",f("strong",{children:Je})]})]})):n("warning","Upload completed with issues",f("div",{children:[f("div",{children:["Uploaded: ",f("strong",{children:Je})]}),we?f("div",{children:["Warnings: ",f("strong",{children:we})]}):null,Ce?f("div",{children:["Errors: ",f("strong",{children:Ce})]}):null]}))}finally{i=!1,Li()}},me=C=>{C.preventDefault(),C.stopPropagation(),C.currentTarget?.classList.remove("is-dragover");const H=Array.from(C.dataTransfer?.files||[]);H.length&&G(H)},ge=C=>{C.preventDefault(),C.stopPropagation();const M=C.currentTarget;C.dataTransfer&&(C.dataTransfer.dropEffect="copy"),M?.classList.add("is-dragover")},ni=C=>{C.preventDefault(),C.stopPropagation(),C.currentTarget?.classList.remove("is-dragover")},ar=f("div",{style:{marginBottom:"10px"},children:[f("div",{style:{height:"8px",borderRadius:"999px",background:"rgba(0,0,0,.08)",overflow:"hidden"},children:f("div",{ref:C=>{d.progressEl=C},style:{height:"100%",width:"0%",background:"var(--ipe-primary, #3b82f6)",transition:"width .2s ease"}})}),f("div",{style:{marginTop:"6px",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"10px"},children:f("div",{ref:C=>{d.progressTextEl=C},style:{fontSize:"12px",opacity:.8},children:"0/0 (0%)"})})]}),si=f("section",{style:{display:"grid",gap:"10px",minWidth:0},children:[f("div",{className:"ipe-input-box",children:[f("label",{htmlFor:"mu_files",children:["Files"," ",l.length>0?f("span",{style:{opacity:.85},children:["(",l.length," selected)"]}):null]}),f("input",{id:"mu_files",type:"file",multiple:!0,accept:String(a),disabled:i,ref:C=>{d.fileInput=C},onChange:C=>{const M=Array.from(C.target.files||[]);G(M),C.target.value=""}})]}),f("div",{ref:C=>{d.listEl=C}})]}),vs=f("section",{className:"ipe-quickUpload__container",onDrop:me,onDragOver:ge,onDragLeave:ni,style:{display:"grid",gap:"12px"},children:[ar,f("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 40%) minmax(0, 1fr)",gap:"12px",alignItems:"start",minWidth:0},children:[si,f("section",{style:{display:"grid",gap:"10px"},children:f("div",{className:"ipe-quickUpload__preview",ref:C=>{d.previewWrapper=C},onClick:C=>{const M=C.target;M&&M.closest("img, .ipe-quickUpload__preview-placeholder")&&(C.preventDefault(),d.fileInput?.click())},style:{border:"1px solid var(--ipe-border-color, rgba(0,0,0,.12))",borderRadius:"8px",padding:"10px",minWidth:0}})})]}),f("div",{style:{borderTop:"1px solid var(--ipe-border-color, rgba(0,0,0,.12))",paddingTop:"10px",display:"grid",gap:"10px"},children:[f("div",{className:"ipe-input-box",children:[f("label",{htmlFor:"mu_summary",children:"Summary (applies to all files)"}),f("textarea",{id:"mu_summary",disabled:i,ref:C=>{d.summaryInput=C},onInput:()=>{}})]}),f(Ai,{name:"ignorewarnings",label:e`Ignore warnings and upload anyway`,inputProps:{disabled:i,ref:C=>{d.ignoreWarnings=C}}})]})]});s.setContent(vs),d.summaryInput&&(d.summaryInput.value=String(o||""));const Li=()=>{const{warn:C,err:M,paused:H}=S(),te=M>0||C>0,Je=H>0;let we=e`Upload`,Ce=()=>{ae("all")},v="is-primary is-text";i?(we=r?"Pausing...":"Pause after current",Ce=()=>{r=!0,Li()}):Je?(we="Resume",Ce=()=>{ae("resume")}):te&&(we="Retry failed/warnings",Ce=()=>{ae("retry")}),s.setButtons([{label:e`Cancel`,className:"is-danger is-text",method:()=>s.close()},{label:"Reset",className:"is-text",method:()=>{i||N()}},{label:we,className:v,method:Ce}])};return fe(),await Ae(),s}}Ra=Ww(gf),us=Yw(Ra,0,"PluginQuickUpload",pf,us),Qw(Ra,1,us);const Jw=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickUpload(){return us}},Symbol.toStringTag,{value:"Module"}));class Zw extends Ue{constructor(e){super(e,{},"quick-usage"),this.ctx=e,e.set("quickUsage",this)}async start(){Promise.resolve().then(()=>_0).then(({PluginTemplatesUsed:e})=>this.ctx.plugin(e)),Promise.resolve().then(()=>T0).then(({PluginImagesUsed:e})=>this.ctx.plugin(e)),this.ctx.inject(["quickUpload","$"],e=>{e.on("quick-edit/wiki-page",({modal:i})=>{const{$:r}=e;this.getWrapperForQuickEdit(i).appendChild(f("a",{href:"#ipe:quick-upload",onClick:s=>{s.preventDefault(),e.quickUpload.showModal(),e.emit("analytics/event",{feature:"quick-usage",subtype:"quick-upload"})},children:r`Quick Upload`}))})})}getWrapperForQuickEdit(e){const i=e.get$content().querySelector(".ipe-quickEdit__usages")||f("div",{className:"ipe-quickEdit__usages",style:{display:"flex",gap:"1em",flexWrap:"wrap"}});return e.get$content().querySelector(".ipe-quickEdit__content")?.insertAdjacentElement("afterend",i),i}}const e_=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickUsage:Zw},Symbol.toStringTag,{value:"Module"}));var t_=Object.create,Aa=Object.defineProperty,i_=Object.getOwnPropertyDescriptor,mf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),yf=t=>{throw TypeError(t)},r_=(t,e,i)=>e in t?Aa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,n_=(t,e)=>Aa(t,"name",{value:e,configurable:!0}),s_=t=>[,,,t_(t?.[mf("metadata")]??null)],o_=["class","method","getter","setter","accessor","field","value","get","set"],bf=t=>t!==void 0&&typeof t!="function"?yf("Function expected"):t,a_=(t,e,i,r,n)=>({kind:o_[t],name:e,metadata:r,addInitializer:s=>i._?yf("Already initialized"):n.push(bf(s||null))}),l_=(t,e)=>r_(e,mf("metadata"),t[3]),c_=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},u_=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&i_(n,i));n_(n,i);for(var h=r.length-1;h>=0;h--)c=a_(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,bf(o)&&(n=o);return l_(t,n),p&&Aa(n,i,p),u?l^4?s:p:n},vf,Ta,wf;vf=[Tt(R.object({toolboxAlwaysShow:R.boolean().description("Make the toolbox opened by default").default(!1)}).description("Toolbox preferences")),xe(["preferences"])];class ds extends(wf=ht){constructor(e){super(e,"toolbox",!1),this.ctx=e,this.container=void 0,this.buttons=[],this.seqCounter=0,this.seqMap=new Map,this.compareButtons=(i,r)=>{const n=this.orderKey(i),s=this.orderKey(r),o=n??0,a=s??0;if(o<a)return-1;if(o>a)return 1;const c=this.seqMap.get(i.id)??0,l=this.seqMap.get(r.id)??0;return n===null&&s===null?c!==l?c-l:0:n===null&&s!==null?-1:n!==null&&s===null?1:c!==l?c-l:0}}async start(){this.container=this.createToolbox(),this.ctx.preferences.get("toolboxAlwaysShow").then(e=>{e&&this.container.classList.add("is-persistent")}),this.setupHoverLogic(),document.body.appendChild(this.container),this.ctx.on("i18n/changed",()=>{this.renderAll()})}stop(){this.container?.remove()}get isPersistent(){return this.container.classList.contains("is-persistent")}setupHoverLogic(){let e=null;this.container.addEventListener("mouseenter",()=>{e&&(clearTimeout(e),e=null),this.isPersistent||this.container.classList.add("is-hovered")}),this.container.addEventListener("mouseleave",()=>{this.isPersistent||(e=window.setTimeout(()=>{this.container.classList.remove("is-hovered")},150))})}calculateButtonDelay(e,i){if(i<=1)return 0;const r=.15,n=e/(i-1),s=r*Math.sqrt(n);return Math.round(s*1e3)/1e3}updateButtonDelays(){this.container.querySelectorAll(".btn-group").forEach(i=>{const r=i.querySelectorAll(".btn-tip-group"),n=r.length;r.forEach((s,o)=>{const a=this.calculateButtonDelay(o,n);s.style.setProperty("--transition-delay",`${a}s`),s.style.setProperty("--max-transition-delay","0.15s")})})}createToolbox(){return f("div",{id:"ipe-edit-toolbox",children:[f("ul",{className:"btn-group group1",style:{display:"flex",flexDirection:"column"}}),f("ul",{className:"btn-group group2",style:{display:"flex",flexDirection:"row"}}),f("button",{className:"ipe-toolbox-btn",id:"toolbox-toggler",onClick:()=>{this.toggle()},children:f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"448",height:"512",viewBox:"0 0 448 512",children:[f("rect",{width:"448",height:"512",fill:"none"}),f("path",{fill:"currentColor",d:"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32"})]})})]})}normalizeButtonId(e){return e||(e=Math.random().toString(36).substring(2,8)),`ipe-toolbox__${e.trim()}`.replace(/[\s.#]+/g,"-")}chooseAutoGroup(){const e=this.buttons.filter(r=>r.group==="group1").length,i=this.buttons.filter(r=>r.group==="group2").length;return e<=i?"group1":"group2"}orderKey(e){const i=e.index;return typeof i=="number"?Number.isNaN(i)?null:i:null}addButton(e){e.id=(e.id||"").trim(),e.id||(this.ctx.logger("toolbox").warn("Button id is empty, generating a random one."),e.id=Math.random().toString(36).slice(2,10));const i=this.buttons.findIndex(n=>n.id===e.id),r=(()=>{if(i!==-1){const n=this.buttons[i];return!e.group||e.group==="auto"?n.group:e.group}return!e.group||e.group==="auto"?this.chooseAutoGroup():e.group})();if(this.seqMap.has(e.id)||this.seqMap.set(e.id,this.seqCounter++),i!==-1){const n=this.buttons[i],s=typeof e.index=="number"&&!Number.isNaN(e.index)?e.index:n.index,o={...n,...e,group:r,index:s};this.buttons.splice(i,1,o)}else{const n=typeof e.index=="number"&&!Number.isNaN(e.index)?e.index:void 0,s={...e,group:r,index:n};this.buttons.push(s)}this.ctx.emit("toolbox/button-added",{ctx:this.ctx,payload:e}),this.renderAll()}removeButton(e){const i=this.buttons.findIndex(r=>r.id===e);if(i!==-1){const r=this.buttons[i];this.buttons.splice(i,1),this.ctx.emit("toolbox/button-removed",{ctx:this.ctx,payload:r}),this.renderAll()}}renderButton(e){let{id:i,icon:r,index:n,tooltip:s,itemProps:o,buttonProps:a,onClick:c}=e;const l=this.normalizeButtonId(i);return f("li",{class:"btn-tip-group",id:l,"data-id":i,"data-index":n,...o,children:[f("div",{class:"btn-tip",children:Hl(s)}),f("button",{id:`${l}-btn`,"data-id":e.id,class:"ipe-toolbox-btn",onClick:d=>{c?.(d),this.ctx.emit("toolbox/button-clicked",{ctx:this.ctx,event:d,payload:e})},...a,children:Hl(r)})]})}renderAll(){const e=this.buttons.filter(s=>s.group==="group1").slice().sort(this.compareButtons),i=this.buttons.filter(s=>s.group==="group2").slice().sort(this.compareButtons),r=this.container.querySelector(".btn-group.group1"),n=this.container.querySelector(".btn-group.group2");r.innerHTML="",n.innerHTML="",e.forEach(s=>{r.appendChild(this.renderButton(s))}),i.forEach(s=>{n.appendChild(this.renderButton(s))}),this.updateButtonDelays()}getContainer(){return this.container}get isOpened(){return this.container.classList.contains("is-persistent")||this.container.classList.contains("is-hovered")}toggle(e){const i=this.isPersistent,r=typeof e=="boolean"?e:!i;this.container.classList.toggle("is-persistent",r),this.container.classList.remove("is-hovered"),this.ctx.preferences.set("toolboxAlwaysShow",r),this.ctx.emit("toolbox/toggle",{ctx:this.ctx,opened:this.isOpened})}}Ta=s_(wf),ds=u_(Ta,0,"PluginToolbox",vf,ds),c_(Ta,1,ds);const d_=Object.freeze(Object.defineProperty({__proto__:null,get PluginToolbox(){return ds}},Symbol.toStringTag,{value:"Module"})),fs=$i({__name:"UIBaseButton",props:{variant:{default:"neutral"},active:{type:Boolean,default:!1}},setup(t){const e=t,i=Bt(()=>({"is-active":e.active,"is-danger":e.variant==="danger","is-primary":e.variant==="primary","is-ghost":e.variant==="ghost","is-accent":e.variant==="accent"}));return(r,n)=>(de(),ve("button",{class:xt(["ipeps-button",i.value])},[qy(r.$slots,"default")],2))}}),f_={id:"ipe-registry-manager"},h_={class:"ipeps-header"},p_={class:"ipeps-header-title"},g_={class:"ipeps-input-wrapper"},m_=["placeholder","disabled"],y_={key:0,class:"ipeps-list"},b_={class:"registry-info"},v_={class:"item-name"},w_={class:"item-desc"},__={class:"homepage"},x_=["href"],k_={class:"url"},S_={class:"item-meta"},E_={class:"ipeps-actions"},$_={key:1,class:"ipeps-empty"},P_={class:"text"},C_={class:"description"},I_=ts($i({__name:"RegistryManager",setup(t){const e=ua(),i=e.$,r=e.$$,n=Qe([]),s=Qe(""),o=Qe(!1),a=h=>{try{return new URL(h).hostname}catch{return h}};async function c(){const h=await e.preferences.get("pluginStore.registries")||[],_=await Promise.allSettled(h.map(async k=>{const P=await e.store.getRegistryInfo(k);return{registryUrl:k,label:a(k),...P}}));n.value=_.filter(k=>k.status==="fulfilled").map(k=>k.value)}async function l(){const h=s.value.trim();if(h){if(n.value.some(_=>_.registryUrl===h)){e.modal.notify("info",{content:"Registry already exists."});return}o.value=!0;try{const _=await e.store.getRegistryInfo(h,"online_manifest",!0);if(!_)throw new Error("Invalid registry or unreachable");const k=await e.preferences.get("pluginStore.registries")||[];k.push(h),await e.preferences.set("pluginStore.registries",k),n.value.push({registryUrl:h,label:a(h),..._}),s.value="",e.modal.notify("success",{content:"Registry added."})}catch(_){e.modal.notify("error",{content:_ instanceof Error?_.message:String(_)})}finally{o.value=!1}}}async function u(h){const k=(await e.preferences.get("pluginStore.registries")||[]).filter(P=>P!==h);await e.preferences.set("pluginStore.registries",k),n.value=n.value.filter(P=>P.registryUrl!==h)}async function d(h){const k=(await e.preferences.get("pluginStore.plugins")||[]).filter(P=>P.registry===h);if(k.length===0){e.modal.confirm({title:r`plugin-store.remove-registry.title`,content:r`plugin-store.remove-registry.tip-content`+`
32
- ${h}`,cancelBtn:{label:i`Cancel`,className:"is-ghost"},okBtn:{label:i`Remove`,className:"is-danger"}},async P=>{P&&(await u(h),e.modal.notify("success",{content:r`plugin-store.remove-registry.remove-success`}))});return}e.modal.dialog({title:r`plugin-store.remove-registry.title`,content:gr("div",{class:"theme-ipe-prose"},[gr("p",{},r({count:k.length})`plugin-store.remove-registry.confirm-content`),gr("ul",{},k.map(P=>gr("li",{},P.id)))]),buttons:[{label:r`plugin-store.remove-registry.buttons.remove-only`,className:"is-danger is-ghost",method:async(P,b)=>{await u(h),e.modal.notify("success",{content:r`plugin-store.remove-registry.remove-success`}),b.close()}},{label:r`plugin-store.remove-registry.buttons.remove-and-uninstall`,className:"is-danger",method:async(P,b)=>{await u(h);for(const m of k)try{await e.store.uninstallAndRemovePreference(m.registry,m.id)}catch(g){e.modal.notify("error",{content:g instanceof Error?`Failed to uninstall ${m.id}: ${g.message}`:`Failed to uninstall ${m.id}`})}e.modal.notify("success",{content:r({$1:k.length})`plugin-store.remove-registry.remove-with-plugins-success`}),b.close()}}]},()=>{})}function y(h){const _=h.changes["pluginStore.registries"];Array.isArray(_)&&c()}function p(){const h=Lt.PLUGIN_REGISTRY_URL;s.value=h,l()}return Lr(()=>{c(),e.on("preferences/changed",y)}),(h,_)=>(de(),ve("div",f_,[ie("div",h_,[ie("div",p_,ye(Oe(i)`Registries`),1),ie("div",g_,[ou(ie("input",{class:"ipeps-input with-icon","onUpdate:modelValue":_[0]||(_[0]=k=>s.value=k),type:"url",placeholder:Oe(i)`Add registry URL`+" (https://...)",disabled:o.value},null,8,m_),[[dd,s.value,void 0,{trim:!0}]]),_[1]||(_[1]=ie("div",{class:"ipeps-input-icon"},"📦",-1))]),Ne(fs,{onClick:l,disabled:o.value||!s.value,variant:"primary"},{default:Ar(()=>[Fr(ye(o.value?Oe(i)`Adding...`:Oe(i)`Add`),1)]),_:1},8,["disabled"])]),n.value.length?(de(),ve("div",y_,[(de(!0),ve(We,null,Wo(n.value,k=>(de(),ve("div",{class:"ipeps-item",key:k.registryUrl},[ie("div",b_,[ie("div",v_,ye(k.label),1),ie("div",w_,[ie("div",__,[k.homepage?(de(),ve("a",{key:0,href:k.homepage,target:"_blank"},ye(k.homepage),9,x_)):fi("",!0)]),ie("div",k_,ye(k.registryUrl),1)]),ie("div",S_,ye(k.packages.length)+" packages",1)]),ie("div",E_,[Ne(fs,{onClick:P=>d(k.registryUrl),variant:"danger"},{default:Ar(()=>[Fr(ye(Oe(i)`Remove`),1)]),_:1},8,["onClick"])])]))),128))])):(de(),ve("div",$_,[_[2]||(_[2]=ie("div",{class:"icon"},"🗂️",-1)),ie("div",P_,ye(Oe(i)`No registries configured`),1),ie("div",C_,[Ne(fs,{onClick:p,variant:"primary",style:{padding:"0.25rem 0.5rem"}},{default:Ar(()=>[Fr(ye(Oe(i)`Setup default registry`),1)]),_:1})])]))]))}}),[["__scopeId","data-v-0245c97d"]]),R_={id:"ipe-plugin-install-manager"},A_={class:"ipeps-header"},T_={class:"ipeps-header-title"},O_={class:"ipeps-input-wrapper"},L_=["placeholder","disabled"],N_=["disabled"],M_={key:0,class:"ipeps-loading"},D_={class:"loading-text"},j_={key:1,class:"ipeps-list"},U_={class:"plugin-info"},F_={class:"plugin-header"},q_={class:"item-name"},B_={class:"ipeps-tags"},H_=["href","title"],z_=["title"],W_={class:"plugin-meta"},K_={key:0,class:"version"},V_={key:1,class:"author"},G_={key:2,class:"license"},Q_={key:2,class:"ipeps-empty"},Y_={class:"plugin-empty-text"},X_=ts($i({__name:"PluginInstallManager",setup(t){const e=ua(),i=e.$,r=e.$$,n=Qe([]),s=Qe([]),o=Qe(""),a=Qe(!1),c=(N,G)=>`${N}
33
- ${G}`,l=Bt(()=>new Set(s.value.map(N=>c(N.registry,N.id)))),u=N=>l.value.has(N),d=N=>{try{return new URL(N).hostname}catch{return N}},y=Qe(!1),p=Bt(()=>n.value.length>0),h=Bt(()=>n.value.flatMap(N=>(N.packages||[]).map(G=>({...G,_key:c(N.registryUrl,G.id),registry:N.registryUrl,registryHomepage:N.homepage,registryLabel:d(N.registryUrl),isBroken:!1,isRegistryMissing:!1})))),_=Bt(()=>{const N=o.value.trim().toLowerCase(),G=h.value,K=new Set(G.map(Pe=>Pe._key)),qe=new Set(n.value.map(Pe=>Pe.registryUrl)),fe=s.value.filter(Pe=>!K.has(c(Pe.registry,Pe.id))).map(Pe=>{const ae=n.value.find(me=>me.registryUrl===Pe.registry);return{id:Pe.id,name:void 0,description:void 0,version:void 0,author:void 0,license:void 0,_key:c(Pe.registry,Pe.id),registry:Pe.registry,registryHomepage:ae?.homepage,registryLabel:d(Pe.registry),isBroken:!0,isRegistryMissing:!qe.has(Pe.registry)}}),Ae=Pe=>N?Pe.filter(ae=>ae.name&&ae.name.toLowerCase().includes(N)||ae.id&&ae.id.toLowerCase().includes(N)||ae.description&&ae.description.toLowerCase().includes(N)||ae.author&&ae.author.toLowerCase().includes(N)||ae.registry&&ae.registry.toLowerCase().includes(N)):Pe;return[...Ae(fe),...Ae(G)]}),k=Bt(()=>_.value),P=N=>N.description?N.description:N.isBroken?N.isRegistryMissing?r`plugin-store.broken.registry-unavailable`:r`plugin-store.broken.plugin-removed`:"",b=async(N,G)=>{e.store.installAndSetPreference(N,G)},m=async(N,G)=>{e.store.uninstallAndRemovePreference(N,G)},g=(N,G)=>u(c(N,G))?m(N,G):b(N,G),w=N=>g(N.registry,N.id),S=async()=>{if(a.value)return;if(n.value.length===0){e.modal.notify("info",{content:"No registry configured. Please add a registry first."});return}a.value=!0;const N=await e.store.refreshAllRegistryCaches(),G=Object.entries(N).filter(([qe,fe])=>fe!==null);n.value=G.map(([qe,fe])=>({...fe,registryUrl:qe}));const K=Object.entries(N).filter(([qe,fe])=>fe===null).map(([qe])=>qe);a.value=!1,G.length===0?e.modal.notify("error",{content:"All registries failed to refresh"}):(e.modal.notify("success",{content:`${G.length} ${G.length===1?"registry":"registries"} refreshed successfully.`}),K.length>0&&e.modal.notify("warning",{content:`${K.length} ${K.length===1?"registry":"registries"} failed to refresh:
28
+ ${H}`,retryable:!0}:{message:H,retryable:!0}},P=C=>C.status==="warning"?!0:C.status==="error"?C.retryable!==!1:!1,b=(C,M)=>C==="retry"?M.filter(H=>P(H)):C==="resume"?M.filter(H=>(H.status==="queued"||H.status==="paused")&&H.retryable!==!1):M.filter(H=>H.status==="queued"||H.status==="paused"),m=C=>{const M=new Set(C.map(H=>H.id));h(M,H=>H.retryable===!1?H:{...H,status:"queued",message:void 0})},g=()=>l.find(C=>C.id===u)||null,w=C=>{u=C,fe(),Re()},S=()=>{const C={ok:0,warn:0,err:0,paused:0};for(const M of l)M.status==="success"?C.ok++:M.status==="warning"?C.warn++:M.status==="error"?C.err++:M.status==="paused"&&C.paused++;return C},I=(C,M)=>{const H=M>0?Math.floor(C/M*100):0;d.progressTextEl&&(d.progressTextEl.textContent=`${C}/${M} (${H}%)`),d.progressEl&&(d.progressEl.style.width=`${Math.max(0,Math.min(100,H))}%`)},F=C=>(C||"").replace(/\s+/g," ").trim(),N=()=>{l=[],u=null,I(0,0),d.summaryInput&&(d.summaryInput.value=String(o||"")),d.ignoreWarnings&&(d.ignoreWarnings.checked=!1),fe(),Re()},G=C=>{const M=C.filter(te=>this.isFileAccepted(te,String(a)));if(!M.length)return;const H=M.map(te=>({id:this.safeId(),file:te,filename:te.name,text:"",status:"queued",retryable:!0}));l=[...l,...H],!u&&l.length&&(u=l[0].id),fe(),Re()},K=C=>{const M={};M.filename=F(C.filename||C.file.name),M.file=C.file;const H=(d.summaryInput?.value||"").trim()||"";return M.comment=H,M.text=C.text||"",d.ignoreWarnings?.checked&&(M.ignorewarnings="1"),M},qe=C=>{switch(C){case"queued":return"Queued";case"uploading":return"Uploading";case"success":return"Uploaded";case"warning":return"Warning";case"error":return"Failed";case"paused":return"Paused";default:return C}},fe=()=>{if(d.listEl){if(d.listEl.innerHTML="",i||I(0,l.length),l.length){const C=f("ul",{style:{listStyle:"none",padding:0,margin:0,display:"grid",gap:"6px"}});l.forEach(M=>{const H=M.id===u,te=f("li",{style:{border:"1px solid var(--ipe-border-color, rgba(0,0,0,.12))",borderRadius:"8px",padding:"8px",cursor:"pointer",background:H?"rgba(59,130,246,.08)":"transparent",minWidth:0},onClick:()=>w(M.id),children:[f("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[f("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:[f("div",{style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",wordBreak:"break-word",fontSize:"13px"},children:f("strong",{style:{fontWeight:600},children:M.filename})}),f("div",{style:{fontSize:"12px",opacity:.75},children:qe(M.status)})]}),f("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:f("button",{type:"button",className:"ipe-btn is-text",title:"Remove",onClick:Je=>{Je.preventDefault(),Je.stopPropagation(),p(M.id),fe(),Re()},children:"×"})})]}),M.message?f("div",{style:{fontSize:"12px",opacity:.8,marginTop:"4px",whiteSpace:"pre-wrap"},children:M.message}):null]});C.appendChild(te)}),d.listEl.appendChild(C)}else{d.listEl.appendChild(f("div",{style:{opacity:.75,padding:"8px 0"},children:f("p",{children:"No files selected."})})),Li();return}Li()}},Re=async()=>{if(!d.previewWrapper)return;d.previewWrapper.innerHTML="";const C=g();if(!C){d.previewWrapper.appendChild(this.getDefaultPreviewPlaceholder());return}const M=C.file,H=f("section",{style:{display:"grid",gap:"6px"},children:[f("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:"12px"},children:[f("strong",{style:{wordBreak:"break-word"},children:M.name}),f("span",{style:{fontSize:"12px",opacity:.8},children:this.formatFileSize(M.size)})]}),f("div",{style:{display:"flex",gap:"10px",alignItems:"center",flexWrap:"wrap"},children:[f("span",{style:{fontSize:"12px",opacity:.8},children:M.type||e`Unknown type`}),C.fileUrl?f("a",{href:C.fileUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px"},children:e`Open file page`}):null]})]}),te=await this.ctx.quickPreview.getPreviewElement(M)||f(t_,{$:e}),Je=f("div",{className:"ipe-quickUpload__preview-content",style:{marginTop:"10px"},children:te}),we=C.status==="success",Ce=f("div",{className:"ipe-input-box",style:{marginTop:"8px",opacity:we?.55:1,filter:we?"grayscale(1)":void 0,pointerEvents:we?"none":void 0},children:[f("label",{htmlFor:"mu_filename",children:e`Target filename`}),f("input",{id:"mu_filename",name:"mu_filename",type:"text",value:C.filename,disabled:i||we,onInput:x=>{const E=x.target.value;y(C.id,{filename:E}),fe()}})]}),v=f("div",{className:"ipe-input-box",style:{marginTop:"8px",opacity:we?.55:1,filter:we?"grayscale(1)":void 0,pointerEvents:we?"none":void 0},children:[f("label",{htmlFor:"mu_text",children:"File description"}),f("textarea",{id:"mu_text",placeholder:`This file is for...
29
+ [[Category:XXX]]`,disabled:i||we,value:C.text||"",onInput:x=>{const E=x.target.value;y(C.id,{text:E}),fe()}})]});d.previewWrapper.appendChild(H),d.previewWrapper.appendChild(Je),d.previewWrapper.appendChild(Ce),d.previewWrapper.appendChild(v)},Pe=async C=>{y(C.id,{status:"uploading",message:void 0}),fe(),await Re();const M=K(C);this.ctx.emit("analytics/event",{feature:"quick-upload",page:M.filename?.toString()||void 0});try{const H=await this.ctx.wikiFile.upload(M);if(H.data?.upload?.result==="Success"){const te=this.ctx.wikiFile.getFileUrl(`File:${H.data.upload.filename}`);y(C.id,{status:"success",fileUrl:te,result:H.data.upload,retryable:!0}),fe(),await Re();return}throw H}catch(H){let te=[];if(H?.data?.upload){const Ce=H.data.upload;if(Ce.result==="Success"){const E=Ce.filename||M.filename,T=this.ctx.wikiFile.getFileUrl(`File:${E}`);y(C.id,{status:"success",fileUrl:T,result:Ce,retryable:!0}),fe(),await Re();return}if(Array.isArray(Ce.warnings?.duplicate)&&Ce.warnings.duplicate.length>0){te.push(`Duplicate of: ${Ce.warnings.duplicate.join(", ")}`),y(C.id,{status:"warning",message:te.join(`
30
+ `),result:Ce,retryable:!0}),fe(),await Re();return}if(Ce.warnings?.exists){te.push("A file with the same name already exists."),y(C.id,{status:"warning",message:te.join(`
31
+ `),result:Ce,retryable:!0}),fe(),await Re();return}const{message:v,retryable:x}=k(H);y(C.id,{status:"error",message:v,retryable:x}),fe(),await Re();return}const{message:Je,retryable:we}=k(H);y(C.id,{status:"error",message:Je,retryable:we}),fe(),await Re()}},ae=async(C="all")=>{if(i)return;let M=b(C,l);if(C==="retry"){if(M.length===0){n("warning","Nothing to retry",f("div",{children:"There are no retryable failed/warning items."}));return}}else if(C==="resume"){if(M.length===0){n("warning","Nothing to resume",f("div",{children:"There are no queued paused items to continue."}));return}}else{if(l.length===0){n("warning",e`No files selected`,f("div",{children:e`Please select one or more files.`}));return}if(l.length>c){this.ctx.modal.confirm({title:e`Confirm bulk upload`,content:f("div",{children:[e`You are about to upload`," ",f("strong",{children:l.length})," ",e`files at once. Are you sure?`]}),center:!0,okBtn:{label:e`Upload`,className:"is-primary is-ghost"},cancelBtn:{label:e`Cancel`,className:"is-danger is-ghost"}},H=>(H&&ae("all"),!0));return}}C==="retry"&&(m(M),fe(),await Re(),M=b("retry",l)),i=!0,r=!1,Li();try{const H=M.length;let te=0;I(0,H);for(const x of M){if(r){const T=new Set(M.slice(te).map(R=>R.id));h(T,R=>R.status==="queued"||R.status==="uploading"?{...R,status:"paused",message:"Paused by user",retryable:!0}:R),fe(),await Re();break}const E=l.find(T=>T.id===x.id);if(!E){te++,I(te,H);continue}await Pe(E),te++,I(te,H)}const{ok:Je,warn:we,err:Ce,paused:v}=S();v>0?n("warning","Upload paused",f("div",{children:[f("div",{children:["Uploaded: ",f("strong",{children:Je})]}),f("div",{children:["Warnings: ",f("strong",{children:we})]}),f("div",{children:["Errors: ",f("strong",{children:Ce})]}),f("div",{children:["Paused: ",f("strong",{children:v})]})]})):Ce===0&&we===0?n("success","Upload completed",f("div",{children:[f("strong",{children:"All files uploaded successfully."}),f("div",{children:["Uploaded: ",f("strong",{children:Je})]})]})):n("warning","Upload completed with issues",f("div",{children:[f("div",{children:["Uploaded: ",f("strong",{children:Je})]}),we?f("div",{children:["Warnings: ",f("strong",{children:we})]}):null,Ce?f("div",{children:["Errors: ",f("strong",{children:Ce})]}):null]}))}finally{i=!1,Li()}},me=C=>{C.preventDefault(),C.stopPropagation(),C.currentTarget?.classList.remove("is-dragover");const H=Array.from(C.dataTransfer?.files||[]);H.length&&G(H)},ge=C=>{C.preventDefault(),C.stopPropagation();const M=C.currentTarget;C.dataTransfer&&(C.dataTransfer.dropEffect="copy"),M?.classList.add("is-dragover")},ni=C=>{C.preventDefault(),C.stopPropagation(),C.currentTarget?.classList.remove("is-dragover")},ar=f("div",{style:{marginBottom:"10px"},children:[f("div",{style:{height:"8px",borderRadius:"999px",background:"rgba(0,0,0,.08)",overflow:"hidden"},children:f("div",{ref:C=>{d.progressEl=C},style:{height:"100%",width:"0%",background:"var(--ipe-primary, #3b82f6)",transition:"width .2s ease"}})}),f("div",{style:{marginTop:"6px",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"10px"},children:f("div",{ref:C=>{d.progressTextEl=C},style:{fontSize:"12px",opacity:.8},children:"0/0 (0%)"})})]}),si=f("section",{style:{display:"grid",gap:"10px",minWidth:0},children:[f("div",{className:"ipe-input-box",children:[f("label",{htmlFor:"mu_files",children:["Files"," ",l.length>0?f("span",{style:{opacity:.85},children:["(",l.length," selected)"]}):null]}),f("input",{id:"mu_files",type:"file",multiple:!0,accept:String(a),disabled:i,ref:C=>{d.fileInput=C},onChange:C=>{const M=Array.from(C.target.files||[]);G(M),C.target.value=""}})]}),f("div",{ref:C=>{d.listEl=C}})]}),vs=f("section",{className:"ipe-quickUpload__container",onDrop:me,onDragOver:ge,onDragLeave:ni,style:{display:"grid",gap:"12px"},children:[ar,f("div",{className:"ipe-quickUpload__layout",children:[si,f("section",{style:{display:"grid",gap:"10px"},children:f("div",{className:"ipe-quickUpload__preview",ref:C=>{d.previewWrapper=C},onClick:C=>{const M=C.target;M&&M.closest("img, .ipe-quickUpload__preview-placeholder")&&(C.preventDefault(),d.fileInput?.click())},style:{border:"1px solid var(--ipe-border-color, rgba(0,0,0,.12))",borderRadius:"8px",padding:"10px",minWidth:0}})})]}),f("div",{style:{borderTop:"1px solid var(--ipe-border-color, rgba(0,0,0,.12))",paddingTop:"10px",display:"grid",gap:"10px"},children:[f("div",{className:"ipe-input-box",children:[f("label",{htmlFor:"mu_summary",children:"Summary (applies to all files)"}),f("textarea",{id:"mu_summary",disabled:i,ref:C=>{d.summaryInput=C},onInput:()=>{}})]}),f(Ri,{name:"ignorewarnings",label:e`Ignore warnings and upload anyway`,inputProps:{disabled:i,ref:C=>{d.ignoreWarnings=C}}})]})]});s.setContent(vs),d.summaryInput&&(d.summaryInput.value=String(o||""));const Li=()=>{const{warn:C,err:M,paused:H}=S(),te=M>0||C>0,Je=H>0;let we=e`Upload`,Ce=()=>{ae("all")},v="is-primary is-text";i?(we=r?"Pausing...":"Pause after current",Ce=()=>{r=!0,Li()}):Je?(we="Resume",Ce=()=>{ae("resume")}):te&&(we="Retry failed/warnings",Ce=()=>{ae("retry")}),s.setButtons([{label:e`Cancel`,className:"is-danger is-text",method:()=>s.close()},{label:"Reset",className:"is-text",method:()=>{i||N()}},{label:we,className:v,method:Ce}])};return fe(),await Re(),s}}Ra=Qw(yf),us=e_(Ra,0,"PluginQuickUpload",mf,us),Zw(Ra,1,us);const i_=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickUpload(){return us}},Symbol.toStringTag,{value:"Module"}));class r_ extends Ue{constructor(e){super(e,{},"quick-usage"),this.ctx=e,e.set("quickUsage",this)}async start(){Promise.resolve().then(()=>E0).then(({PluginTemplatesUsed:e})=>this.ctx.plugin(e)),Promise.resolve().then(()=>M0).then(({PluginImagesUsed:e})=>this.ctx.plugin(e)),this.ctx.inject(["quickUpload","$"],e=>{e.on("quick-edit/wiki-page",({modal:i})=>{const{$:r}=e;this.getWrapperForQuickEdit(i).appendChild(f("a",{href:"#ipe:quick-upload",onClick:s=>{s.preventDefault(),e.quickUpload.showModal(),e.emit("analytics/event",{feature:"quick-usage",subtype:"quick-upload"})},children:r`Quick Upload`}))})})}getWrapperForQuickEdit(e){const i=e.get$content().querySelector(".ipe-quickEdit__usages")||f("div",{className:"ipe-quickEdit__usages",style:{display:"flex",gap:"1em",flexWrap:"wrap"}});return e.get$content().querySelector(".ipe-quickEdit__content")?.insertAdjacentElement("afterend",i),i}}const n_=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickUsage:r_},Symbol.toStringTag,{value:"Module"}));var s_=Object.create,Ta=Object.defineProperty,o_=Object.getOwnPropertyDescriptor,bf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),vf=t=>{throw TypeError(t)},a_=(t,e,i)=>e in t?Ta(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,l_=(t,e)=>Ta(t,"name",{value:e,configurable:!0}),c_=t=>[,,,s_(t?.[bf("metadata")]??null)],u_=["class","method","getter","setter","accessor","field","value","get","set"],wf=t=>t!==void 0&&typeof t!="function"?vf("Function expected"):t,d_=(t,e,i,r,n)=>({kind:u_[t],name:e,metadata:r,addInitializer:s=>i._?vf("Already initialized"):n.push(wf(s||null))}),f_=(t,e)=>a_(e,bf("metadata"),t[3]),h_=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},p_=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&o_(n,i));l_(n,i);for(var h=r.length-1;h>=0;h--)c=d_(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,wf(o)&&(n=o);return f_(t,n),p&&Ta(n,i,p),u?l^4?s:p:n},_f,Oa,xf;_f=[Tt(A.object({toolboxAlwaysShow:A.boolean().description("Make the toolbox opened by default").default(!1)}).description("Toolbox preferences")),xe(["preferences"])];class ds extends(xf=ht){constructor(e){super(e,"toolbox",!1),this.ctx=e,this.container=void 0,this.buttons=[],this.seqCounter=0,this.seqMap=new Map,this.compareButtons=(i,r)=>{const n=this.orderKey(i),s=this.orderKey(r),o=n??0,a=s??0;if(o<a)return-1;if(o>a)return 1;const c=this.seqMap.get(i.id)??0,l=this.seqMap.get(r.id)??0;return n===null&&s===null?c!==l?c-l:0:n===null&&s!==null?-1:n!==null&&s===null?1:c!==l?c-l:0}}async start(){this.container=this.createToolbox(),this.ctx.preferences.get("toolboxAlwaysShow").then(e=>{e&&this.container.classList.add("is-persistent")}),this.setupHoverLogic(),document.body.appendChild(this.container),this.ctx.on("i18n/changed",()=>{this.renderAll()})}stop(){this.container?.remove()}get isPersistent(){return this.container.classList.contains("is-persistent")}setupHoverLogic(){let e=null;this.container.addEventListener("mouseenter",()=>{e&&(clearTimeout(e),e=null),this.isPersistent||this.container.classList.add("is-hovered")}),this.container.addEventListener("mouseleave",()=>{this.isPersistent||(e=window.setTimeout(()=>{this.container.classList.remove("is-hovered")},150))})}calculateButtonDelay(e,i){if(i<=1)return 0;const r=.15,n=e/(i-1),s=r*Math.sqrt(n);return Math.round(s*1e3)/1e3}updateButtonDelays(){this.container.querySelectorAll(".btn-group").forEach(i=>{const r=i.querySelectorAll(".btn-tip-group"),n=r.length;r.forEach((s,o)=>{const a=this.calculateButtonDelay(o,n);s.style.setProperty("--transition-delay",`${a}s`),s.style.setProperty("--max-transition-delay","0.15s")})})}createToolbox(){return f("div",{id:"ipe-edit-toolbox",children:[f("ul",{className:"btn-group group1",style:{display:"flex",flexDirection:"column"}}),f("ul",{className:"btn-group group2",style:{display:"flex",flexDirection:"row"}}),f("button",{className:"ipe-toolbox-btn",id:"toolbox-toggler",onClick:()=>{this.toggle()},children:f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"448",height:"512",viewBox:"0 0 448 512",children:[f("rect",{width:"448",height:"512",fill:"none"}),f("path",{fill:"currentColor",d:"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32"})]})})]})}normalizeButtonId(e){return e||(e=Math.random().toString(36).substring(2,8)),`ipe-toolbox__${e.trim()}`.replace(/[\s.#]+/g,"-")}chooseAutoGroup(){const e=this.buttons.filter(r=>r.group==="group1").length,i=this.buttons.filter(r=>r.group==="group2").length;return e<=i?"group1":"group2"}orderKey(e){const i=e.index;return typeof i=="number"?Number.isNaN(i)?null:i:null}addButton(e){e.id=(e.id||"").trim(),e.id||(this.ctx.logger("toolbox").warn("Button id is empty, generating a random one."),e.id=Math.random().toString(36).slice(2,10));const i=this.buttons.findIndex(n=>n.id===e.id),r=(()=>{if(i!==-1){const n=this.buttons[i];return!e.group||e.group==="auto"?n.group:e.group}return!e.group||e.group==="auto"?this.chooseAutoGroup():e.group})();if(this.seqMap.has(e.id)||this.seqMap.set(e.id,this.seqCounter++),i!==-1){const n=this.buttons[i],s=typeof e.index=="number"&&!Number.isNaN(e.index)?e.index:n.index,o={...n,...e,group:r,index:s};this.buttons.splice(i,1,o)}else{const n=typeof e.index=="number"&&!Number.isNaN(e.index)?e.index:void 0,s={...e,group:r,index:n};this.buttons.push(s)}this.ctx.emit("toolbox/button-added",{ctx:this.ctx,payload:e}),this.renderAll()}removeButton(e){const i=this.buttons.findIndex(r=>r.id===e);if(i!==-1){const r=this.buttons[i];this.buttons.splice(i,1),this.ctx.emit("toolbox/button-removed",{ctx:this.ctx,payload:r}),this.renderAll()}}renderButton(e){let{id:i,icon:r,index:n,tooltip:s,itemProps:o,buttonProps:a,onClick:c}=e;const l=this.normalizeButtonId(i);return f("li",{class:"btn-tip-group",id:l,"data-id":i,"data-index":n,...o,children:[f("div",{class:"btn-tip",children:Wl(s)}),f("button",{id:`${l}-btn`,"data-id":e.id,class:"ipe-toolbox-btn",onClick:d=>{c?.(d),this.ctx.emit("toolbox/button-clicked",{ctx:this.ctx,event:d,payload:e})},...a,children:Wl(r)})]})}renderAll(){const e=this.buttons.filter(s=>s.group==="group1").slice().sort(this.compareButtons),i=this.buttons.filter(s=>s.group==="group2").slice().sort(this.compareButtons),r=this.container.querySelector(".btn-group.group1"),n=this.container.querySelector(".btn-group.group2");r.innerHTML="",n.innerHTML="",e.forEach(s=>{r.appendChild(this.renderButton(s))}),i.forEach(s=>{n.appendChild(this.renderButton(s))}),this.updateButtonDelays()}getContainer(){return this.container}get isOpened(){return this.container.classList.contains("is-persistent")||this.container.classList.contains("is-hovered")}toggle(e){const i=this.isPersistent,r=typeof e=="boolean"?e:!i;this.container.classList.toggle("is-persistent",r),this.container.classList.remove("is-hovered"),this.ctx.preferences.set("toolboxAlwaysShow",r),this.ctx.emit("toolbox/toggle",{ctx:this.ctx,opened:this.isOpened})}}Oa=c_(xf),ds=p_(Oa,0,"PluginToolbox",_f,ds),h_(Oa,1,ds);const g_=Object.freeze(Object.defineProperty({__proto__:null,get PluginToolbox(){return ds}},Symbol.toStringTag,{value:"Module"})),fs=$i({__name:"UIBaseButton",props:{variant:{default:"neutral"},active:{type:Boolean,default:!1}},setup(t){const e=t,i=Bt(()=>({"is-active":e.active,"is-danger":e.variant==="danger","is-primary":e.variant==="primary","is-ghost":e.variant==="ghost","is-accent":e.variant==="accent"}));return(r,n)=>(de(),ve("button",{class:xt(["ipeps-button",i.value])},[Wy(r.$slots,"default")],2))}}),m_={id:"ipe-registry-manager"},y_={class:"ipeps-header"},b_={class:"ipeps-header-title"},v_={class:"ipeps-input-wrapper"},w_=["placeholder","disabled"],__={key:0,class:"ipeps-list"},x_={class:"registry-info"},k_={class:"item-name"},S_={class:"item-desc"},E_={class:"homepage"},$_=["href"],P_={class:"url"},C_={class:"item-meta"},I_={class:"ipeps-actions"},A_={key:1,class:"ipeps-empty"},R_={class:"text"},T_={class:"description"},O_=ts($i({__name:"RegistryManager",setup(t){const e=da(),i=e.$,r=e.$$,n=Qe([]),s=Qe(""),o=Qe(!1),a=h=>{try{return new URL(h).hostname}catch{return h}};async function c(){const h=await e.preferences.get("pluginStore.registries")||[],_=await Promise.allSettled(h.map(async k=>{const P=await e.store.getRegistryInfo(k);return{registryUrl:k,label:a(k),...P}}));n.value=_.filter(k=>k.status==="fulfilled").map(k=>k.value)}async function l(){const h=s.value.trim();if(h){if(n.value.some(_=>_.registryUrl===h)){e.modal.notify("info",{content:"Registry already exists."});return}o.value=!0;try{const _=await e.store.getRegistryInfo(h,"online_manifest",!0);if(!_)throw new Error("Invalid registry or unreachable");const k=await e.preferences.get("pluginStore.registries")||[];k.push(h),await e.preferences.set("pluginStore.registries",k),n.value.push({registryUrl:h,label:a(h),..._}),s.value="",e.modal.notify("success",{content:"Registry added."})}catch(_){e.modal.notify("error",{content:_ instanceof Error?_.message:String(_)})}finally{o.value=!1}}}async function u(h){const k=(await e.preferences.get("pluginStore.registries")||[]).filter(P=>P!==h);await e.preferences.set("pluginStore.registries",k),n.value=n.value.filter(P=>P.registryUrl!==h)}async function d(h){const k=(await e.preferences.get("pluginStore.plugins")||[]).filter(P=>P.registry===h);if(k.length===0){e.modal.confirm({title:r`plugin-store.remove-registry.title`,content:r`plugin-store.remove-registry.tip-content`+`
32
+ ${h}`,cancelBtn:{label:i`Cancel`,className:"is-ghost"},okBtn:{label:i`Remove`,className:"is-danger"}},async P=>{P&&(await u(h),e.modal.notify("success",{content:r`plugin-store.remove-registry.remove-success`}))});return}e.modal.dialog({title:r`plugin-store.remove-registry.title`,content:gr("div",{class:"theme-ipe-prose"},[gr("p",{},r({count:k.length})`plugin-store.remove-registry.confirm-content`),gr("ul",{},k.map(P=>gr("li",{},P.id)))]),buttons:[{label:r`plugin-store.remove-registry.buttons.remove-only`,className:"is-danger is-ghost",method:async(P,b)=>{await u(h),e.modal.notify("success",{content:r`plugin-store.remove-registry.remove-success`}),b.close()}},{label:r`plugin-store.remove-registry.buttons.remove-and-uninstall`,className:"is-danger",method:async(P,b)=>{await u(h);for(const m of k)try{await e.store.uninstallAndRemovePreference(m.registry,m.id)}catch(g){e.modal.notify("error",{content:g instanceof Error?`Failed to uninstall ${m.id}: ${g.message}`:`Failed to uninstall ${m.id}`})}e.modal.notify("success",{content:r({$1:k.length})`plugin-store.remove-registry.remove-with-plugins-success`}),b.close()}}]},()=>{})}function y(h){const _=h.changes["pluginStore.registries"];Array.isArray(_)&&c()}function p(){const h=Lt.PLUGIN_REGISTRY_URL;s.value=h,l()}return Lr(()=>{c(),e.on("preferences/changed",y)}),(h,_)=>(de(),ve("div",m_,[ie("div",y_,[ie("div",b_,ye(Oe(i)`Registries`),1),ie("div",v_,[lu(ie("input",{class:"ipeps-input with-icon","onUpdate:modelValue":_[0]||(_[0]=k=>s.value=k),type:"url",placeholder:Oe(i)`Add registry URL`+" (https://...)",disabled:o.value},null,8,w_),[[hd,s.value,void 0,{trim:!0}]]),_[1]||(_[1]=ie("div",{class:"ipeps-input-icon"},"📦",-1))]),Ne(fs,{onClick:l,disabled:o.value||!s.value,variant:"primary"},{default:Rr(()=>[Fr(ye(o.value?Oe(i)`Adding...`:Oe(i)`Add`),1)]),_:1},8,["disabled"])]),n.value.length?(de(),ve("div",__,[(de(!0),ve(We,null,Ko(n.value,k=>(de(),ve("div",{class:"ipeps-item",key:k.registryUrl},[ie("div",x_,[ie("div",k_,ye(k.label),1),ie("div",S_,[ie("div",E_,[k.homepage?(de(),ve("a",{key:0,href:k.homepage,target:"_blank"},ye(k.homepage),9,$_)):fi("",!0)]),ie("div",P_,ye(k.registryUrl),1)]),ie("div",C_,ye(k.packages.length)+" packages",1)]),ie("div",I_,[Ne(fs,{onClick:P=>d(k.registryUrl),variant:"danger"},{default:Rr(()=>[Fr(ye(Oe(i)`Remove`),1)]),_:1},8,["onClick"])])]))),128))])):(de(),ve("div",A_,[_[2]||(_[2]=ie("div",{class:"icon"},"🗂️",-1)),ie("div",R_,ye(Oe(i)`No registries configured`),1),ie("div",T_,[Ne(fs,{onClick:p,variant:"primary",style:{padding:"0.25rem 0.5rem"}},{default:Rr(()=>[Fr(ye(Oe(i)`Setup default registry`),1)]),_:1})])]))]))}}),[["__scopeId","data-v-0245c97d"]]),L_={id:"ipe-plugin-install-manager"},N_={class:"ipeps-header"},M_={class:"ipeps-header-title"},D_={class:"ipeps-input-wrapper"},j_=["placeholder","disabled"],U_=["disabled"],F_={key:0,class:"ipeps-loading"},q_={class:"loading-text"},B_={key:1,class:"ipeps-list"},H_={class:"plugin-info"},z_={class:"plugin-header"},W_={class:"item-name"},K_={class:"ipeps-tags"},V_=["href","title"],G_=["title"],Q_={class:"plugin-meta"},Y_={key:0,class:"version"},X_={key:1,class:"author"},J_={key:2,class:"license"},Z_={key:2,class:"ipeps-empty"},e0={class:"plugin-empty-text"},t0=ts($i({__name:"PluginInstallManager",setup(t){const e=da(),i=e.$,r=e.$$,n=Qe([]),s=Qe([]),o=Qe(""),a=Qe(!1),c=(N,G)=>`${N}
33
+ ${G}`,l=Bt(()=>new Set(s.value.map(N=>c(N.registry,N.id)))),u=N=>l.value.has(N),d=N=>{try{return new URL(N).hostname}catch{return N}},y=Qe(!1),p=Bt(()=>n.value.length>0),h=Bt(()=>n.value.flatMap(N=>(N.packages||[]).map(G=>({...G,_key:c(N.registryUrl,G.id),registry:N.registryUrl,registryHomepage:N.homepage,registryLabel:d(N.registryUrl),isBroken:!1,isRegistryMissing:!1})))),_=Bt(()=>{const N=o.value.trim().toLowerCase(),G=h.value,K=new Set(G.map(Pe=>Pe._key)),qe=new Set(n.value.map(Pe=>Pe.registryUrl)),fe=s.value.filter(Pe=>!K.has(c(Pe.registry,Pe.id))).map(Pe=>{const ae=n.value.find(me=>me.registryUrl===Pe.registry);return{id:Pe.id,name:void 0,description:void 0,version:void 0,author:void 0,license:void 0,_key:c(Pe.registry,Pe.id),registry:Pe.registry,registryHomepage:ae?.homepage,registryLabel:d(Pe.registry),isBroken:!0,isRegistryMissing:!qe.has(Pe.registry)}}),Re=Pe=>N?Pe.filter(ae=>ae.name&&ae.name.toLowerCase().includes(N)||ae.id&&ae.id.toLowerCase().includes(N)||ae.description&&ae.description.toLowerCase().includes(N)||ae.author&&ae.author.toLowerCase().includes(N)||ae.registry&&ae.registry.toLowerCase().includes(N)):Pe;return[...Re(fe),...Re(G)]}),k=Bt(()=>_.value),P=N=>N.description?N.description:N.isBroken?N.isRegistryMissing?r`plugin-store.broken.registry-unavailable`:r`plugin-store.broken.plugin-removed`:"",b=async(N,G)=>{e.store.installAndSetPreference(N,G)},m=async(N,G)=>{e.store.uninstallAndRemovePreference(N,G)},g=(N,G)=>u(c(N,G))?m(N,G):b(N,G),w=N=>g(N.registry,N.id),S=async()=>{if(a.value)return;if(n.value.length===0){e.modal.notify("info",{content:"No registry configured. Please add a registry first."});return}a.value=!0;const N=await e.store.refreshAllRegistryCaches(),G=Object.entries(N).filter(([qe,fe])=>fe!==null);n.value=G.map(([qe,fe])=>({...fe,registryUrl:qe}));const K=Object.entries(N).filter(([qe,fe])=>fe===null).map(([qe])=>qe);a.value=!1,G.length===0?e.modal.notify("error",{content:"All registries failed to refresh"}):(e.modal.notify("success",{content:`${G.length} ${G.length===1?"registry":"registries"} refreshed successfully.`}),K.length>0&&e.modal.notify("warning",{content:`${K.length} ${K.length===1?"registry":"registries"} failed to refresh:
34
34
  ${K.join(`
35
- `)}`}))},I=async()=>{y.value=!1;const N=await e.store.ctx.preferences.get("pluginStore.registries")||[],G=await Promise.allSettled(N.map(async K=>({...await e.store.getRegistryInfo(K),registryUrl:K})));n.value=G.filter(K=>K.status==="fulfilled").map(K=>K.value),s.value=await e.preferences.get("pluginStore.plugins")||[],y.value=!0};function F(N){const G=N.changes["pluginStore.registries"],K=N.changes["pluginStore.plugins"];Array.isArray(K)&&(s.value=K),Array.isArray(G)&&I()}return Lr(()=>{I(),e.on("preferences/changed",F)}),Ho(()=>{}),(N,G)=>(de(),ve("div",R_,[ie("div",A_,[ie("div",T_,ye(Oe(i)`Plugins`),1),ie("div",O_,[ou(ie("input",{class:"ipeps-input with-icon","onUpdate:modelValue":G[0]||(G[0]=K=>o.value=K),type:"text",placeholder:Oe(i)`Search plugins...`,disabled:!h.value.length},null,8,L_),[[dd,o.value,void 0,{trim:!0}]]),G[1]||(G[1]=ie("div",{class:"ipeps-input-icon"},"🔍",-1))]),ie("button",{class:xt(["ipeps-button",{refreshing:a.value}]),onClick:S,disabled:a.value||!p.value,variant:"primary"},ye(a.value?Oe(i)`Refreshing...`:Oe(i)`Refresh`),11,N_)]),!p.value&&!y.value?(de(),ve("div",M_,[G[2]||(G[2]=ie("div",{class:"loading-spinner"},null,-1)),ie("div",D_,ye(Oe(i)`Loading...`),1)])):k.value.length?(de(),ve("div",j_,[(de(!0),ve(We,null,Wo(k.value,K=>(de(),ve("div",{class:xt(["ipeps-item",{installed:u(K._key),broken:K.isBroken}]),key:K._key},[ie("div",U_,[ie("div",F_,[ie("div",q_,ye(K.name||K.id),1),u(K._key)||K.isBroken?(de(),ve("span",{key:0,class:xt(["ipeps-badge",{"is-installed":u(K._key),"is-broken":K.isBroken}])},ye(K.isBroken?Oe(r)`plugin-store.tags.broken`:Oe(r)`plugin-store.tags.installed`),3)):fi("",!0)]),ie("div",B_,[K.registryHomepage&&!K.isRegistryMissing?(de(),ve("a",{key:0,class:"ipeps-tag registry-tag",href:K.registryHomepage,target:"_blank",title:K.registryLabel},ye(K.registryLabel),9,H_)):(de(),ve("span",{key:1,class:xt(["ipeps-tag registry-tag",{broken:K.isRegistryMissing}]),title:K.registryLabel},ye(K.registryLabel),11,z_)),ie("div",{class:xt(["plugin-id ipeps-tag",{broken:K.isBroken&&!K.isRegistryMissing}])},ye(K.id),3)]),ie("div",{class:xt(["plugin-desc",{"broken-desc":K.isBroken}])},ye(P(K)),3),ie("div",W_,[K.version?(de(),ve("span",K_,"v"+ye(K.version),1)):fi("",!0),K.author?(de(),ve("span",V_,"👤 "+ye(K.author),1)):fi("",!0),K.license?(de(),ve("span",G_,"📜 "+ye(K.license),1)):fi("",!0)])]),Ne(fs,{active:u(K._key),variant:u(K._key)?"danger":"primary",onClick:qe=>w(K)},{default:Ar(()=>[Fr(ye(u(K._key)?Oe(i)`Remove`:Oe(i)`Install`),1)]),_:2},1032,["active","variant","onClick"])],2))),128))])):(de(),ve("div",Q_,[G[3]||(G[3]=ie("div",{class:"plugin-empty-icon"},"📦",-1)),ie("div",Y_,ye(Oe(i)`No matching plugins found`),1)]))]))}}),[["__scopeId","data-v-d3aab2b1"]]),J_={id:"ipe-plugin-store-app"},Z_=Object.freeze(Object.defineProperty({__proto__:null,default:ts($i({__name:"PluginStoreApp",setup(t){return(e,i)=>(de(),ve("div",J_,[Ne(X_),i[0]||(i[0]=ie("div",{class:"divider-wrapper"},[ie("hr",{class:"divider"})],-1)),Ne(I_)]))}}),[["__scopeId","data-v-1b3d0d80"]])},Symbol.toStringTag,{value:"Module"}));var e0=Object.create,Oa=Object.defineProperty,t0=Object.getOwnPropertyDescriptor,_f=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),xf=t=>{throw TypeError(t)},i0=(t,e,i)=>e in t?Oa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,r0=(t,e)=>Oa(t,"name",{value:e,configurable:!0}),n0=t=>[,,,e0(t?.[_f("metadata")]??null)],s0=["class","method","getter","setter","accessor","field","value","get","set"],kf=t=>t!==void 0&&typeof t!="function"?xf("Function expected"):t,o0=(t,e,i,r,n)=>({kind:s0[t],name:e,metadata:r,addInitializer:s=>i._?xf("Already initialized"):n.push(kf(s||null))}),a0=(t,e)=>i0(e,_f("metadata"),t[3]),l0=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},c0=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&t0(n,i));r0(n,i);for(var h=r.length-1;h>=0;h--)c=o0(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,kf(o)&&(n=o);return a0(t,n),p&&Oa(n,i,p),u?l^4?s:p:n},Sf,La,Ef;Sf=[xe(["preferences","wiki","wikiPage","wikiTitle","modal","preferencesUI","$"])];class hs extends(Ef=Ue){constructor(e){super(e,{},"pref-sync"),this.ctx=e,e.set("prefSync",this)}start(){const e=this.ctx,i=e.$;e.preferences.defineCategory({name:"pref-sync",label:i`Sync`,description:i`Import and export preferences`,index:98,customRenderer:()=>{const r=this.getUserPrefsPageTitle();return f("div",{className:"theme-ipe-prose",children:[r&&f("section",{children:[f("h3",{children:i`Backup your preferences via user page`}),f("p",{children:f("a",{href:r?.getURL().toString(),target:"_blank",children:[r?.getPrefixedText()," →"]})}),f("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[f(Wr,{type:"primary",onClick:n=>{n.preventDefault();const s=n.target;s.disabled=!0;const o=e.preferencesUI.getCurrentModal();o?.setLoadingState(!0),this.exportToUserPage().then(a=>{e.modal.notify("success",{title:i`Preferences Exported`,content:f("p",{children:["Your preferences have been exported to"," ",f("a",{href:a.getURL().toString(),target:"_blank",children:a.getPrefixedText()}),"."]})})}).finally(()=>{s.disabled=!1,o?.setLoadingState(!1)})},children:[f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-cloud-up",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 18.004h-5.343c-2.572 -.004 -4.657 -2.011 -4.657 -4.487c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.38 0 2.57 .811 3.128 1.986"}),f("path",{d:"M19 22v-6"}),f("path",{d:"M22 19l-3 -3l-3 3"})]})," ",i`Backup`]}),f(Wr,{onClick:n=>{n.preventDefault();const s=e.preferencesUI.getCurrentModal(),o=n.target;o.disabled=!0,s?.setLoadingState(!0),this.importFromUserPage().then(a=>{this.notifyImportSuccess(a)}).finally(()=>{o.disabled=!1,s?.setLoadingState(!1)})},children:[f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-cloud-down",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 18.004h-5.343c-2.572 -.004 -4.657 -2.011 -4.657 -4.487c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.38 0 2.573 .813 3.13 1.99"}),f("path",{d:"M19 16v6"}),f("path",{d:"M22 19l-3 3l-3 -3"})]})," ",i`Restore`]})]})]}),f("section",{children:[f("h3",{children:i`Import and export preferences`}),f("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[f(Wr,{onClick:n=>{n.preventDefault();const s=e.preferencesUI.getCurrentModal();s?.setLoadingState(!0);const o=document.createElement("input");o.type="file",o.accept="application/json";let a=!1;const c=()=>{a||s?.setLoadingState(!1),window.removeEventListener("focus",c)};window.addEventListener("focus",c,{once:!0}),o.addEventListener("change",async l=>{a=!0;try{const u=l.target.files?.[0];if(!u)return;const d=await this.importFromFile(u);this.notifyImportSuccess(d)}catch(u){e.modal.notify("error",{title:"Import failed",content:u instanceof Error?u.message:String(u)})}finally{s?.setLoadingState(!1)}}),o.click()},children:i`Import from file`}),f(Wr,{onClick:n=>{n.preventDefault();const s=f("input",{type:"url",style:{width:"100%"}}),o=e.preferencesUI.getCurrentModal();e.modal.confirm({title:i`Import from URL`,content:f("div",{className:"ipe-input-box",children:[f("label",{htmlFor:"url-input",children:i`Enter the URL of the preferences JSON file:`}),s]})},async a=>{const c=s.value.trim();if(!(!a||!c))try{o?.setLoadingState(!0);const l=await this.importFromUrl(c);this.notifyImportSuccess(l)}catch(l){e.modal.notify("error",{title:"Import failed",content:l instanceof Error?l.message:String(l)})}finally{o?.setLoadingState(!1)}})},children:i`Import from URL`}),f(Wr,{onClick:async n=>{n.preventDefault(),await e.preferencesUI.dispatchFormSave();const s=await e.preferences.getExportableRecord(),o=JSON.stringify(s,null,2);e.modal.dialog({title:i`Save to file`,content:f("div",{children:[f("label",{htmlFor:"data",children:i`Your InPageEdit preferences:`}),f("textarea",{name:"data",id:"data",rows:10,value:o,readOnly:!0,style:{width:"100%"}})]}),buttons:[{label:"Copy",method:(a,c)=>{navigator.clipboard.writeText(o),e.modal.notify("success",{content:i`Copied to clipboard`}),c.close()}},{label:i`Download`,method:(a,c)=>{const l=document.createElement("a");l.href=`data:text/json;charset=utf-8,${encodeURIComponent(o)}`,l.download=`ipe-prefs-${new Date().toISOString()}.json`,l.click(),c.close()}}]},()=>{})},children:i`Save as file`})]})]})]})}})}stop(){}getUserPrefsPageTitle(){try{const e=this.ctx.wiki?.userInfo?.name;return e?this.ctx.wikiTitle.newTitle(`User:${e}/ipe-prefs.json`,2):null}catch{return null}}async importFromUserPage(){const e=this.getUserPrefsPageTitle();if(!e)return this.logger.debug("Cannot get user page title, skipping load"),{};try{const i=e.getURL({action:"raw",ctype:"application/json"}),r=await this.importFromUrl(i.toString());return this.logger.info("Loaded preferences from user page:",e),r}catch(i){return this.logger.error("Failed to load preferences from user page:",i),{}}}async exportToUserPage(){const e=this.ctx,i=this.getUserPrefsPageTitle();if(!i)throw new Error("Cannot get user page title");await e.preferencesUI.dispatchFormSave();const r=await e.preferences.getExportableRecord(),n=JSON.stringify(r,null,2);try{return await this.ctx.wikiPage.newBlankPage({title:i.toString(),ns:2}).edit({text:n,summary:"Update InPageEdit preferences",watchlist:_t.nochange}),this.logger.info("Exported preferences to user page:",i),i}catch(s){throw this.logger.error("Failed to export preferences to user page:",s),s}}async importFromUrl(e){const i=await fetch(e);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);const r=await i.blob();return await this.importFromFile(r)}async importFromFile(e){const i=await e.text(),r=JSON.parse(i);return await this.ctx.preferences.setMany(r)}notifyImportSuccess(e){const{$:i}=this.ctx,r=Object.keys(e??{}),n=r.length;return this.ctx.modal.notify("success",{title:i`Preferences Imported`,content:f("section",{children:[f("p",{children:i({count:n})`Successfully imported {{ count }} {{ count > 1 ? "settings" : "setting" }}:`}),f("ol",{style:{listStyle:"auto",paddingLeft:"1em"},children:r.map(s=>f("li",{children:s},s))})]})})}}La=n0(Ef),hs=c0(La,0,"PluginPrefSync",Sf,hs),l0(La,1,hs);const u0=Object.freeze(Object.defineProperty({__proto__:null,get PluginPrefSync(){return hs}},Symbol.toStringTag,{value:"Module"}));var d0=Object.create,Na=Object.defineProperty,f0=Object.getOwnPropertyDescriptor,$f=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Pf=t=>{throw TypeError(t)},h0=(t,e,i)=>e in t?Na(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,p0=(t,e)=>Na(t,"name",{value:e,configurable:!0}),g0=t=>[,,,d0(t?.[$f("metadata")]??null)],m0=["class","method","getter","setter","accessor","field","value","get","set"],Cf=t=>t!==void 0&&typeof t!="function"?Pf("Function expected"):t,y0=(t,e,i,r,n)=>({kind:m0[t],name:e,metadata:r,addInitializer:s=>i._?Pf("Already initialized"):n.push(Cf(s||null))}),b0=(t,e)=>h0(e,$f("metadata"),t[3]),v0=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},w0=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&f0(n,i));p0(n,i);for(var h=r.length-1;h>=0;h--)c=y0(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,Cf(o)&&(n=o);return b0(t,n),p&&Na(n,i,p),u?l^4?s:p:n},If,Ma,Rf;If=[xe(["modal","$"])];class ps extends(Rf=Ue){constructor(e){super(e,{},"templates-used"),this.ctx=e,e.set("templatesUsed",this)}async start(){this.ctx.on("quick-edit/wiki-page",this._injectQuickEdit.bind(this))}_injectQuickEdit(e){const{$:i}=this.ctx,{wikiPage:r,modal:n}=e;if(!r||!r.pageid)return;const s=this.ctx.quickUsage.getWrapperForQuickEdit(n),o=f("a",{href:`#ipe://quick-usage/templates?title=${r.title}`,onClick:async a=>{a.preventDefault();const c=await this.showModal({wikiPage:r});c&&n.on(n.Event.Close,()=>{c.destroy()})},children:i`Templates Used`});s.appendChild(o)}async showModal(e={}){const{$:i}=this.ctx,r=e.wikiPage||await this.ctx.wikiPage.WikiPage.newFromAnyKind(e);if(!r||!r.pageid)return;const n=this.ctx.modal.show({title:i`Templates Used`,content:f("section",{className:"ipe-quickUsage__templates",children:f("ol",{children:r.templates.map(s=>{const o=this.ctx.wikiTitle.newTitle(s.title,s.ns),a=this.ctx.quickEdit.createQuickEditButton({title:o.toString()},{label:""});return f("li",{children:[f("a",{href:o.getURL().toString(),target:"_blank",rel:"noopener noreferrer",children:o.toString()})," ","(",a,")"]},o.toString())})})}),sizeClass:"dialog",draggable:!0,backdrop:!1});return this.ctx.emit("analytics/event",{feature:"quick-usage",subtype:"templates-used"}),n}}Ma=g0(Rf),ps=w0(Ma,0,"PluginTemplatesUsed",If,ps),v0(Ma,1,ps);const _0=Object.freeze(Object.defineProperty({__proto__:null,get PluginTemplatesUsed(){return ps}},Symbol.toStringTag,{value:"Module"}));var x0=Object.create,Da=Object.defineProperty,k0=Object.getOwnPropertyDescriptor,Af=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Tf=t=>{throw TypeError(t)},S0=(t,e,i)=>e in t?Da(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,E0=(t,e)=>Da(t,"name",{value:e,configurable:!0}),$0=t=>[,,,x0(t?.[Af("metadata")]??null)],P0=["class","method","getter","setter","accessor","field","value","get","set"],Of=t=>t!==void 0&&typeof t!="function"?Tf("Function expected"):t,C0=(t,e,i,r,n)=>({kind:P0[t],name:e,metadata:r,addInitializer:s=>i._?Tf("Already initialized"):n.push(Of(s||null))}),I0=(t,e)=>S0(e,Af("metadata"),t[3]),R0=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},A0=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&k0(n,i));E0(n,i);for(var h=r.length-1;h>=0;h--)c=C0(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,Of(o)&&(n=o);return I0(t,n),p&&Da(n,i,p),u?l^4?s:p:n},Lf,ja,Nf;Lf=[xe(["modal","$"])];class gs extends(Nf=Ue){constructor(e){super(e,{},"images-used"),this.ctx=e}async start(){this.ctx.on("quick-edit/wiki-page",this.injectQuickEdit.bind(this))}injectQuickEdit(e){const{$:i}=this.ctx,{wikiPage:r,modal:n}=e;if(!r||!r.pageid)return;const s=this.ctx.quickUsage.getWrapperForQuickEdit(n),o=f("a",{href:`#ipe://quick-usage/images?title=${r.title}`,onClick:async a=>{a.preventDefault();const c=await this.showModal({wikiPage:r});c&&n.on(n.Event.Close,()=>{c.destroy()})},children:i`Images Used`});s.appendChild(o)}async showModal(e={}){const{$:i}=this.ctx,r=e.wikiPage||await this.ctx.wikiPage.WikiPage.newFromAnyKind(e);if(!r||!r.pageid)return;const n=this.ctx.modal.show({title:i`Images Used`,content:f("section",{className:"ipe-quickUsage__images",children:f("ol",{children:r.images.map(s=>{const o=this.ctx.wikiFile.getFileUrl(s.title);return f("li",{children:[f("a",{href:this.ctx.wiki.getUrl(s.title),target:"_blank",rel:"noopener noreferrer",children:s.title})," ","(",f("a",{href:o,target:"_blank",rel:"noopener noreferrer",onClick:a=>{a.preventDefault(),this.ctx.quickPreview.previewFile(o,s.title)},children:i`Preview`}),")"]},s.title)})})}),sizeClass:"dialog",draggable:!0,backdrop:!1});return this.ctx.emit("analytics/event",{feature:"quick-usage",subtype:"images-used"}),n}}ja=$0(Nf),gs=A0(ja,0,"PluginImagesUsed",Lf,gs),R0(ja,1,gs);const T0=Object.freeze(Object.defineProperty({__proto__:null,get PluginImagesUsed(){return gs}},Symbol.toStringTag,{value:"Module"}));Y.BasePlugin=Ue,Y.CordisSymbols=U,Y.EffectScope=Is,Y.Endpoints=Lt,Y.ForkScope=Ja,Y.InPageEdit=Fi,Y.Inject=xe,Y.Lifecycle=Ya,Y.Logger=tl,Y.LoggerLevel=As,Y.MainScope=Rs,Y.RegisterPreferences=Tt,Y.Schema=R,Y.ScopeStatus=Xa,Y.Service=ht,Y.createLogger=nl,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})}));
35
+ `)}`}))},I=async()=>{y.value=!1;const N=await e.store.ctx.preferences.get("pluginStore.registries")||[],G=await Promise.allSettled(N.map(async K=>({...await e.store.getRegistryInfo(K),registryUrl:K})));n.value=G.filter(K=>K.status==="fulfilled").map(K=>K.value),s.value=await e.preferences.get("pluginStore.plugins")||[],y.value=!0};function F(N){const G=N.changes["pluginStore.registries"],K=N.changes["pluginStore.plugins"];Array.isArray(K)&&(s.value=K),Array.isArray(G)&&I()}return Lr(()=>{I(),e.on("preferences/changed",F)}),zo(()=>{}),(N,G)=>(de(),ve("div",L_,[ie("div",N_,[ie("div",M_,ye(Oe(i)`Plugins`),1),ie("div",D_,[lu(ie("input",{class:"ipeps-input with-icon","onUpdate:modelValue":G[0]||(G[0]=K=>o.value=K),type:"text",placeholder:Oe(i)`Search plugins...`,disabled:!h.value.length},null,8,j_),[[hd,o.value,void 0,{trim:!0}]]),G[1]||(G[1]=ie("div",{class:"ipeps-input-icon"},"🔍",-1))]),ie("button",{class:xt(["ipeps-button",{refreshing:a.value}]),onClick:S,disabled:a.value||!p.value,variant:"primary"},ye(a.value?Oe(i)`Refreshing...`:Oe(i)`Refresh`),11,U_)]),!p.value&&!y.value?(de(),ve("div",F_,[G[2]||(G[2]=ie("div",{class:"loading-spinner"},null,-1)),ie("div",q_,ye(Oe(i)`Loading...`),1)])):k.value.length?(de(),ve("div",B_,[(de(!0),ve(We,null,Ko(k.value,K=>(de(),ve("div",{class:xt(["ipeps-item",{installed:u(K._key),broken:K.isBroken}]),key:K._key},[ie("div",H_,[ie("div",z_,[ie("div",W_,ye(K.name||K.id),1),u(K._key)||K.isBroken?(de(),ve("span",{key:0,class:xt(["ipeps-badge",{"is-installed":u(K._key),"is-broken":K.isBroken}])},ye(K.isBroken?Oe(r)`plugin-store.tags.broken`:Oe(r)`plugin-store.tags.installed`),3)):fi("",!0)]),ie("div",K_,[K.registryHomepage&&!K.isRegistryMissing?(de(),ve("a",{key:0,class:"ipeps-tag registry-tag",href:K.registryHomepage,target:"_blank",title:K.registryLabel},ye(K.registryLabel),9,V_)):(de(),ve("span",{key:1,class:xt(["ipeps-tag registry-tag",{broken:K.isRegistryMissing}]),title:K.registryLabel},ye(K.registryLabel),11,G_)),ie("div",{class:xt(["plugin-id ipeps-tag",{broken:K.isBroken&&!K.isRegistryMissing}])},ye(K.id),3)]),ie("div",{class:xt(["plugin-desc",{"broken-desc":K.isBroken}])},ye(P(K)),3),ie("div",Q_,[K.version?(de(),ve("span",Y_,"v"+ye(K.version),1)):fi("",!0),K.author?(de(),ve("span",X_,"👤 "+ye(K.author),1)):fi("",!0),K.license?(de(),ve("span",J_,"📜 "+ye(K.license),1)):fi("",!0)])]),Ne(fs,{active:u(K._key),variant:u(K._key)?"danger":"primary",onClick:qe=>w(K)},{default:Rr(()=>[Fr(ye(u(K._key)?Oe(i)`Remove`:Oe(i)`Install`),1)]),_:2},1032,["active","variant","onClick"])],2))),128))])):(de(),ve("div",Z_,[G[3]||(G[3]=ie("div",{class:"plugin-empty-icon"},"📦",-1)),ie("div",e0,ye(Oe(i)`No matching plugins found`),1)]))]))}}),[["__scopeId","data-v-d3aab2b1"]]),i0={id:"ipe-plugin-store-app"},r0=Object.freeze(Object.defineProperty({__proto__:null,default:ts($i({__name:"PluginStoreApp",setup(t){return(e,i)=>(de(),ve("div",i0,[Ne(t0),i[0]||(i[0]=ie("div",{class:"divider-wrapper"},[ie("hr",{class:"divider"})],-1)),Ne(O_)]))}}),[["__scopeId","data-v-1b3d0d80"]])},Symbol.toStringTag,{value:"Module"}));var n0=Object.create,La=Object.defineProperty,s0=Object.getOwnPropertyDescriptor,kf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Sf=t=>{throw TypeError(t)},o0=(t,e,i)=>e in t?La(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,a0=(t,e)=>La(t,"name",{value:e,configurable:!0}),l0=t=>[,,,n0(t?.[kf("metadata")]??null)],c0=["class","method","getter","setter","accessor","field","value","get","set"],Ef=t=>t!==void 0&&typeof t!="function"?Sf("Function expected"):t,u0=(t,e,i,r,n)=>({kind:c0[t],name:e,metadata:r,addInitializer:s=>i._?Sf("Already initialized"):n.push(Ef(s||null))}),d0=(t,e)=>o0(e,kf("metadata"),t[3]),f0=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},h0=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&s0(n,i));a0(n,i);for(var h=r.length-1;h>=0;h--)c=u0(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,Ef(o)&&(n=o);return d0(t,n),p&&La(n,i,p),u?l^4?s:p:n},$f,Na,Pf;$f=[xe(["preferences","wiki","wikiPage","wikiTitle","modal","preferencesUI","$"])];class hs extends(Pf=Ue){constructor(e){super(e,{},"pref-sync"),this.ctx=e,e.set("prefSync",this)}start(){const e=this.ctx,i=e.$;e.preferences.defineCategory({name:"pref-sync",label:i`Sync`,description:i`Import and export preferences`,index:98,customRenderer:()=>{const r=this.getUserPrefsPageTitle();return f("div",{className:"theme-ipe-prose",children:[r&&f("section",{children:[f("h3",{children:i`Backup your preferences via user page`}),f("p",{children:f("a",{href:r?.getURL().toString(),target:"_blank",children:[r?.getPrefixedText()," →"]})}),f("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[f(Wr,{type:"primary",onClick:n=>{n.preventDefault();const s=n.target;s.disabled=!0;const o=e.preferencesUI.getCurrentModal();o?.setLoadingState(!0),this.exportToUserPage().then(a=>{e.modal.notify("success",{title:i`Preferences Exported`,content:f("p",{children:["Your preferences have been exported to"," ",f("a",{href:a.getURL().toString(),target:"_blank",children:a.getPrefixedText()}),"."]})})}).finally(()=>{s.disabled=!1,o?.setLoadingState(!1)})},children:[f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-cloud-up",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 18.004h-5.343c-2.572 -.004 -4.657 -2.011 -4.657 -4.487c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.38 0 2.57 .811 3.128 1.986"}),f("path",{d:"M19 22v-6"}),f("path",{d:"M22 19l-3 -3l-3 3"})]})," ",i`Backup`]}),f(Wr,{onClick:n=>{n.preventDefault();const s=e.preferencesUI.getCurrentModal(),o=n.target;o.disabled=!0,s?.setLoadingState(!0),this.importFromUserPage().then(a=>{this.notifyImportSuccess(a)}).finally(()=>{o.disabled=!1,s?.setLoadingState(!1)})},children:[f("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-cloud-down",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 18.004h-5.343c-2.572 -.004 -4.657 -2.011 -4.657 -4.487c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.38 0 2.573 .813 3.13 1.99"}),f("path",{d:"M19 16v6"}),f("path",{d:"M22 19l-3 3l-3 -3"})]})," ",i`Restore`]})]})]}),f("section",{children:[f("h3",{children:i`Import and export preferences`}),f("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[f(Wr,{onClick:n=>{n.preventDefault();const s=e.preferencesUI.getCurrentModal();s?.setLoadingState(!0);const o=document.createElement("input");o.type="file",o.accept="application/json";let a=!1;const c=()=>{a||s?.setLoadingState(!1),window.removeEventListener("focus",c)};window.addEventListener("focus",c,{once:!0}),o.addEventListener("change",async l=>{a=!0;try{const u=l.target.files?.[0];if(!u)return;const d=await this.importFromFile(u);this.notifyImportSuccess(d)}catch(u){e.modal.notify("error",{title:"Import failed",content:u instanceof Error?u.message:String(u)})}finally{s?.setLoadingState(!1)}}),o.click()},children:i`Import from file`}),f(Wr,{onClick:n=>{n.preventDefault();const s=f("input",{type:"url",style:{width:"100%"}}),o=e.preferencesUI.getCurrentModal();e.modal.confirm({title:i`Import from URL`,content:f("div",{className:"ipe-input-box",children:[f("label",{htmlFor:"url-input",children:i`Enter the URL of the preferences JSON file:`}),s]})},async a=>{const c=s.value.trim();if(!(!a||!c))try{o?.setLoadingState(!0);const l=await this.importFromUrl(c);this.notifyImportSuccess(l)}catch(l){e.modal.notify("error",{title:"Import failed",content:l instanceof Error?l.message:String(l)})}finally{o?.setLoadingState(!1)}})},children:i`Import from URL`}),f(Wr,{onClick:async n=>{n.preventDefault(),await e.preferencesUI.dispatchFormSave();const s=await e.preferences.getExportableRecord(),o=JSON.stringify(s,null,2);e.modal.dialog({title:i`Save to file`,content:f("div",{children:[f("label",{htmlFor:"data",children:i`Your InPageEdit preferences:`}),f("textarea",{name:"data",id:"data",rows:10,value:o,readOnly:!0,style:{width:"100%"}})]}),buttons:[{label:"Copy",method:(a,c)=>{navigator.clipboard.writeText(o),e.modal.notify("success",{content:i`Copied to clipboard`}),c.close()}},{label:i`Download`,method:(a,c)=>{const l=document.createElement("a");l.href=`data:text/json;charset=utf-8,${encodeURIComponent(o)}`,l.download=`ipe-prefs-${new Date().toISOString()}.json`,l.click(),c.close()}}]},()=>{})},children:i`Save as file`})]})]})]})}})}stop(){}getUserPrefsPageTitle(){try{const e=this.ctx.wiki?.userInfo?.name;return e?this.ctx.wikiTitle.newTitle(`User:${e}/ipe-prefs.json`,2):null}catch{return null}}async importFromUserPage(){const e=this.getUserPrefsPageTitle();if(!e)return this.logger.debug("Cannot get user page title, skipping load"),{};try{const i=e.getURL({action:"raw",ctype:"application/json"}),r=await this.importFromUrl(i.toString());return this.logger.info("Loaded preferences from user page:",e),r}catch(i){return this.logger.error("Failed to load preferences from user page:",i),{}}}async exportToUserPage(){const e=this.ctx,i=this.getUserPrefsPageTitle();if(!i)throw new Error("Cannot get user page title");await e.preferencesUI.dispatchFormSave();const r=await e.preferences.getExportableRecord(),n=JSON.stringify(r,null,2);try{return await this.ctx.wikiPage.newBlankPage({title:i.toString(),ns:2}).edit({text:n,summary:"Update InPageEdit preferences",watchlist:_t.nochange}),this.logger.info("Exported preferences to user page:",i),i}catch(s){throw this.logger.error("Failed to export preferences to user page:",s),s}}async importFromUrl(e){const i=await fetch(e);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);const r=await i.blob();return await this.importFromFile(r)}async importFromFile(e){const i=await e.text(),r=JSON.parse(i);return await this.ctx.preferences.setMany(r)}notifyImportSuccess(e){const{$:i}=this.ctx,r=Object.keys(e??{}),n=r.length;return this.ctx.modal.notify("success",{title:i`Preferences Imported`,content:f("section",{children:[f("p",{children:i({count:n})`Successfully imported {{ count }} {{ count > 1 ? "settings" : "setting" }}:`}),f("ol",{style:{listStyle:"auto",paddingLeft:"1em"},children:r.map(s=>f("li",{children:s},s))})]})})}}Na=l0(Pf),hs=h0(Na,0,"PluginPrefSync",$f,hs),f0(Na,1,hs);const p0=Object.freeze(Object.defineProperty({__proto__:null,get PluginPrefSync(){return hs}},Symbol.toStringTag,{value:"Module"}));var g0=Object.create,Ma=Object.defineProperty,m0=Object.getOwnPropertyDescriptor,Cf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),If=t=>{throw TypeError(t)},y0=(t,e,i)=>e in t?Ma(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,b0=(t,e)=>Ma(t,"name",{value:e,configurable:!0}),v0=t=>[,,,g0(t?.[Cf("metadata")]??null)],w0=["class","method","getter","setter","accessor","field","value","get","set"],Af=t=>t!==void 0&&typeof t!="function"?If("Function expected"):t,_0=(t,e,i,r,n)=>({kind:w0[t],name:e,metadata:r,addInitializer:s=>i._?If("Already initialized"):n.push(Af(s||null))}),x0=(t,e)=>y0(e,Cf("metadata"),t[3]),k0=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},S0=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&m0(n,i));b0(n,i);for(var h=r.length-1;h>=0;h--)c=_0(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,Af(o)&&(n=o);return x0(t,n),p&&Ma(n,i,p),u?l^4?s:p:n},Rf,Da,Tf;Rf=[xe(["modal","$"])];class ps extends(Tf=Ue){constructor(e){super(e,{},"templates-used"),this.ctx=e,e.set("templatesUsed",this)}async start(){this.ctx.on("quick-edit/wiki-page",this._injectQuickEdit.bind(this))}_injectQuickEdit(e){const{$:i}=this.ctx,{wikiPage:r,modal:n}=e;if(!r||!r.pageid)return;const s=this.ctx.quickUsage.getWrapperForQuickEdit(n),o=f("a",{href:`#ipe://quick-usage/templates?title=${r.title}`,onClick:async a=>{a.preventDefault();const c=await this.showModal({wikiPage:r});c&&n.on(n.Event.Close,()=>{c.destroy()})},children:i`Templates Used`});s.appendChild(o)}async showModal(e={}){const{$:i}=this.ctx,r=e.wikiPage||await this.ctx.wikiPage.WikiPage.newFromAnyKind(e);if(!r||!r.pageid)return;const n=this.ctx.modal.show({title:i`Templates Used`,content:f("section",{className:"ipe-quickUsage__templates",children:f("ol",{children:r.templates.map(s=>{const o=this.ctx.wikiTitle.newTitle(s.title,s.ns),a=this.ctx.quickEdit.createQuickEditButton({title:o.toString()},{label:""});return f("li",{children:[f("a",{href:o.getURL().toString(),target:"_blank",rel:"noopener noreferrer",children:o.toString()})," ","(",a,")"]},o.toString())})})}),sizeClass:"dialog",draggable:!0,backdrop:!1});return this.ctx.emit("analytics/event",{feature:"quick-usage",subtype:"templates-used"}),n}}Da=v0(Tf),ps=S0(Da,0,"PluginTemplatesUsed",Rf,ps),k0(Da,1,ps);const E0=Object.freeze(Object.defineProperty({__proto__:null,get PluginTemplatesUsed(){return ps}},Symbol.toStringTag,{value:"Module"}));var $0=Object.create,ja=Object.defineProperty,P0=Object.getOwnPropertyDescriptor,Of=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Lf=t=>{throw TypeError(t)},C0=(t,e,i)=>e in t?ja(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,I0=(t,e)=>ja(t,"name",{value:e,configurable:!0}),A0=t=>[,,,$0(t?.[Of("metadata")]??null)],R0=["class","method","getter","setter","accessor","field","value","get","set"],Nf=t=>t!==void 0&&typeof t!="function"?Lf("Function expected"):t,T0=(t,e,i,r,n)=>({kind:R0[t],name:e,metadata:r,addInitializer:s=>i._?Lf("Already initialized"):n.push(Nf(s||null))}),O0=(t,e)=>C0(e,Of("metadata"),t[3]),L0=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},N0=(t,e,i,r,n,s)=>{var o,a,c,l=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=l&&(n=n.prototype,l<5&&(l>3||!u)&&P0(n,i));I0(n,i);for(var h=r.length-1;h>=0;h--)c=T0(l,i,a={},t[3],y),o=(0,r[h])(n,c),a._=1,Nf(o)&&(n=o);return O0(t,n),p&&ja(n,i,p),u?l^4?s:p:n},Mf,Ua,Df;Mf=[xe(["modal","$"])];class gs extends(Df=Ue){constructor(e){super(e,{},"images-used"),this.ctx=e}async start(){this.ctx.on("quick-edit/wiki-page",this.injectQuickEdit.bind(this))}injectQuickEdit(e){const{$:i}=this.ctx,{wikiPage:r,modal:n}=e;if(!r||!r.pageid)return;const s=this.ctx.quickUsage.getWrapperForQuickEdit(n),o=f("a",{href:`#ipe://quick-usage/images?title=${r.title}`,onClick:async a=>{a.preventDefault();const c=await this.showModal({wikiPage:r});c&&n.on(n.Event.Close,()=>{c.destroy()})},children:i`Images Used`});s.appendChild(o)}async showModal(e={}){const{$:i}=this.ctx,r=e.wikiPage||await this.ctx.wikiPage.WikiPage.newFromAnyKind(e);if(!r||!r.pageid)return;const n=this.ctx.modal.show({title:i`Images Used`,content:f("section",{className:"ipe-quickUsage__images",children:f("ol",{children:r.images.map(s=>{const o=this.ctx.wikiFile.getFileUrl(s.title);return f("li",{children:[f("a",{href:this.ctx.wiki.getUrl(s.title),target:"_blank",rel:"noopener noreferrer",children:s.title})," ","(",f("a",{href:o,target:"_blank",rel:"noopener noreferrer",onClick:a=>{a.preventDefault(),this.ctx.quickPreview.previewFile(o,s.title)},children:i`Preview`}),")"]},s.title)})})}),sizeClass:"dialog",draggable:!0,backdrop:!1});return this.ctx.emit("analytics/event",{feature:"quick-usage",subtype:"images-used"}),n}}Ua=A0(Df),gs=N0(Ua,0,"PluginImagesUsed",Mf,gs),L0(Ua,1,gs);const M0=Object.freeze(Object.defineProperty({__proto__:null,get PluginImagesUsed(){return gs}},Symbol.toStringTag,{value:"Module"}));Y.BasePlugin=Ue,Y.CordisSymbols=U,Y.EffectScope=Is,Y.Endpoints=Lt,Y.ForkScope=Za,Y.InPageEdit=Fi,Y.Inject=xe,Y.Lifecycle=Xa,Y.Logger=il,Y.LoggerLevel=Rs,Y.MainScope=As,Y.RegisterPreferences=Tt,Y.Schema=A,Y.ScopeStatus=Ja,Y.Service=ht,Y.createLogger=sl,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})}));
36
36
  //# sourceMappingURL=index.umd.js.map