@inpageedit/core 0.15.0 → 0.16.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 (100) hide show
  1. package/dist/{ActionButton-CRjo_l3y.js → ActionButton-B6OUgtHx.js} +2 -2
  2. package/dist/{ActionButton-CRjo_l3y.js.map → ActionButton-B6OUgtHx.js.map} +1 -1
  3. package/dist/CheckBox-Dx3r3LQz.js +13 -0
  4. package/dist/CheckBox-Dx3r3LQz.js.map +1 -0
  5. package/dist/IconQuickDiff-BkbxyY-d.js +29 -0
  6. package/dist/IconQuickDiff-BkbxyY-d.js.map +1 -0
  7. package/dist/IconQuickEdit-BiRYADU_.js +68 -0
  8. package/dist/IconQuickEdit-BiRYADU_.js.map +1 -0
  9. package/dist/IconUpload-Bz4BW_nc.js +27 -0
  10. package/dist/IconUpload-Bz4BW_nc.js.map +1 -0
  11. package/dist/InPageEdit.js +20 -0
  12. package/dist/InPageEdit.js.map +1 -0
  13. package/dist/InputBox-D2ZRTMFP.js +42 -0
  14. package/dist/InputBox-D2ZRTMFP.js.map +1 -0
  15. package/dist/{PluginImagesUsed-Bq_C_rgg.js → PluginImagesUsed-BVyvFA1_.js} +7 -7
  16. package/dist/{PluginImagesUsed-Bq_C_rgg.js.map → PluginImagesUsed-BVyvFA1_.js.map} +1 -1
  17. package/dist/{PluginPrefSync-DP5NyPnI.js → PluginPrefSync-CUKkx4Qk.js} +10 -10
  18. package/dist/{PluginPrefSync-DP5NyPnI.js.map → PluginPrefSync-CUKkx4Qk.js.map} +1 -1
  19. package/dist/{PluginStoreApp-_YWpLgfs.js → PluginStoreApp-CoOAw1fr.js} +4 -4
  20. package/dist/{PluginStoreApp-_YWpLgfs.js.map → PluginStoreApp-CoOAw1fr.js.map} +1 -1
  21. package/dist/{PluginTemplatesUsed-DS_rHctR.js → PluginTemplatesUsed-CdjT1wR4.js} +12 -12
  22. package/dist/{PluginTemplatesUsed-DS_rHctR.js.map → PluginTemplatesUsed-CdjT1wR4.js.map} +1 -1
  23. package/dist/{index-CM_6yF2v.js → Promise.withResolvers-C4chhLB1.js} +17 -11
  24. package/dist/Promise.withResolvers-C4chhLB1.js.map +1 -0
  25. package/dist/{RadioBox-0UuxlcWZ.js → RadioBox-B0z9YHQg.js} +2 -2
  26. package/dist/{RadioBox-0UuxlcWZ.js.map → RadioBox-B0z9YHQg.js.map} +1 -1
  27. package/dist/components/index.js +75 -46
  28. package/dist/components/index.js.map +1 -1
  29. package/dist/{BasePlugin-BCVSn9QJ.js → core.js} +28 -10
  30. package/dist/core.js.map +1 -0
  31. package/dist/{index-n5KKWE9v.js → index-1tsXE6ax.js} +9 -8
  32. package/dist/{index-n5KKWE9v.js.map → index-1tsXE6ax.js.map} +1 -1
  33. package/dist/{index-CS1kidKF.js → index-B32tFyLB.js} +57 -57
  34. package/dist/{index-CS1kidKF.js.map → index-B32tFyLB.js.map} +1 -1
  35. package/dist/{index-Cq8xPcEY.js → index-BPTMltVf.js} +35 -35
  36. package/dist/index-BPTMltVf.js.map +1 -0
  37. package/dist/{index-rKL4D_7I.js → index-BYlcHc-O.js} +22 -24
  38. package/dist/index-BYlcHc-O.js.map +1 -0
  39. package/dist/{index-DjyjqpeO.js → index-C4qm_X_A.js} +11 -11
  40. package/dist/{index-DjyjqpeO.js.map → index-C4qm_X_A.js.map} +1 -1
  41. package/dist/index-CAtPo7xJ.js +793 -0
  42. package/dist/index-CAtPo7xJ.js.map +1 -0
  43. package/dist/{index-DPA1ptYq.js → index-CVCy0wPP.js} +8 -7
  44. package/dist/{index-DPA1ptYq.js.map → index-CVCy0wPP.js.map} +1 -1
  45. package/dist/index-CYfkwXRf.js +1631 -0
  46. package/dist/index-CYfkwXRf.js.map +1 -0
  47. package/dist/{index-mFwJhDwE.js → index-DZa9mxN4.js} +11 -11
  48. package/dist/{index-mFwJhDwE.js.map → index-DZa9mxN4.js.map} +1 -1
  49. package/dist/{index-B9VO3swL.js → index-Dm2vgYkZ.js} +58 -81
  50. package/dist/index-Dm2vgYkZ.js.map +1 -0
  51. package/dist/{index-C3t-Xj3e.js → index-NWWeW3tX.js} +10 -10
  52. package/dist/{index-C3t-Xj3e.js.map → index-NWWeW3tX.js.map} +1 -1
  53. package/dist/index-QnWieXQc.js +4932 -0
  54. package/dist/index-QnWieXQc.js.map +1 -0
  55. package/dist/{index-CbdkXGs7.js → index-bQ0CVu3l.js} +13 -17
  56. package/dist/{index-CbdkXGs7.js.map → index-bQ0CVu3l.js.map} +1 -1
  57. package/dist/{index-Cb2_vqBl.js → index-ygc4AMy4.js} +10 -10
  58. package/dist/{index-Cb2_vqBl.js.map → index-ygc4AMy4.js.map} +1 -1
  59. package/dist/{index-DD5CVCfD.js → index-z_qDGCMT.js} +2 -2
  60. package/dist/{index-DD5CVCfD.js.map → index-z_qDGCMT.js.map} +1 -1
  61. package/dist/index.d.ts +98 -36
  62. package/dist/index.js +24 -26
  63. package/dist/index.js.map +1 -1
  64. package/dist/{makeCallable-LDU0xZMJ.js → makeCallable-Cg4zUG4c.js} +2 -2
  65. package/dist/{makeCallable-LDU0xZMJ.js.map → makeCallable-Cg4zUG4c.js.map} +1 -1
  66. package/dist/models/index.js +7 -7
  67. package/dist/models/index.js.map +1 -1
  68. package/dist/plugins/index.js +12 -12
  69. package/dist/services/index.js +5 -4
  70. package/dist/style.css +1 -1
  71. package/dist/{vueHooks-l04s8cIl.js → vueHooks-Bs93iP61.js} +1519 -1492
  72. package/dist/vueHooks-Bs93iP61.js.map +1 -0
  73. package/lib/index.umd.js +19 -15
  74. package/lib/index.umd.js.map +1 -1
  75. package/lib/style.css +1 -1
  76. package/package.json +36 -27
  77. package/dist/BasePlugin-BCVSn9QJ.js.map +0 -1
  78. package/dist/IconQuickEdit-CMCQncyj.js +0 -27
  79. package/dist/IconQuickEdit-CMCQncyj.js.map +0 -1
  80. package/dist/InputBox-CZ1v4_l3.js +0 -50
  81. package/dist/InputBox-CZ1v4_l3.js.map +0 -1
  82. package/dist/Preferences-DqtjY7XU.js +0 -1541
  83. package/dist/Preferences-DqtjY7XU.js.map +0 -1
  84. package/dist/WatchlistAction-BbNAyryN.js +0 -5
  85. package/dist/WatchlistAction-BbNAyryN.js.map +0 -1
  86. package/dist/browser-DR-yCqVg.js +0 -1160
  87. package/dist/browser-DR-yCqVg.js.map +0 -1
  88. package/dist/index-B9VO3swL.js.map +0 -1
  89. package/dist/index-CG38LlAh.js +0 -46
  90. package/dist/index-CG38LlAh.js.map +0 -1
  91. package/dist/index-CM_6yF2v.js.map +0 -1
  92. package/dist/index-CcAmmXbb.js +0 -3290
  93. package/dist/index-CcAmmXbb.js.map +0 -1
  94. package/dist/index-Cq8xPcEY.js.map +0 -1
  95. package/dist/index-DVvsTsLI.js +0 -505
  96. package/dist/index-DVvsTsLI.js.map +0 -1
  97. package/dist/index-FvMu0Ka0.js +0 -342
  98. package/dist/index-FvMu0Ka0.js.map +0 -1
  99. package/dist/index-rKL4D_7I.js.map +0 -1
  100. package/dist/vueHooks-l04s8cIl.js.map +0 -1
package/lib/index.umd.js CHANGED
@@ -1,7 +1,7 @@
1
- (function(W,re){typeof exports=="object"&&typeof module<"u"?re(exports):typeof define=="function"&&define.amd?define(["exports"],re):(W=typeof globalThis<"u"?globalThis:W||self,re(W.InPageEditBundle={}))})(this,(function(W){"use strict";var g0=Object.defineProperty;var Pf=W=>{throw TypeError(W)};var m0=(W,re,Pe)=>re in W?g0(W,re,{enumerable:!0,configurable:!0,writable:!0,value:Pe}):W[re]=Pe;var B=(W,re,Pe)=>m0(W,typeof re!="symbol"?re+"":re,Pe),Ca=(W,re,Pe)=>re.has(W)||Pf("Cannot "+Pe);var ae=(W,re,Pe)=>(Ca(W,re,"read from private field"),Pe?Pe.call(W):re.get(W)),Qi=(W,re,Pe)=>re.has(W)?Pf("Cannot add the same private member more than once"):re instanceof WeakSet?re.add(W):re.set(W,Pe),Le=(W,re,Pe,V)=>(Ca(W,re,"write to private field"),V?V.call(W,Pe):re.set(W,Pe),Pe),ot=(W,re,Pe)=>(Ca(W,re,"access private method"),Pe);var ut,Hi,_i,zi,Ki,Wi,Vi,$e,rt,Ye,Ra,Of,Ia,Tf,Lf,dt,Nf,Mf,Df,jf,Uf,jn,bt,xi;const re=()=>{let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};Promise.withResolvers||(Promise.withResolvers=re);var Pe=Object.defineProperty,V=(t,e)=>Pe(t,"name",{value:e,configurable:!0});function Ff(){}V(Ff,"noop");function we(t){return t==null}V(we,"isNullable");function Bf(t){return!we(t)}V(Bf,"isNonNullable");function qn(t){return t&&typeof t=="object"&&!Array.isArray(t)}V(qn,"isPlainObject");function Aa(t,e){return Object.fromEntries(Object.entries(t).filter(([i,n])=>e(i,n)))}V(Aa,"filterKeys");function Dt(t,e){return Object.fromEntries(Object.entries(t).map(([i,n])=>[i,e(n,i)]))}V(Dt,"mapValues");function Oa(t,e,i){if(!e)return{...t};const n={};for(const r of e)(i||t[r]!==void 0)&&(n[r]=t[r]);return n}V(Oa,"pick");function qf(t,e){if(!e)return{...t};const i={...t};for(const n of e)Reflect.deleteProperty(i,n);return i}V(qf,"omit");function Ne(t,e,i){return Object.defineProperty(t,e,{writable:!0,value:i,enumerable:!1})}V(Ne,"defineProperty");function Hf(t,e){return e.every(i=>t.includes(i))}V(Hf,"contain");function zf(t,e){return t.filter(i=>e.includes(i))}V(zf,"intersection");function Kf(t,e){return t.filter(i=>!e.includes(i))}V(Kf,"difference");function Wf(t,e){return Array.from(new Set([...t,...e]))}V(Wf,"union");function Vf(t){return[...new Set(t)]}V(Vf,"deduplicate");function Gt(t,e){const i=t?.indexOf(e);return i>=0?(t.splice(i,1),!0):!1}V(Gt,"remove");function Gf(t){return Array.isArray(t)?t:we(t)?[]:[t]}V(Gf,"makeArray");function Qt(t,e){return arguments.length===1?i=>Qt(t,i):t in globalThis&&e instanceof globalThis[t]||Object.prototype.toString.call(e).slice(8,-1)===t}V(Qt,"is");function Yi(t){return Qt("ArrayBuffer",t)||Qt("SharedArrayBuffer",t)}V(Yi,"isArrayBufferLike");function Ta(t){return Yi(t)||ArrayBuffer.isView(t)}V(Ta,"isArrayBufferSource");var vt;(t=>{t.is=Yi,t.isSource=Ta;function e(o){return ArrayBuffer.isView(o)?o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength):o}t.fromSource=e,V(e,"fromSource");function i(o){if(typeof Buffer<"u")return Buffer.from(o).toString("base64");let a="";const l=new Uint8Array(o);for(let c=0;c<l.byteLength;c++)a+=String.fromCharCode(l[c]);return btoa(a)}t.toBase64=i,V(i,"toBase64");function n(o){return typeof Buffer<"u"?e(Buffer.from(o,"base64")):Uint8Array.from(atob(o),a=>a.charCodeAt(0))}t.fromBase64=n,V(n,"fromBase64");function r(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=r,V(r,"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),l=[];for(let c=0;c<a.length;c+=2)l.push(parseInt(`${a[c]}${a[c+1]}`,16));return Uint8Array.from(l).buffer}t.fromHex=s,V(s,"fromHex")})(vt||(vt={})),vt.fromBase64,vt.toBase64,vt.fromHex,vt.toHex;function Hn(t,e=new Map){if(!t||typeof t!="object")return t;if(Qt("Date",t))return new Date(t.valueOf());if(Qt("RegExp",t))return new RegExp(t.source,t.flags);if(Yi(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 r=[];return e.set(t,r),t.forEach((s,o)=>{r[o]=Reflect.apply(Hn,null,[s,e])}),r}const n=Object.create(Object.getPrototypeOf(t));e.set(t,n);for(const r of Reflect.ownKeys(t)){const s={...Reflect.getOwnPropertyDescriptor(t,r)};"value"in s&&(s.value=Reflect.apply(Hn,null,[s.value,e])),Reflect.defineProperty(n,r,s)}return n}V(Hn,"clone");function si(t,e,i){if(t===e||!i&&we(t)&&we(e))return!0;if(typeof t!=typeof e||typeof t!="object"||!t||!e)return!1;function n(r,s){return r(t)?r(e)?s(t,e):!1:r(e)?!1:void 0}return V(n,"check"),n(Array.isArray,(r,s)=>r.length===s.length&&r.every((o,a)=>si(o,s[a])))??n(Qt("Date"),(r,s)=>r.valueOf()===s.valueOf())??n(Qt("RegExp"),(r,s)=>r.source===s.source&&r.flags===s.flags)??n(Yi,(r,s)=>{if(r.byteLength!==s.byteLength)return!1;const o=new Uint8Array(r),a=new Uint8Array(s);for(let l=0;l<o.length;l++)if(o[l]!==a[l])return!1;return!0})??Object.keys({...t,...e}).every(r=>si(t[r],e[r],i))}V(si,"deepEqual");function Qf(t){return t.charAt(0).toUpperCase()+t.slice(1)}V(Qf,"capitalize");function Yf(t){return t.charAt(0).toLowerCase()+t.slice(1)}V(Yf,"uncapitalize");function Xf(t){return t.replace(/[_-][a-z]/g,e=>e.slice(1).toUpperCase())}V(Xf,"camelCase");function ls(t,e,i){const n=[];let r=0;for(let s=0;s<t.length;s++){const o=t.charCodeAt(s);if(o>=65&&o<=90){if(r===1){const a=t.charCodeAt(s+1);a>=97&&a<=122&&n.push(i),n.push(o+32)}else r!==0&&n.push(i),n.push(o+32);r=1}else o>=97&&o<=122?(n.push(o),r=2):e.includes(o)?(r!==0&&n.push(i),r=0):n.push(o)}return String.fromCharCode(...n)}V(ls,"tokenize");function Jf(t){return ls(t,[45,95],45)}V(Jf,"paramCase");function Zf(t){return ls(t,[45,95],95)}V(Zf,"snakeCase");function eh(t){return typeof t!="string"?`[${t.toString()}]`:/^[a-z_$][\w$]*$/i.test(t)?`.${t}`:`[${JSON.stringify(t)}]`}V(eh,"formatProperty");function La(t){return t.replace(/\/$/,"")}V(La,"trimSlash");function th(t){return t.startsWith("/")||(t="/"+t),La(t)}V(th,"sanitize");var Na;(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,V(i,"setTimezoneOffset");function n(){return e}t.getTimezoneOffset=n,V(n,"getTimezoneOffset");function r(p=new Date,f){return typeof p=="number"&&(p=new Date(p)),f===void 0&&(f=e),Math.floor((p.valueOf()/t.minute-f)/1440)}t.getDateNumber=r,V(r,"getDateNumber");function s(p,f){const w=new Date(p*t.day);return f===void 0&&(f=e),new Date(+w+f*t.minute)}t.fromDateNumber=s,V(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 l(p){const f=a.exec(p);return f?(parseFloat(f[1])*t.week||0)+(parseFloat(f[2])*t.day||0)+(parseFloat(f[3])*t.hour||0)+(parseFloat(f[4])*t.minute||0)+(parseFloat(f[5])*t.second||0):0}t.parseTime=l,V(l,"parseTime");function c(p){const f=l(p);return f?p=Date.now()+f:/^\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=c,V(c,"parseDate");function u(p){const f=Math.abs(p);return f>=t.day-t.hour/2?Math.round(p/t.day)+"d":f>=t.hour-t.minute/2?Math.round(p/t.hour)+"h":f>=t.minute-t.second/2?Math.round(p/t.minute)+"m":f>=t.second?Math.round(p/t.second)+"s":p+"ms"}t.format=u,V(u,"format");function d(p,f=2){return p.toString().padStart(f,"0")}t.toDigits=d,V(d,"toDigits");function y(p,f=new Date){return p.replace("yyyy",f.getFullYear().toString()).replace("yy",f.getFullYear().toString().slice(2)).replace("MM",d(f.getMonth()+1)).replace("dd",d(f.getDate())).replace("hh",d(f.getHours())).replace("mm",d(f.getMinutes())).replace("ss",d(f.getSeconds())).replace("SSS",d(f.getMilliseconds(),3))}t.template=y,V(y,"template")})(Na||(Na={}));var ih=Object.defineProperty,G=(t,e)=>ih(t,"name",{value:e,configurable:!0}),D={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")},nh=function*(){}.constructor,Ma=async function*(){}.constructor;function cs(t){return!(!t.prototype||t instanceof nh||Ma!==Function&&t instanceof Ma)}G(cs,"isConstructor");function Xi(t,e){const i=t.Config||t.schema;return i&&t.schema!==!1&&(e=i(e)),e??{}}G(Xi,"resolveConfig");function Da(t){return[Map,Set,Date,Promise].some(e=>t instanceof e)}G(Da,"isUnproxyable");function us(t,e){if(t===Object.prototype)return e;const i=Object.create(us(Object.getPrototypeOf(t),e));for(const n of Reflect.ownKeys(t))Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n));return i}G(us,"joinPrototype");function ds(t){return t&&(typeof t=="object"||typeof t=="function")}G(ds,"isObject");function wt(t,e,i){if(!ds(e))return e;if(Object.hasOwn(e,D.shadow))return Object.getPrototypeOf(e);const n=e[D.tracker];return n?Kn(t,e,n,i):e}G(wt,"getTraceable");function Ji(t,e){return e?new Proxy(t,{get:G((i,n,r)=>n in e&&n!=="constructor"?Reflect.get(e,n,r):Reflect.get(i,n,r),"get"),set:G((i,n,r,s)=>n in e&&n!=="constructor"?Reflect.set(e,n,r,s):Reflect.set(i,n,r,s),"set")}):t}G(Ji,"withProps");function zn(t,e,i){return Ji(t,Object.defineProperty(Object.create(null),e,{value:i,writable:!1}))}G(zn,"withProp");function fs(t,e,i,n){if(!i)return n;const r=Reflect.getOwnPropertyDescriptor(e,i)?.value;return r?zn(n,i,t.extend({[D.shadow]:r})):n}G(fs,"createShadow");function ja(t,e,i,n){return new Proxy(e,{apply:G((r,s,o)=>(s===i&&(s=n),o=o.map(a=>typeof a!="function"||a[D.original]?a:new Proxy(a,{get:G((l,c,u)=>{if(c===D.original)return l;const d=Reflect.get(l,c,u);return c==="toString"&&d===Function.prototype.toString?function(...y){return Reflect.apply(d,this===u?l:this,y)}:d},"get"),apply:G((l,c,u)=>Reflect.apply(l,wt(t,c),u.map(d=>wt(t,d))),"apply"),construct:G((l,c,u)=>Reflect.construct(l,c.map(d=>wt(t,d)),u),"construct")})),wt(t,Reflect.apply(r,s,o))),"apply")})}G(ja,"createShadowMethod");function Kn(t,e,i,n){t[D.shadow]&&(t=Object.getPrototypeOf(t));const r=new Proxy(e,{get:G((s,o,a)=>{if(o===D.original)return s;if(o===i.property)return t;if(typeof o=="symbol")return Reflect.get(s,o,a);if(i.associate&&t[D.internal][`${i.associate}.${o}`])return Reflect.get(t,`${i.associate}.${o}`,zn(t,D.receiver,a));const l=fs(t,s,i.property,a),c=Reflect.get(s,o,l),u=c?.[D.tracker];return u?Kn(t,c,u):!n&&typeof c=="function"?ja(t,c,a,l):c},"get"),set:G((s,o,a,l)=>{if(o===D.original||o===i.property)return!1;if(typeof o=="symbol")return Reflect.set(s,o,a,l);if(i.associate&&t[D.internal][`${i.associate}.${o}`])return Reflect.set(t,`${i.associate}.${o}`,a,zn(t,D.receiver,l));const c=fs(t,s,i.property,l);return Reflect.set(s,o,a,c)},"set"),apply:G((s,o,a)=>hs(r,s,o,a),"apply")});return r}G(Kn,"createTraceable");function hs(t,e,i,n){return e[D.invoke]?e[D.invoke].apply(t,n):Reflect.apply(e,i,n)}G(hs,"applyTraceable");function ps(t,e,i){const n=G(function(...r){const s=Kn(n.ctx,n,i);return hs(s,n,this,r)},"self");return Ne(n,"name",t),Object.setPrototypeOf(n,e)}G(ps,"createCallable");var rh=(ut=class{constructor(e){this.ctx=e,Ne(this,D.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 n=e[D.internal][i];for(;n?.type==="alias";)i=n.name,n=e[D.internal][i];return[i,n]}static checkInject(e,i,n){if(e=e[D.shadow]??e,["prototype","then","registry","lifecycle"].includes(i)||i[0]==="$"||i[0]==="_"||!e.runtime.plugin||e.bail(e,"internal/inject",i))return;const r=n.stack.split(`
1
+ (function(Q,pe){typeof exports=="object"&&typeof module<"u"?pe(exports):typeof define=="function"&&define.amd?define(["exports"],pe):(Q=typeof globalThis<"u"?globalThis:Q||self,pe(Q.InPageEditBundle={}))})(this,(function(Q){"use strict";var T0=Object.defineProperty;var Ff=Q=>{throw TypeError(Q)};var O0=(Q,pe,W)=>pe in Q?T0(Q,pe,{enumerable:!0,configurable:!0,writable:!0,value:W}):Q[pe]=W;var D=(Q,pe,W)=>O0(Q,typeof pe!="symbol"?pe+"":pe,W),Ua=(Q,pe,W)=>pe.has(Q)||Ff("Cannot "+W);var de=(Q,pe,W)=>(Ua(Q,pe,"read from private field"),W?W.call(Q):pe.get(Q)),an=(Q,pe,W)=>pe.has(Q)?Ff("Cannot add the same private member more than once"):pe instanceof WeakSet?pe.add(Q):pe.set(Q,W),Be=(Q,pe,W,Xn)=>(Ua(Q,pe,"write to private field"),Xn?Xn.call(Q,W):pe.set(Q,W),W),ht=(Q,pe,W)=>(Ua(Q,pe,"access private method"),W);var bt,Zi,Ai,en,tn,nn,rn,Le,dt,rt,Fa,qf,Ba,zf,Hf,vt,Wf,Kf,Vf,Gf,Qf,Qn,$t,Ti;var pe=Object.defineProperty,W=(t,e)=>pe(t,"name",{value:e,configurable:!0});function Xn(){}W(Xn,"noop");function Ce(t){return t==null}W(Ce,"isNullable");function Yf(t){return!Ce(t)}W(Yf,"isNonNullable");function Jn(t){return t&&typeof t=="object"&&!Array.isArray(t)}W(Jn,"isPlainObject");function qa(t,e){return Object.fromEntries(Object.entries(t).filter(([i,n])=>e(i,n)))}W(qa,"filterKeys");function Kt(t,e){return Object.fromEntries(Object.entries(t).map(([i,n])=>[i,e(n,i)]))}W(Kt,"mapValues");function za(t,e,i){if(!e)return{...t};const n={};for(const r of e)(i||t[r]!==void 0)&&(n[r]=t[r]);return n}W(za,"pick");function Xf(t,e){if(!e)return{...t};const i={...t};for(const n of e)Reflect.deleteProperty(i,n);return i}W(Xf,"omit");function qe(t,e,i){return Object.defineProperty(t,e,{writable:!0,value:i,enumerable:!1})}W(qe,"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 si(t,e){const i=t?.indexOf(e);return i>=0?(t.splice(i,1),!0):!1}W(si,"remove");function nh(t){return Array.isArray(t)?t:Ce(t)?[]:[t]}W(nh,"makeArray");function oi(t,e){return arguments.length===1?i=>oi(t,i):t in globalThis&&e instanceof globalThis[t]||Object.prototype.toString.call(e).slice(8,-1)===t}W(oi,"is");function ln(t){return oi("ArrayBuffer",t)||oi("SharedArrayBuffer",t)}W(ln,"isArrayBufferLike");function Ha(t){return ln(t)||ArrayBuffer.isView(t)}W(Ha,"isArrayBufferSource");var Pt;(t=>{t.is=ln,t.isSource=Ha;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 n(o){return typeof Buffer<"u"?e(Buffer.from(o,"base64")):Uint8Array.from(atob(o),a=>a.charCodeAt(0))}t.fromBase64=n,W(n,"fromBase64");function r(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=r,W(r,"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")})(Pt||(Pt={})),Pt.fromBase64,Pt.toBase64,Pt.fromHex,Pt.toHex;function Zn(t,e=new Map){if(!t||typeof t!="object")return t;if(oi("Date",t))return new Date(t.valueOf());if(oi("RegExp",t))return new RegExp(t.source,t.flags);if(ln(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 r=[];return e.set(t,r),t.forEach((s,o)=>{r[o]=Reflect.apply(Zn,null,[s,e])}),r}const n=Object.create(Object.getPrototypeOf(t));e.set(t,n);for(const r of Reflect.ownKeys(t)){const s={...Reflect.getOwnPropertyDescriptor(t,r)};"value"in s&&(s.value=Reflect.apply(Zn,null,[s.value,e])),Reflect.defineProperty(n,r,s)}return n}W(Zn,"clone");function gi(t,e,i){if(t===e||!i&&Ce(t)&&Ce(e))return!0;if(typeof t!=typeof e||typeof t!="object"||!t||!e)return!1;function n(r,s){return r(t)?r(e)?s(t,e):!1:r(e)?!1:void 0}return W(n,"check"),n(Array.isArray,(r,s)=>r.length===s.length&&r.every((o,a)=>gi(o,s[a])))??n(oi("Date"),(r,s)=>r.valueOf()===s.valueOf())??n(oi("RegExp"),(r,s)=>r.source===s.source&&r.flags===s.flags)??n(ln,(r,s)=>{if(r.byteLength!==s.byteLength)return!1;const o=new Uint8Array(r),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(r=>gi(t[r],e[r],i))}W(gi,"deepEqual");function rh(t){return t.charAt(0).toUpperCase()+t.slice(1)}W(rh,"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 bs(t,e,i){const n=[];let r=0;for(let s=0;s<t.length;s++){const o=t.charCodeAt(s);if(o>=65&&o<=90){if(r===1){const a=t.charCodeAt(s+1);a>=97&&a<=122&&n.push(i),n.push(o+32)}else r!==0&&n.push(i),n.push(o+32);r=1}else o>=97&&o<=122?(n.push(o),r=2):e.includes(o)?(r!==0&&n.push(i),r=0):n.push(o)}return String.fromCharCode(...n)}W(bs,"tokenize");function ah(t){return bs(t,[45,95],45)}W(ah,"paramCase");function lh(t){return bs(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 n(){return e}t.getTimezoneOffset=n,W(n,"getTimezoneOffset");function r(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=r,W(r,"getDateNumber");function s(p,h){const x=new Date(p*t.day);return h===void 0&&(h=e),new Date(+x+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 m(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=m,W(m,"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 vs(t){return!(!t.prototype||t instanceof fh||Va!==Function&&t instanceof Va)}X(vs,"isConstructor");function cn(t,e){const i=t.Config||t.schema;return i&&t.schema!==!1&&(e=i(e)),e??{}}X(cn,"resolveConfig");function Ga(t){return[Map,Set,Date,Promise].some(e=>t instanceof e)}X(Ga,"isUnproxyable");function ws(t,e){if(t===Object.prototype)return e;const i=Object.create(ws(Object.getPrototypeOf(t),e));for(const n of Reflect.ownKeys(t))Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n));return i}X(ws,"joinPrototype");function _s(t){return t&&(typeof t=="object"||typeof t=="function")}X(_s,"isObject");function Ct(t,e,i){if(!_s(e))return e;if(Object.hasOwn(e,U.shadow))return Object.getPrototypeOf(e);const n=e[U.tracker];return n?tr(t,e,n,i):e}X(Ct,"getTraceable");function un(t,e){return e?new Proxy(t,{get:X((i,n,r)=>n in e&&n!=="constructor"?Reflect.get(e,n,r):Reflect.get(i,n,r),"get"),set:X((i,n,r,s)=>n in e&&n!=="constructor"?Reflect.set(e,n,r,s):Reflect.set(i,n,r,s),"set")}):t}X(un,"withProps");function er(t,e,i){return un(t,Object.defineProperty(Object.create(null),e,{value:i,writable:!1}))}X(er,"withProp");function xs(t,e,i,n){if(!i)return n;const r=Reflect.getOwnPropertyDescriptor(e,i)?.value;return r?er(n,i,t.extend({[U.shadow]:r})):n}X(xs,"createShadow");function Qa(t,e,i,n){return new Proxy(e,{apply:X((r,s,o)=>(s===i&&(s=n),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(...m){return Reflect.apply(d,this===u?c:this,m)}:d},"get"),apply:X((c,l,u)=>Reflect.apply(c,Ct(t,l),u.map(d=>Ct(t,d))),"apply"),construct:X((c,l,u)=>Reflect.construct(c,l.map(d=>Ct(t,d)),u),"construct")})),Ct(t,Reflect.apply(r,s,o))),"apply")})}X(Qa,"createShadowMethod");function tr(t,e,i,n){t[U.shadow]&&(t=Object.getPrototypeOf(t));const r=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}`,er(t,U.receiver,a));const c=xs(t,s,i.property,a),l=Reflect.get(s,o,c),u=l?.[U.tracker];return u?tr(t,l,u):!n&&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,er(t,U.receiver,c));const l=xs(t,s,i.property,c);return Reflect.set(s,o,a,l)},"set"),apply:X((s,o,a)=>ks(r,s,o,a),"apply")});return r}X(tr,"createTraceable");function ks(t,e,i,n){return e[U.invoke]?e[U.invoke].apply(t,n):Reflect.apply(e,i,n)}X(ks,"applyTraceable");function Ss(t,e,i){const n=X(function(...r){const s=tr(n.ctx,n,i);return ks(s,n,this,r)},"self");return qe(n,"name",t),Object.setPrototypeOf(n,e)}X(Ss,"createCallable");var hh=(bt=class{constructor(e){this.ctx=e,qe(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 n=e[U.internal][i];for(;n?.type==="alias";)i=n.name,n=e[U.internal][i];return[i,n]}static checkInject(e,i,n){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 r=n.stack.split(`
2
2
  `);r.splice(1,1),n.stack=r.join(`
3
- `),e.emit(e,"internal/warning",n)}get(e){if(this.ctx[D.internal][e]?.type!=="service")return;const n=this.ctx[D.isolate][e],r=this.ctx[D.store][n]?.value;return wt(this.ctx,r)}set(e,i){this.provide(e);const n=this.ctx[D.isolate][e],r=this.ctx[D.store][n]?.value;i??(i=void 0);let s=G(()=>{},"dispose");if(r===i)return s;if(!we(i)&&!we(r))throw new Error(`service ${e} has been registered`);const o=this.ctx;we(i)||(s=o.effect(()=>()=>{o.set(e,void 0)})),Da(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[D.filter]=l=>o[D.isolate][e]===l[D.isolate][e],o.emit(a,"internal/before-service",e,i),o[D.store][n]={value:i,source:o},o.emit(a,"internal/service",e,r),s}provide(e,i,n){const r=this.ctx.root[D.internal];if(e in r)return;const s=Symbol(e);r[e]={type:"service",builtin:n},this.ctx.root[D.isolate][e]=s,ds(i)&&(this.ctx[D.store][s]={value:i,source:null},Ne(i,D.tracker,{associate:e,property:"ctx"}))}_accessor(e,i){const n=this.ctx.root[D.internal];return e in n?()=>{}:(n[e]={type:"accessor",...i},()=>delete this.ctx.root[D.isolate][e])}accessor(e,i){this.ctx.scope.effect(()=>this._accessor(e,i))}alias(e,i){const n=this.ctx.root[D.internal];if(!(e in n))for(const r of i)n[r]||(n[r]={type:"alias",name:e})}_mixin(e,i){const n=Array.isArray(i)?i.map(o=>[o,o]):Object.entries(i),r=typeof e=="string"?o=>o[e]:()=>e,s=n.map(([o,a])=>this._accessor(a,{get(l){const c=r(this);if(we(c))return c;const u=l?Ji(l,c):c,d=Reflect.get(c,o,u);return typeof d!="function"?d:d.bind(u??c)},set(l,c){const u=r(this),d=c?Ji(c,u):u;return Reflect.set(u,o,l,d)}}));return()=>s.forEach(o=>o())}mixin(e,i){this.ctx.scope.effect(()=>this._mixin(e,i))}trace(e){return wt(this.ctx,e)}bind(e){return new Proxy(e,{apply:G((i,n,r)=>i.apply(this.trace(n),r.map(s=>this.trace(s))),"apply")})}},G(ut,"ReflectService"),B(ut,"handler",{get:G((e,i,n)=>{if(typeof i!="string")return Reflect.get(e,i,n);if(Reflect.has(e,i))return wt(n,Reflect.get(e,i,n),!0);const[r,s]=ut.resolveInject(e,i),o=new Error(`property ${r} is not registered, declare it as \`inject\` to suppress this warning`);return s?s.type==="accessor"?s.get.call(n,n[D.receiver]):(s.builtin||ut.checkInject(n,r,o),n.reflect.get(r)):(ut.checkInject(n,r,o),Reflect.get(e,r,n))},"get"),set:G((e,i,n,r)=>{if(typeof i!="string")return Reflect.set(e,i,n,r);const[s,o]=ut.resolveInject(e,i);return o?o.type==="accessor"?o.set?o.set.call(r,n,r[D.receiver]):!1:(r.reflect.set(s,n),!0):Reflect.set(e,s,n,r)},"set"),has:G((e,i)=>{if(typeof i!="string")return Reflect.has(e,i);if(Reflect.has(e,i))return!0;const[,n]=ut.resolveInject(e,i);return!!n},"has")}),ut),gs=rh;function ms(t){return t!==null&&t!==!1&&t!==void 0}G(ms,"isBailed");var sh=(Hi=class{constructor(e){B(this,"isActive",!1);B(this,"_tasks",new Set);B(this,"_hooks",{});this.ctx=e,Ne(this,D.tracker,{associate:"lifecycle",property:"ctx"}),Ne(this.on("internal/listener",function(n,r,s){const o=s.prepend?"unshift":"push";if(n==="ready")return this.lifecycle.isActive?(this.scope.ensure(async()=>r()),()=>!1):void 0;if(n==="dispose")return this.scope.disposables[o](r),Ne(r,"name","event <dispose>"),()=>Gt(this.scope.disposables,r);if(n==="fork")return this.scope.runtime.forkables[o](r),this.scope.collect("event <fork>",()=>Gt(this.scope.runtime.forkables,r))}),Ke.static,e.scope);for(const n of["info","error","warning"])Ne(this.on(`internal/${n}`,(r,...s)=>{this._hooks[`internal/${n}`].length>1}),Ke.static,e.scope);Ne(this.on("internal/before-service",function(n){for(const r of this.registry.values()){if(!r.inject[n]?.required)continue;const s=r.isReusable?r.children:[r];for(const o of s)this[D.filter](o.ctx)&&(o.updateStatus(),o.reset())}},{global:!0}),Ke.static,e.scope),Ne(this.on("internal/service",function(n){for(const r of this.registry.values()){if(!r.inject[n]?.required)continue;const s=r.isReusable?r.children:[r];for(const o of s)this[D.filter](o.ctx)&&o.start()}},{global:!0}),Ke.static,e.scope);const i=G((n,r)=>{if(!n.runtime.plugin)return!1;for(const s in n.runtime.inject)if(r===gs.resolveInject(n.ctx,s)[0])return!0;return i(n.parent.scope,r)},"checkInject");Ne(this.on("internal/inject",function(n){return i(this.scope,n)},{global:!0}),Ke.static,e.scope)}async flush(){for(;this._tasks.size;)await Promise.all(Array.from(this._tasks))}filterHooks(e,i){return i=wt(this.ctx,i),e.slice().filter(n=>{const r=i?.[Ke.filter];return n.global||!r||r.call(i,n.ctx)})}*dispatch(e,i){const n=typeof i[0]=="object"||typeof i[0]=="function"?i.shift():null,r=i.shift();r!=="internal/event"&&this.emit("internal/event",e,r,i,n);for(const s of this.filterHooks(this._hooks[r]||[],n))yield s.callback.apply(n,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(ms(i))return i}bail(...e){for(const i of this.dispatch("bail",e))if(ms(i))return i}register(e,i,n,r){const s=r.prepend?"unshift":"push";return i[s]({ctx:this.ctx,callback:n,...r}),this.ctx.state.collect(e,()=>this.unregister(i,n))}unregister(e,i){const n=e.findIndex(r=>r.callback===i);if(n>=0)return e.splice(n,1),!0}on(e,i,n){var a;typeof n!="object"&&(n={prepend:n}),this.ctx.scope.assertActive(),i=this.ctx.reflect.bind(i);const r=this.bail(this.ctx,"internal/listener",e,i,n);if(r)return r;const s=(a=this._hooks)[e]||(a[e]=[]),o=typeof e=="string"?`event <${e}>`:"event (Symbol)";return this.register(o,s,i,n)}once(e,i,n){const r=this.on(e,function(...s){return r(),i.apply(this,s)},n);return r}async start(){this.isActive=!0;const e=this._hooks.ready||[];for(;e.length;){const{ctx:i,callback:n}=e.shift();i.scope.ensure(async()=>n())}await this.flush()}async stop(){this.isActive=!1,this.ctx.scope.reset()}},G(Hi,"Lifecycle"),Hi),Ua=sh,Fa=(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))(Fa||{});W.CordisError=(_i=class extends Error{constructor(e,i){super(i??_i.Code[e]),this.code=e}},G(_i,"CordisError"),_i),(t=>{t.Code={INACTIVE_EFFECT:"cannot create effect on inactive context"}})(W.CordisError||(W.CordisError={}));var ys=(zi=class{constructor(e,i){B(this,"uid");B(this,"ctx");B(this,"disposables",[]);B(this,"error");B(this,"status",0);B(this,"isActive",!1);B(this,"context");B(this,"proxy");B(this,"acceptors",[]);B(this,"tasks",new Set);B(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:G((n,r)=>Reflect.get(this.config,r),"get")})}get _config(){return this.runtime.isReactive?this.proxy:this.config}assertActive(){if(!(this.uid!==null||this.isActive))throw new W.CordisError("INACTIVE_EFFECT")}effect(e,i){this.assertActive();const n=cs(e)?new e(this.ctx,i):e(this.ctx,i);let r=!1;const s=typeof n=="function"?n:n.dispose.bind(n),o=G((...a)=>{if(!r)return r=!0,Gt(this.disposables,o),s(...a)},"wrapped");return this.disposables.push(o),typeof n=="function"?o:(n.dispose=o,n)}collect(e,i){const n=Ne(()=>(Gt(this.disposables,n),i()),"name",e);return this.disposables.push(n),n}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(n=>{this.context.emit(this.ctx,"internal/error",n),this.cancel(n)}).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||!we(this.ctx.get(e)))}reset(){this.isActive=!1,this.disposables=this.disposables.splice(0).filter(e=>{if(this.uid!==null&&e[Ke.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 n={keys:Array.isArray(e[0])?e.shift():null,callback:e[0],...e[1]};return this.effect(()=>(this.acceptors.push(n),n.immediate&&n.callback?.(this.config),()=>Gt(this.acceptors,n)))}decline(e){return this.accept(e,()=>!0)}checkUpdate(e,i){if(i||!this.config)return[!0,!0];if(i===!1)return[!1,!1];const n=Object.create(null),r=G(c=>{const u=n[c]??(n[c]=!si(this.config[c],e[c]));return o||(o=u),u},"checkPropertyUpdate"),s=new Set;let o=!1,a=!1,l=this.runtime.isReactive||null;for(const{keys:c,callback:u,passive:d}of this.acceptors){if(!c)l||(l=!d);else if(d)c?.forEach(p=>s.add(p));else{let p=!1;for(const f of c)p||(p=r(f));if(!p)continue}u?.(e)&&(a=!0)}for(const c in{...this.config,...e})if(l!==!1&&!(c in n)&&!s.has(c)){const u=r(c);l===null&&(a||(a=u))}return[o,a]}},G(zi,"EffectScope"),zi),Ba=(Ki=class extends ys{constructor(i,n,r,s){super(i,r);B(this,"dispose");this.runtime=n,this.dispose=Ne(i.scope.collect(`fork <${i.runtime.name}>`,()=>{this.uid=null,this.reset(),this.context.emit("internal/fork",this);const o=Gt(n.disposables,this.dispose);return Gt(n.children,this)&&!n.children.length&&i.registry.delete(n.plugin),o}),Ke.static,n),n.children.push(this),n.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,n){const r=this.config,s=this.runtime.isForkable?this:this.runtime;if(s.config!==r)return;let o;try{o=Xi(this.runtime.plugin,i)}catch(c){return this.context.emit("internal/error",c),this.cancel(c)}const[a,l]=s.checkUpdate(o,n);this.context.emit("internal/before-update",this,i),this.config=o,s.config=o,a&&this.context.emit("internal/update",this,r),l&&s.restart()}},G(Ki,"ForkScope"),Ki),bs=(Wi=class extends ys{constructor(i,n,r,s){super(i,r);B(this,"value");B(this,"runtime",this);B(this,"schema");B(this,"name");B(this,"inject",Object.create(null));B(this,"forkables",[]);B(this,"children",[]);B(this,"isReusable",!1);B(this,"isReactive",!1);B(this,"apply",G((i,n)=>{if(typeof this.plugin!="function")return this.plugin.apply(i,n);if(cs(this.plugin)){const r=new this.plugin(i,n),s=r[Ke.expose];return s&&i.set(s,r),r.fork&&this.forkables.push(r.fork.bind(r)),r}else return this.plugin(i,n)},"apply"));this.plugin=n,n?(this.setup(),this.init(s)):(this.name="root",this.isActive=!0)}get isForkable(){return this.forkables.length>0}fork(i,n,r){return new Ba(i,this,n,r)}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=be.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,n){if(this.isForkable){const c=new Error(`attempting to update forkable plugin "${this.plugin.name}", which may lead to unexpected behavior`);this.context.emit(this.ctx,"internal/warning",c)}const r=this.config;let s;try{s=Xi(this.runtime.plugin||this.context.constructor,i)}catch(c){return this.context.emit("internal/error",c),this.cancel(c)}const[o,a]=this.checkUpdate(s,n),l=this.children.find(c=>c.config===r);this.config=s,l&&(this.context.emit("internal/before-update",l,i),l.config=s,o&&this.context.emit("internal/update",l,r)),a&&this.restart()}},G(Wi,"MainScope"),Wi);function qa(t){return t&&typeof t=="object"&&typeof t.apply=="function"}G(qa,"isApplicable");function be(t){return function(e,i){if(i.kind==="class")e.inject=t;else if(i.kind==="method")i.addInitializer(function(){const n=this[D.tracker]?.property;if(!n)throw new Error("missing context tracker");this[n].inject(t,r=>{e.call(Ji(this,{[n]:r}))})});else throw new Error("@Inject can only be used on class or class methods")}}G(be,"Inject"),(t=>{function e(i){if(!i)return{};if(Array.isArray(i))return Object.fromEntries(i.map(o=>[o,{required:!0}]));const{required:n,optional:r,...s}=i;return Array.isArray(n)&&Object.assign(s,Object.fromEntries(n.map(o=>[o,{required:!0}]))),Array.isArray(r)&&Object.assign(s,Object.fromEntries(r.map(o=>[o,{required:!1}]))),s}t.resolve=e,G(e,"resolve")})(be||(be={}));var oh=(Vi=class{constructor(e,i){B(this,"_counter",0);B(this,"_internal",new Map);B(this,"context");this.ctx=e,Ne(this,D.tracker,{associate:"registry",property:"ctx"}),this.context=e;const n=new bs(e,null,i);e.scope=n,n.ctx=e,this.set(null,n)}get counter(){return++this._counter}get size(){return this._internal.size}resolve(e,i=!1){if(e===null||typeof e=="function")return e;if(qa(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 n=this.resolve(e);this._internal.set(n,i)}delete(e){const i=this.resolve(e),n=i&&this._internal.get(i);if(n)return this._internal.delete(i),n.dispose(),n}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,n){if(this.resolve(e,!0),this.ctx.scope.assertActive(),!n)try{i=Xi(e,i)}catch(s){this.context.emit(this.ctx,"internal/error",s),n=s,i=null}let r=this.get(e);return r?(r.isForkable||this.context.emit(this.ctx,"internal/warning",new Error(`duplicate plugin detected: ${e.name}`)),r.fork(this.ctx,i,n)):(r=new bs(this.ctx,e,i,n),this.set(e,r),r.fork(this.ctx,i,n))}},G(Vi,"Registry"),Vi),ah=oh,Ke=($e=class{static is(e){return!!e?.[$e.is]}static associate(e,i){return e}constructor(e){e=Xi(this.constructor,e),this[D.store]=Object.create(null),this[D.isolate]=Object.create(null),this[D.internal]=Object.create(null),this[D.intercept]=Object.create(null);const i=new Proxy(this,gs.handler);i.root=i,i.reflect=new gs(i),i.registry=new ah(i,e),i.lifecycle=new Ua(i);const n=G(r=>{if(r){n(Object.getPrototypeOf(r));for(const s of Object.getOwnPropertyNames(r)){const o=r[s].prototype?.constructor;o&&(i[r[s].key]=new o(i,e),Ne(i[r[s].key],"ctx",i))}}},"attach");return n(this[D.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,D.shadow)?.value,n=Object.assign(Object.create(wt(this,this)),e);return i?Object.assign(Object.create(n),{[D.shadow]:i}):n}isolate(e,i){const n=Object.create(this[D.isolate]);return n[e]=i??Symbol(e),this.extend({[D.isolate]:n})}intercept(e,i){const n=Object.create(this[D.intercept]);return n[e]=i,this.extend({[D.intercept]:n})}},G($e,"Context"),B($e,"store",D.store),B($e,"events",D.events),B($e,"static",D.static),B($e,"filter",D.filter),B($e,"expose",D.expose),B($e,"isolate",D.isolate),B($e,"internal",D.internal),B($e,"intercept",D.intercept),B($e,"origin","ctx"),B($e,"current","ctx"),$e.is[Symbol.toPrimitive]=()=>Symbol.for("cordis.is"),$e.prototype[$e.is]=!0,$e);Ke.prototype[Ke.internal]=Object.create(null);var ht=(rt=class{constructor(...e){B(this,"ctx");B(this,"name");B(this,"config");let i,n,r,s;Ke.is(e[0])?(i=e[0],typeof e[1]=="string"?(n=e[1],r=e[2]):s=e[1]):s=e[0],n??(n=this.constructor[D.provide]),r??(r=this.constructor[D.immediate]);let o=this;const a={associate:n,property:"ctx"};return o[D.invoke]&&(o=ps(n,us(Object.getPrototypeOf(this),Function.prototype),a)),i?o.ctx=i:o[D.setup](),o.name=n,o.config=s,Ne(o,D.tracker,a),o.ctx.provide(n),o.ctx.runtime.name=n,r&&(i?o[D.expose]=n:o.ctx.set(n,o)),o.ctx.on("ready",async()=>{await Promise.resolve(),await o.start(),r||o.ctx.set(n,o)}),o.ctx.on("dispose",()=>o.stop()),o}start(){}stop(){}[D.filter](e){return e[D.isolate][this.name]===this.ctx[D.isolate][this.name]}[D.setup](){this.ctx=new Ke}[D.extend](e){let i;return this[rt.invoke]?i=ps(this.name,this,this[D.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}},G(rt,"Service"),B(rt,"setup",D.setup),B(rt,"invoke",D.invoke),B(rt,"extend",D.extend),B(rt,"tracker",D.tracker),B(rt,"provide",D.provide),B(rt,"immediate",D.immediate),rt),lh=Object.defineProperty,ch=Object.getOwnPropertyNames,Z=(t,e)=>lh(t,"name",{value:e,configurable:!0}),uh=(t,e)=>function(){return e||(0,t[ch(t)[0]])((e={exports:{}}).exports,e),e.exports},dh=uh({"src/index.ts"(t,e){var I;var i=Symbol.for("schemastery"),n=Symbol.for("ValidationError");globalThis.__schemastery_index__??(globalThis.__schemastery_index__=0);var r=(I=class extends TypeError{constructor(b,k){let P="$";for(const L of k.path||[])typeof L=="string"?P+="."+L:typeof L=="number"?P+="["+L+"]":typeof L=="symbol"&&(P+=`[Symbol(${L.toString()})]`);P.startsWith(".")&&(P=P.slice(1));super((P==="$"?"":`${P} `)+b);B(this,"name","ValidationError");this.options=k}static is(b){return!!b?.[n]}},Z(I,"ValidationError"),I);Object.defineProperty(r.prototype,n,{value:!0});var s=Z(function(m){const g=Z(function(b,k={}){return s.resolve(b,g,k)[0]},"schema");if(m.refs){const b=Dt(m.refs,P=>new s(P)),k=Z(P=>b[P],"getRef");for(const P in b){const L=b[P];L.sKey=k(L.sKey),L.inner=k(L.inner),L.list=L.list&&L.list.map(k),L.dict=L.dict&&Dt(L.dict,k)}return b[m.uid]}if(Object.assign(g,m),typeof g.callback=="string")try{g.callback=new Function("return "+g.callback)()}catch{}return Object.defineProperty(g,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(g,s.prototype),g.meta||(g.meta={}),g.toString=g.toString.bind(g),g},"Schema");s.prototype=Object.create(Function.prototype),s.prototype[i]=!0,s.ValidationError=r;var o;s.prototype.toJSON=Z(function(){var b;if(o)return o[b=this.uid]??(o[b]=JSON.parse(JSON.stringify({...this}))),this.uid;o={[this.uid]:{...this}},o[this.uid]=JSON.parse(JSON.stringify({...this}));const g={uid:this.uid,refs:o};return o=void 0,g},"toJSON"),s.prototype.set=Z(function(g,b){return this.dict[g]=b,this},"set"),s.prototype.push=Z(function(g){return this.list.push(g),this},"push");function a(m,g){const b=typeof m=="string"?{"":m}:{...m};for(const k in g){const P=g[k];P?.$description||P?.$desc?b[k]=P.$description||P.$desc:typeof P=="string"&&(b[k]=P)}return b}Z(a,"mergeDesc");function l(m){return m?.$value??m?.$inner}Z(l,"getInner");function c(m){return Aa(m??{},g=>!g.startsWith("$"))}Z(c,"extractKeys"),s.prototype.i18n=Z(function(g){const b=s(this),k=a(b.meta.description,g);return Object.keys(k).length&&(b.meta.description=k),b.dict&&(b.dict=Dt(b.dict,(P,L)=>P.i18n(Dt(g,C=>l(C)?.[L]??C?.[L])))),b.list&&(b.list=b.list.map((P,L)=>P.i18n(Dt(g,(C={})=>Array.isArray(l(C))?l(C)[L]:Array.isArray(C)?C[L]:c(C))))),b.inner&&(b.inner=b.inner.i18n(Dt(g,P=>l(P)?l(P):c(P)))),b.sKey&&(b.sKey=b.sKey.i18n(Dt(g,P=>P?.$key))),b},"i18n"),s.prototype.extra=Z(function(g,b){const k=s(this);return k.meta={...k.meta,[g]:b},k},"extra");for(const m of["required","disabled","collapse","hidden","loose"])Object.assign(s.prototype,{[m](g=!0){const b=s(this);return b.meta={...b.meta,[m]:g},b}});s.prototype.deprecated=Z(function(){var b;const g=s(this);return(b=g.meta).badges||(b.badges=[]),g.meta.badges.push({text:"deprecated",type:"danger"}),g},"deprecated"),s.prototype.experimental=Z(function(){var b;const g=s(this);return(b=g.meta).badges||(b.badges=[]),g.meta.badges.push({text:"experimental",type:"warning"}),g},"experimental"),s.prototype.pattern=Z(function(g){const b=s(this),k=Oa(g,["source","flags"]);return b.meta={...b.meta,pattern:k},b},"pattern"),s.prototype.simplify=Z(function(g){if(si(g,this.meta.default,this.type==="dict"))return null;if(we(g))return g;if(this.type==="object"||this.type==="dict"){const b={};for(const k in g){const L=(this.type==="object"?this.dict[k]:this.inner)?.simplify(g[k]);(this.type==="dict"||!we(L))&&(b[k]=L)}return si(b,this.meta.default,this.type==="dict")?null:b}else if(this.type==="array"||this.type==="tuple"){const b=[];return g.forEach((k,P)=>{const L=this.type==="array"?this.inner:this.list[P],C=L?L.simplify(k):k;b.push(C)}),b}else if(this.type==="intersect"){const b={};for(const k of this.list)Object.assign(b,k.simplify(g));return b}else if(this.type==="union")for(const b of this.list)try{return s.resolve(g,b,{}),b.simplify(g)}catch{}return g},"simplify"),s.prototype.toString=Z(function(g){return x[this.type]?.(this,g)??`Schema<${this.type}>`},"toString"),s.prototype.role=Z(function(m,g){const b=s(this);return b.meta={...b.meta,role:m,extra:g},b},"role");for(const m of["default","link","comment","description","max","min","step"])Object.assign(s.prototype,{[m](g){const b=s(this);return b.meta={...b.meta,[m]:g},b}});var u={};s.extend=Z(function(g,b){u[g]=b},"extend"),s.resolve=Z(function(g,b,k={},P=!1){if(!b)return[g];if(k.ignore?.(g,b))return[g];if(we(g)&&b.type!=="lazy"){if(b.meta.required)throw new r("missing required value",k);let C=b,U=b.meta.default;for(;C?.type==="intersect"&&we(U);)C=C.list[0],U=C?.meta.default;if(we(U))return[g];g=Hn(U)}const L=u[b.type];if(!L)throw new r(`unsupported type "${b.type}"`,k);try{return L(g,b,k,P)}catch(C){if(!b.meta.loose)throw C;return[b.meta.default]}},"resolve"),s.from=Z(function(g){if(we(g))return s.any();if(["string","number","boolean"].includes(typeof g))return s.const(g).required();if(g[i])return g;if(typeof g=="function")switch(g){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(g).required()}else throw new TypeError(`cannot infer schema from ${g}`)},"from"),s.lazy=Z(function(g){const b=Z(()=>(k.inner[i]||(k.inner=k.builder(),k.inner.meta={...k.meta,...k.inner.meta}),k.inner.toJSON()),"toJSON"),k=new s({type:"lazy",builder:g,inner:{toJSON:b}});return k},"lazy"),s.natural=Z(function(){return s.number().step(1).min(0)},"natural"),s.percent=Z(function(){return s.number().step(.01).min(0).max(1).role("slider")},"percent"),s.date=Z(function(){return s.union([s.is(Date),s.transform(s.string().role("datetime"),(g,b)=>{const k=new Date(g);if(isNaN(+k))throw new r(`invalid date "${g}"`,b);return k},!0)])},"date"),s.regExp=Z(function(g=""){return s.union([s.is(RegExp),s.transform(s.string().role("regexp",{flag:g}),(b,k)=>{try{return new RegExp(b,g)}catch(P){throw new r(P.message,k)}},!0)])},"regExp"),s.arrayBuffer=Z(function(g){return s.union([s.is(ArrayBuffer),s.is(SharedArrayBuffer),s.transform(s.any(),(b,k)=>{if(vt.isSource(b))return vt.fromSource(b);throw new r(`expected ArrayBufferSource but got ${b}`,k)},!0),...g?[s.transform(s.string(),(b,k)=>{try{return g==="base64"?vt.fromBase64(b):vt.fromHex(b)}catch(P){throw new r(P.message,k)}},!0)]:[]])},"arrayBuffer"),s.extend("lazy",(m,g,b,k)=>(g.inner[i]||(g.inner=g.builder(),g.inner.meta={...g.meta,...g.inner.meta}),s.resolve(m,g.inner,b,k))),s.extend("any",m=>[m]),s.extend("never",(m,g,b)=>{throw new r(`expected nullable but got ${m}`,b)}),s.extend("const",(m,{value:g},b)=>{if(si(m,g))return[g];throw new r(`expected ${g} but got ${m}`,b)});function d(m,g,b,k,P=!1){const{max:L=1/0,min:C=-1/0}=g;if(m>L)throw new r(`expected ${b} <= ${L} but got ${m}`,k);if(m<C&&!P)throw new r(`expected ${b} >= ${C} but got ${m}`,k)}Z(d,"checkWithinRange"),s.extend("string",(m,{meta:g},b)=>{if(typeof m!="string")throw new r(`expected string but got ${m}`,b);if(g.pattern){const k=new RegExp(g.pattern.source,g.pattern.flags);if(!k.test(m))throw new r(`expect string to match regexp ${k}`,b)}return d(m.length,g,"string length",b),[m]});function y(m,g){const b=m.toString();if(b.includes("e"))return m*Math.pow(10,g);const k=b.indexOf(".");if(k===-1)return m*Math.pow(10,g);const P=b.slice(k+1),L=b.slice(0,k);return P.length<=g?+(L+P.padEnd(g,"0")):+(L+P.slice(0,g)+"."+P.slice(g))}Z(y,"decimalShift");function p(m,g,b){if(b=Math.abs(b),!/^\d+\.\d+$/.test(b.toString()))return(m-g)%b===0;const k=b.toString().indexOf("."),P=b.toString().slice(k+1).length;return Math.abs(y(m,P)-y(g,P))%y(b,P)===0}Z(p,"isMultipleOf"),s.extend("number",(m,{meta:g},b)=>{if(typeof m!="number")throw new r(`expected number but got ${m}`,b);d(m,g,"number",b);const{step:k}=g;if(k&&!p(m,g.min??0,k))throw new r(`expected number multiple of ${k} but got ${m}`,b);return[m]}),s.extend("boolean",(m,g,b)=>{if(typeof m=="boolean")return[m];throw new r(`expected boolean but got ${m}`,b)}),s.extend("bitset",(m,{bits:g,meta:b},k)=>{let P=0,L=[];if(typeof m=="number"){P=m;for(const C in g)m&g[C]&&L.push(C)}else if(Array.isArray(m)){L=m;for(const C of L){if(typeof C!="string")throw new r(`expected string but got ${C}`,k);C in g&&(P|=g[C])}}else throw new r(`expected number or array but got ${m}`,k);return P===b.default?[P]:[P,L]}),s.extend("function",(m,g,b)=>{if(typeof m=="function")return[m];throw new r(`expected function but got ${m}`,b)}),s.extend("is",(m,{constructor:g},b)=>{if(typeof g=="function"){if(m instanceof g)return[m];throw new r(`expected ${g.name} but got ${m}`,b)}else{if(we(m))throw new r(`expected ${g} but got ${m}`,b);let k=Object.getPrototypeOf(m);for(;k;){if(k.constructor?.name===g)return[m];k=Object.getPrototypeOf(k)}throw new r(`expected ${g} but got ${m}`,b)}});function f(m,g,b,k){try{const[P,L]=s.resolve(m[g],b,{...k,path:[...k.path||[],g]});return L!==void 0&&(m[g]=L),P}catch(P){if(!k?.autofix)throw P;return delete m[g],b.meta.default}}Z(f,"property"),s.extend("array",(m,{inner:g,meta:b},k)=>{if(!Array.isArray(m))throw new r(`expected array but got ${m}`,k);return d(m.length,b,"array length",k,!we(g.meta.default)),[m.map((P,L)=>f(m,L,g,k))]}),s.extend("dict",(m,{inner:g,sKey:b},k,P)=>{if(!qn(m))throw new r(`expected object but got ${m}`,k);const L={};for(const C in m){let U;try{U=s.resolve(C,b,k)[0]}catch(H){if(P)continue;throw H}L[U]=f(m,C,g,k),m[U]=m[C],C!==U&&delete m[C]}return[L]}),s.extend("tuple",(m,{list:g},b,k)=>{if(!Array.isArray(m))throw new r(`expected array but got ${m}`,b);const P=g.map((L,C)=>f(m,C,L,b));return k?[P]:(P.push(...m.slice(g.length)),[P])});function w(m,g){for(const b in g)b in m||(m[b]=g[b])}Z(w,"merge"),s.extend("object",(m,{dict:g},b,k)=>{if(!qn(m))throw new r(`expected object but got ${m}`,b);const P={};for(const L in g){const C=f(m,L,g[L],b);(!we(C)||L in m)&&(P[L]=C)}return k||w(P,m),[P]}),s.extend("union",(m,{list:g,toString:b},k,P)=>{for(const L of g)try{return s.resolve(m,L,k,P)}catch{}throw new r(`expected ${b()} but got ${JSON.stringify(m)}`,k)}),s.extend("intersect",(m,{list:g,toString:b},k,P)=>{if(!g.length)return[m];let L;for(const C of g){const U=s.resolve(m,C,k,!0)[0];if(!we(U))if(we(L))L=U;else{if(typeof L!=typeof U)throw new r(`expected ${b()} but got ${JSON.stringify(m)}`,k);if(typeof U=="object")w(L??(L={}),U);else if(L!==U)throw new r(`expected ${b()} but got ${JSON.stringify(m)}`,k)}}return!P&&qn(m)&&w(L,m),[L]}),s.extend("transform",(m,{inner:g,callback:b,preserve:k},P)=>{const[L,C=m]=s.resolve(m,g,P,!0);return k?[b(L)]:[b(L),b(C)]});var x={};function S(m,g,b){x[m]=b,Object.assign(s,{[m](...k){const P=new s({type:m});return g.forEach((L,C)=>{switch(L){case"sKey":P.sKey=k[C]??s.string();break;case"inner":P.inner=s.from(k[C]);break;case"list":P.list=k[C].map(s.from);break;case"dict":P.dict=Dt(k[C],s.from);break;case"bits":{P.bits={};for(const U in k[C])typeof k[C][U]=="number"&&(P.bits[U]=k[C][U]);break}case"callback":{const U=P.callback=k[C];U.toJSON||(U.toJSON=()=>U.toString());break}case"constructor":{const U=P.constructor=k[C];typeof U=="function"&&(U.toJSON||(U.toJSON=()=>U.name));break}default:P[L]=k[C]}}),m==="object"||m==="dict"?P.meta.default={}:m==="array"||m==="tuple"?P.meta.default=[]:m==="bitset"&&(P.meta.default=0),P}})}Z(S,"defineMethod"),S("is",["constructor"],({constructor:m})=>typeof m=="function"?m.name:m),S("any",[],()=>"any"),S("never",[],()=>"never"),S("const",["value"],({value:m})=>typeof m=="string"?JSON.stringify(m):m),S("string",[],()=>"string"),S("number",[],()=>"number"),S("boolean",[],()=>"boolean"),S("bitset",["bits"],()=>"bitset"),S("function",[],()=>"function"),S("array",["inner"],({inner:m})=>`${m.toString(!0)}[]`),S("dict",["inner","sKey"],({inner:m,sKey:g})=>`{ [key: ${g.toString()}]: ${m.toString()} }`),S("tuple",["list"],({list:m})=>`[${m.map(g=>g.toString()).join(", ")}]`),S("object",["dict"],({dict:m})=>Object.keys(m).length===0?"{}":`{ ${Object.entries(m).map(([g,b])=>`${g}${b.meta.required?"":"?"}: ${b.toString()}`).join(", ")} }`),S("union",["list"],({list:m},g)=>{const b=m.map(({toString:k})=>k()).join(" | ");return g?`(${b})`:b}),S("intersect",["list"],({list:m})=>`${m.map(g=>g.toString(!0)).join(" & ")}`),S("transform",["inner","callback","preserve"],({inner:m},g)=>m.toString(g)),e.exports=s}});const R=dh();var vs=(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))(vs||{});const ws=globalThis||window,_s=Symbol.for("__IPE_LOGGER_COLOR_MAP__");ws[_s]||(ws[_s]=new Map);const xs=ws[_s];function Wn(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i),e=(e>>>0)*16777619;return e>>>0}const Ha=[[350,360],[0,15],[15,30],[200,230],[230,250],[250,280],[280,310],[310,330],[140,160],[160,180]];function fh(t,e){const i=Ha.length,n=Wn(t)%i,[r,s]=Ha[n],o=s-r,a=Wn(t+":"+e),l=r+a%(o||1),c=Wn(t+":s"),u=Wn(t+":l");let d,y;if(e==="name")d=62+c%18,y=30+u%12;else{const p=l>=0&&l<50||l>330&&l<360,f=l>=200&&l<=300;d=55+c%20,f?y=55+u%8:p?y=48+u%6:y=50+u%8,d<60&&(d+=5)}return`hsl(${l}, ${d}%, ${y}%)`}function Vn(t,e){if(e)return xs.set(t,e),e;const i=xs.get(t);if(i)return i;const n=t.startsWith("name:")?"name":"group",r=fh(t,n);return xs.set(t,r),r}let za=class Cf{constructor(e={}){this._custom=i=>{if(!this._enabled(i.level))return Ka;const[n,r]=this._prefix(i.label);return this._consoleMethod(i.method).bind(console,n,...r)},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&&Vn(`name:${this._name}`,this._nameColor),this._installBuiltinLevels();for(const i of Object.keys(this._dynamicLevels))this._installLevelGetter(i,this._dynamicLevels[i]);return ph(this)}get level(){return this._levelRef.value}set level(e){this._levelRef.value=e}group(e,i){return e&&Vn(`group:${e}`,i?.color),new Cf({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=hh[e];if(!this._enabled(i.level))return Ka;const[n,r]=this._prefix(i.label);return this._consoleMethod(e).bind(console,n,...r)}_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 n="";if(this._name){const r=Vn(`name:${this._name}`,this._nameColor);n+=`%c${this._name}%c`,i.push(`background:${r}; color:#fff; padding:1px 4px; border-radius:2px; font-weight:700;`,Wa)}if(e&&(n+=` ${e}`),this._groupPath.length){const r=this._groupPath.join("/"),s=Vn(`group:${r}`);n+=` %c${r}%c`,i.push(`color:${s}; text-decoration: underline;`,Wa)}return[n,i]}};const Ka=()=>{},Wa="color:inherit; background:transparent; text-decoration:none;",hh={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 ph(t){const e=function(i,n){return t.group(i,n)};return new Proxy(e,{get(i,n,r){return t[n]},set(i,n,r){return t[n]=r,!0},apply(i,n,r){return t.group(r[0],r[1])},has(i,n){return n in t}})}function Va(t){return new za(t)}function ks(t){if(typeof globalThis.structuredClone=="function")try{return globalThis.structuredClone(t)}catch{}return $i(t,new WeakMap)}function $i(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,l)=>{o.set($i(l,e),$i(a,e))}),o}if(t instanceof Set){const o=new Set;return e.set(t,o),t.forEach(a=>o.add($i(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]=$i(t[a],e);return o}const n=Object.getPrototypeOf(t),r=Object.create(n);e.set(t,r);const s=Object.getOwnPropertyDescriptors(t);for(const o of Reflect.ownKeys(s)){const a=s[o];"value"in a&&(a.value=$i(a.value,e)),Object.defineProperty(r,o,a)}return r}function _t(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}const Ga=function(t){const e=this.constructor.prototype,i=Reflect.get(e,t,e);function n(...r){return Reflect.apply(i,n,r)}Reflect.setPrototypeOf(n,e);for(const r of Reflect.ownKeys(i)){const s=Reflect.getOwnPropertyDescriptor(i,r);s&&Reflect.defineProperty(n,r,s)}return n};Ga.prototype=Object.create(Function.prototype);const gh=Ga;function xt(t,...e){const i=ks(t||{});for(const n of e)if(n!=null)for(const r of Reflect.ownKeys(n)){const s=n[r];if(typeof s>"u")continue;if(s===null){delete i[r];continue}const o=i[r];_t(o)&&_t(s)?i[r]=xt(o,s):i[r]=ks(s)}return i}var Ze=(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.BODY_TRANSFORM_ERROR="BODY_TRANSFORM_ERROR",t))(Ze||{});let et=class Rf extends Error{constructor(i,n,r,s){super(n,s);B(this,"name","FexiosError");this.code=i,this.context=r}static is(i,n){return!(i instanceof Rf)||i instanceof Gn?!1:n?i.code===n:!0}},Gn=class If extends et{constructor(i,n,r){super(n.statusText,i,void 0,r);B(this,"name","FexiosResponseError");this.response=n}static is(i){return i instanceof If}};var Zi;(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[n,r]of e.entries())if(r!=null)if(Array.isArray(r))for(const s of r)s!=null&&i.append(n,String(s));else i.append(n,String(r));return i}if(_t(e)){for(const[n,r]of Object.entries(e))if(r!=null)if(Array.isArray(r))for(const s of r)s!=null&&i.append(n,String(s));else i.append(n,String(r));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((n,r)=>{i[r]=i[r]?[...i[r],n]:[n]}),i}if(e instanceof Map){const i={};for(const[n,r]of e.entries())if(r!=null)if(Array.isArray(r)){const s=r.filter(o=>o!=null).map(o=>String(o));s.length&&(i[n]=(i[n]??[]).concat(s))}else{const s=String(r);i[n]=i[n]?[...i[n],s]:[s]}return i}throw new TypeError(`unsupported type transformation, got: ${Object.prototype.toString.call(e)}`)},t.mergeHeaders=(...e)=>{const i=new Headers,n=r=>{for(const[s,o]of Object.entries(r))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 r of e){if(r==null)continue;if(r instanceof Headers){r.forEach((o,a)=>{i.set(a,o)});continue}if(_t(r)){n(r);continue}const s=(0,t.toHeaderRecord)(r);for(const[o,a]of Object.entries(s)){i.delete(o);for(const l of a)i.append(o,l)}}return i}})(Zi||(Zi={}));var at;(t=>{t.makeSearchParams=n=>{if(!n)return new URLSearchParams;if(n instanceof URLSearchParams)return n;if(typeof n!="object"||n?.constructor!==Object)throw new TypeError("only plain object is supported");const r=new URLSearchParams,s=(l,c)=>{c!=null&&r.append(l,c)},o=(l,c)=>{c!=null&&r.set(l,c)},a=(l,c)=>{if(c!=null){if(Array.isArray(c)){for(const u of c)s(l,u?.toString());return}if(typeof c=="object"&&c.constructor===Object){for(const[u,d]of Object.entries(c)){if(d==null)continue;const y=u.endsWith("[]"),p=y?u.slice(0,-2):u,f=`${l}[${p}]`;if(y){const w=`${f}[]`;if(Array.isArray(d))for(const x of d)s(w,x?.toString());else typeof d=="object"&&d!==null&&d.constructor===Object?a(`${f}[]`,d):s(w,d?.toString())}else if(Array.isArray(d))for(const w of d)s(f,w?.toString());else typeof d=="object"&&d!==null&&d.constructor===Object?a(f,d):o(f,d?.toString())}return}o(l,c?.toString())}};for(const[l,c]of Object.entries(n))a(l,c);return r},t.makeQueryString=n=>(0,t.makeSearchParams)(n).toString(),t.makeURL=(n,r,s,o)=>{const a=typeof window<"u"&&window.location?.origin||"http://localhost",l=typeof n=="string"?new URL(n,o??a):new URL(n),c=(0,t.toQueryRecord)(l.searchParams),u=(0,t.mergeQueries)(c,r||{}),d=(0,t.makeSearchParams)(u);return l.search=d.toString(),typeof s<"u"&&(l.hash=s),l},t.toQueryRecord=n=>{typeof n=="string"&&(n=(0,t.fromString)(n));const r={},s=a=>{if(!a.includes("["))return{path:[a],forceArray:!1};const l=[a.slice(0,a.indexOf("["))],c=/\[([^\]]*)\]/g;let u,d=!1,y=!1;for(;u=c.exec(a);)u[1]===""?(d=!0,y=!0):(l.push(u[1]),y=!1);return d&&y&&(l[l.length-1]=l[l.length-1]+"[]"),{path:l,forceArray:d}},o=(a,l,c,u)=>{let d=a;for(let y=0;y<l.length;y++){const p=l[y];y===l.length-1?u?d[p]===void 0?d[p]=[c]:Array.isArray(d[p])?d[p].push(c):d[p]=[d[p],c]:d[p]===void 0?d[p]=c:Array.isArray(d[p])?d[p].push(c):d[p]=[d[p],c]:((d[p]===void 0||typeof d[p]!="object"||Array.isArray(d[p]))&&(d[p]={}),d=d[p])}};for(const[a,l]of n.entries()){const{path:c,forceArray:u}=s(String(a));o(r,c,l?.toString(),u)}return r},t.fromString=n=>{const r=n.trim();if(!r)return new URLSearchParams;if(r.startsWith("?"))return new URLSearchParams(r.slice(1));const s=r.indexOf("?");if(s>=0){const o=r.indexOf("#",s+1),a=r.slice(s+1,o>=0?o:void 0);return new URLSearchParams(a)}return new URLSearchParams(r)},t.mergeQueries=(...n)=>{const r={};for(const s of n)s!=null&&i(r,e(s));return r};function e(n){if(!n)return{};if(n instanceof URLSearchParams||n instanceof FormData||n instanceof Map)return(0,t.toQueryRecord)(n);if(typeof n=="string")return(0,t.toQueryRecord)((0,t.fromString)(n));if(_t(n))return n;throw new TypeError(`unsupported type transformation, got: ${Object.prototype.toString.call(n)}`)}function i(n,r){for(const[s,o]of Object.entries(r)){if(o===void 0)continue;if(o===null){delete n[s];continue}const a=n[s];_t(a)&&_t(o)?i(a,o):n[s]=ks(o)}}})(at||(at={}));let Ss=class{constructor(e,i,n){B(this,"ok");B(this,"status");B(this,"statusText");B(this,"headers");B(this,"url");B(this,"redirected");this.rawResponse=e,this.data=i,this.responseType=n,["ok","status","statusText","headers","url","redirected"].forEach(r=>{Reflect.defineProperty(this,r,{get:()=>e[r]})})}};const Qa=t=>{const e=t.reduce((r,s)=>r+s.length,0),i=new Uint8Array(e);let n=0;for(const r of t)i.set(r,n),n+=r.length;return i};async function mh(t,e,i){const n=t.getReader();if(!n)throw new et(Ze.NO_BODY_READER,"Failed to get ReadableStream from response body");const r=[];let s=0;try{for(;;){const{done:a,value:l}=await n.read();if(a)break;r.push(l),s+=l.length,i&&e>0&&i(s/e,Qa(r))}}finally{n.releaseLock?.()}const o=Qa(r);return i?.(1,o),o}const yh=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 Ya(t,e,i,n,r){const s=t.headers.get("content-type")?.toLowerCase()??"",o=t.headers.get("content-length"),a=o?Number(o):0,l=t.headers.get("upgrade")?.toLowerCase(),c=t.headers.get("connection")?.toLowerCase();let u=e??yh(s)??"text";if(e||(l==="websocket"&&c==="upgrade"?u="ws":s.includes("text/event-stream")&&(u="stream")),u==="stream"){const x=t.url||t.url||"",S=await bh(x,t,r),I=n?.(S);if(typeof I=="boolean"?I:!S.ok)throw new Gn(S.statusText,S);return S}if(u==="ws"){const x=t.url||t.url||"",S=await Xa(x,t,r),I=n?.(S);if(typeof I=="boolean"?I:!S.ok)throw new Gn(S.statusText,S);return S}const d=/\bcharset=([^;]+)/i.exec(s)?.[1]?.trim()||"utf-8",y=new TextDecoder(d);let p;try{if(u==="form")p=await t.formData();else{const x=await mh(t.body,a,i);if(u==="arrayBuffer")p=x.buffer.slice(x.byteOffset,x.byteOffset+x.byteLength);else if(u==="blob")p=new Blob([x],{type:s||"application/octet-stream"});else if(u==="text"){const S=y.decode(x);if(e)p=S;else{const I=S.trim();if(I.startsWith("{")&&I.endsWith("}")||I.startsWith("[")&&I.endsWith("]"))try{p=JSON.parse(I),u="json"}catch{p=S}else p=S}}else if(u==="json"){const S=y.decode(x);p=S.length?JSON.parse(S):null}else p=x}}catch(x){if(!(x instanceof Error))throw x;try{p=await t.text(),u="text"}catch{throw new et(Ze.BODY_TRANSFORM_ERROR,`Failed to transform response body to ${u}`,void 0,{cause:x})}}const f=new Ss(t,p,u),w=n?.(f);if(typeof w=="boolean"?w:!f.ok)throw new Gn(f.statusText,f);return f}async function Xa(t,e,i){const n=new WebSocket(t.toString()),r=i??6e4;return await new Promise((s,o)=>{const a=r>0?setTimeout(()=>{n.close(),o(new et(Ze.TIMEOUT,`WebSocket connection timed out after ${r}ms`))},r):void 0;let l=!1;const c=()=>{clearTimeout(a),n.removeEventListener("open",u),n.removeEventListener("error",d),n.removeEventListener("close",y)},u=()=>{l||(l=!0,c(),s())},d=p=>{l||(l=!0,c(),o(new et(Ze.NETWORK_ERROR,"WebSocket connection failed",void 0,{cause:p})))},y=p=>{l||(l=!0,c(),o(new et(Ze.NETWORK_ERROR,`WebSocket connection closed unexpectedly (code: ${p.code}, reason: ${p.reason})`,void 0,{cause:p})))};n.addEventListener("open",u),n.addEventListener("error",d),n.addEventListener("close",y)}),new Ss(e||new Response(null),n,"ws")}async function bh(t,e,i){const n=new EventSource(t.toString()),r=i??6e4;return await new Promise((s,o)=>{const a=r>0?setTimeout(()=>{n.close(),o(new et(Ze.TIMEOUT,`EventSource connection timed out after ${r}ms`))},r):void 0;let l=!1;const c=()=>{clearTimeout(a),n.removeEventListener("open",u),n.removeEventListener("error",d)},u=()=>{l||(l=!0,c(),s())},d=y=>{l||(l=!0,c(),o(new et(Ze.NETWORK_ERROR,"EventSource connection failed",void 0,{cause:y})))};n.addEventListener("open",u),n.addEventListener("error",d)}),new Ss(e||new Response(null),n,"stream")}const xe=class xe extends gh{constructor(i={}){super("request");B(this,"baseConfigs");B(this,"hooks",[]);B(this,"mergeQueries",at.mergeQueries);B(this,"mergeHeaders",Zi.mergeHeaders);B(this,"interceptors",{request:this.createInterceptor("beforeRequest"),response:this.createInterceptor("afterResponse")});B(this,"create",xe.create);B(this,"_plugins",new Map);B(this,"checkIsPlainObject",_t);B(this,"mergeQuery",this.mergeQueries);this.baseConfigs=xt(xe.DEFAULT_CONFIGS,i),xe.ALL_METHODS.forEach(n=>this.createMethodShortcut(n.toLowerCase()))}get defaults(){return this.baseConfigs}set defaults(i){this.baseConfigs=i}async request(i,n){let r=n||{};if(typeof i=="string"||i instanceof URL?r.url=i.toString():typeof i=="object"&&(r=i),r=await this.emit("beforeInit",r),r[xe.FINAL_SYMBOL])return r;if(r=this.applyDefaults(r),xe.METHODS_WITHOUT_BODY.includes(r.method?.toLocaleLowerCase())&&r.body)throw new et(Ze.BODY_NOT_ALLOWED,`Request method "${r.method}" does not allow body`);if(r=await this.emit("beforeRequest",r),r[xe.FINAL_SYMBOL])return r;let s;const o={};if(typeof r.body<"u"&&r.body!==null&&(r.body instanceof Blob||r.body instanceof FormData||r.body instanceof URLSearchParams?s=r.body:typeof r.body=="object"&&r.body!==null?(s=JSON.stringify(r.body),r.headers=this.mergeHeaders(r.headers,{"Content-Type":"application/json"})):s=r.body),!Zi.makeHeaders(r.headers||{}).get("content-type")&&s&&(s instanceof FormData||s instanceof URLSearchParams?o["content-type"]=null:typeof s=="string"&&typeof r.body=="object"?o["content-type"]="application/json":s instanceof Blob&&(o["content-type"]=s.type||"application/octet-stream")),r.body=s,r=await this.emit("afterBodyTransformed",r),r[xe.FINAL_SYMBOL])return r;const a=r.abortController??(globalThis.AbortController?new AbortController:void 0),l=globalThis.location?.href||"http://localhost",c=new URL(r.baseURL||this.baseConfigs.baseURL||l,l),u=new URL(r.url,c),d=at.makeURL(u,r.query,u.hash).toString(),y=new Request(d,{method:r.method||"GET",credentials:r.credentials,cache:r.cache,mode:r.mode,headers:Zi.mergeHeaders(this.baseConfigs.headers,r.headers||{},o),body:r.body,signal:a?.signal});if(r.rawRequest=y,r=await this.emit("beforeActualFetch",r),r[xe.FINAL_SYMBOL])return r;const p=r.timeout??this.baseConfigs.timeout??60*1e3,f=r.shouldThrow??this.baseConfigs.shouldThrow;if(r.url.startsWith("ws")||r.responseType==="ws"){const x=await Xa(r.url,void 0,p),S={...r,response:x,rawResponse:void 0,data:x.data,headers:x.headers};return this.emit("afterResponse",S)}let w;try{a&&(w=p>0?setTimeout(()=>{a.abort()},p):void 0);const x=await(r.fetch||this.baseConfigs.fetch||globalThis.fetch)(r.rawRequest).catch(S=>{throw w&&clearTimeout(w),a?.signal.aborted?new et(Ze.TIMEOUT,`Request timed out after ${p}ms`,r):new et(Ze.NETWORK_ERROR,S.message,r)});return w&&clearTimeout(w),r.rawResponse=x,r.response=await Ya(x,r.responseType,(S,I)=>{n?.onProgress?.(S,I)},f,p),Object.defineProperties(r,{url:{get:()=>x?.url||d},data:{get:()=>r.response.data},headers:{get:()=>x.headers},responseType:{get:()=>r.response.responseType}}),this.emit("afterResponse",r)}catch(x){throw w&&clearTimeout(w),x}}applyDefaults(i){const n=i;"customEnv"in this.baseConfigs&&(n.customEnv=xt({},this.baseConfigs.customEnv,n.customEnv));const r=globalThis.location?.href||"http://localhost",s=n.baseURL||this.baseConfigs.baseURL||r,o=new URL(s,r),a=new URL(n.url.toString(),o),l=at.toQueryRecord(o.searchParams),c=at.toQueryRecord(a.searchParams),u=at.mergeQueries(l,c);a.search=at.makeSearchParams(u).toString(),n.url=a.toString();const d=at.mergeQueries(this.baseConfigs.query,n.query);return n.query&&this.restoreNulls(d,n.query),n.query=d,n}restoreNulls(i,n){if(!(!n||typeof n!="object"))for(const[r,s]of Object.entries(n))s===null?i[r]=null:_t(s)&&((!i[r]||typeof i[r]!="object")&&(i[r]={}),this.restoreNulls(i[r],s))}async emit(i,n,r={shouldHandleShortCircuitResponse:!0}){const s=this.hooks.filter(a=>a.event===i);if(s.length===0)return n;const o=async(a,l)=>{const c={...a,rawResponse:l},u=await Ya(l,a.responseType,(d,y)=>a.onProgress?.(d,y),a.shouldThrow??this.baseConfigs.shouldThrow,a.timeout??this.baseConfigs.timeout??60*1e3);if(c.response=u,c.data=u.data,c.headers=u.headers,i!=="afterResponse"){const d=await this.emit("afterResponse",c);return d[xe.FINAL_SYMBOL]=!0,d}else return c[xe.FINAL_SYMBOL]=!0,c};for(let a=0;a<s.length;a++){const l=s[a],c=`${String(i)}#${l.action.name||`anonymous#${a}`}`,u=Symbol("FEXIOS_HOOK_CTX_MARK");try{n[u]=u}catch{}const d=await l.action.call(this,n);try{delete n[u]}catch{}if(d===!1)throw new et(Ze.ABORTED_BY_HOOK,`Request aborted by hook "${c}"`,n);if(d instanceof Response){if(r.shouldHandleShortCircuitResponse!==!1)return o(n,d);n.rawResponse=d}else d&&typeof d=="object"&&d[u]===u&&(n=d)}return n}on(i,n,r=!1){if(typeof n!="function")throw new et(Ze.INVALID_HOOK_CALLBACK,`Hook should be a function, but got "${typeof n}"`);return this.hooks[r?"unshift":"push"]({event:i,action:n}),this}off(i,n){return i==="*"||!i?this.hooks=this.hooks.filter(r=>r.action!==n):this.hooks=this.hooks.filter(r=>r.event!==i||r.action!==n),this}createInterceptor(i){return{handlers:()=>this.hooks.filter(n=>n.event===i).map(n=>n.action),use:(n,r=!1)=>this.on(i,n,r),clear:()=>{this.hooks=this.hooks.filter(n=>n.event!==i)}}}createMethodShortcut(i){return Reflect.defineProperty(this,i,{get:()=>(n,r,s)=>(xe.METHODS_WITHOUT_BODY.includes(i.toLocaleLowerCase())?s=r:(s=s||{},s.body=r),this.request(n,{...s,method:i}))}),this}extends(i){const n=new xe(xt(this.baseConfigs,i));return n.hooks=[...this.hooks],n._plugins=new Map(this._plugins),n._plugins.forEach(async r=>{await n.plugin(r)}),n}static create(i){return new xe(i)}async plugin(i){if(typeof i?.name=="string"&&typeof i?.install=="function"){if(this._plugins.has(i.name))return this;const n=await i.install(this);if(this._plugins.set(i.name,i),n instanceof xe)return n}return this}};B(xe,"version","5.0.1"),B(xe,"FINAL_SYMBOL",Symbol("FEXIOS_FINAL_CONTEXT")),B(xe,"DEFAULT_CONFIGS",{baseURL:"",timeout:0,credentials:void 0,headers:{},query:{},responseType:void 0,shouldThrow(i){return!i.ok},fetch:globalThis.fetch}),B(xe,"ALL_METHODS",["get","post","put","patch","delete","head","options","trace"]),B(xe,"METHODS_WITHOUT_BODY",["get","head","options","trace"]);let en=xe;const vh=en.create,Ja=vh();typeof globalThis<"u"?globalThis.fexios=Ja:typeof window<"u"&&(window.fexios=Ja);var Qn;(t=>{function e(n){return Array.isArray(n)?n.join("|"):typeof n=="boolean"||n===null?n?"1":void 0:typeof n=="number"?""+n:n}t.normalizeParamValue=e;function i(n){const r=o=>o&&(o instanceof URLSearchParams||o instanceof FormData);if(n==null)return;const s=new FormData;if(r(n))return n.forEach((o,a)=>{const l=e(o);l!=null&&s.append(a,l)}),s;if(_t(n))return Object.entries(n).forEach(([o,a])=>{const l=e(a);l!=null&&s.append(o,l)}),s}t.normalizeBody=i})(Qn||(Qn={}));var tn=(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))(tn||{});let We=class extends Error{constructor(e,i="",n){super(),this.code=e,this.message=i,this.cause=n,this.name="WikiSaikouError"}static is(e,i){return e instanceof this&&(i===void 0||e.code===i)}},Yt=class Af extends Error{constructor(e,i){super(),this.errors=e,this.cause=i,this.name="MediaWikiApiError",this.errors=Af.normalizeErrors(e),this.message=e.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(e=>e.code==="badtoken")||["NeedToken","WrongToken"].includes(this.cause?.data?.login?.result)}toString(){return`[${this.name} ${this.code}]`}static is(e){return e instanceof this}static normalizeErrors(e){return Array.isArray(e)===!1?[]:e.filter(i=>typeof i=="object"&&!!i?.code).map(i=>i.text?i:i.info?{...i,text:i.info}:i["*"]?{...i,text:i["*"]}:{...i,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 n(s).length>0}t.includesMediaWikiApiError=i,t.normalizeMwApiErrors=Yt.normalizeErrors;function n(s){let o=e(s);if(typeof o!="object"||o===null)return[];const a=o?.error,l=o?.errors,c=[];return a&&c.push(a),Array.isArray(l)&&c.push(...l),(0,t.normalizeMwApiErrors)(c)}t.extractMediaWikiApiErrors=n;function r(s){if(Yt.is(s))return s.isBadTokenError();{const o=n(s);return new Yt(o).isBadTokenError()}}t.isBadTokenError=r})(We||(We={}));const Za=Symbol.for("__FEXIOS_SAIKOU__");function el(t){const e=t instanceof en?t:new en({baseURL:t instanceof URL?t.toString():String(t),responseType:"json"});return e[Za]||(Reflect.defineProperty(e,Za,{get:()=>!0,enumerable:!1,configurable:!1}),e.on("beforeInit",i=>{if(i.method?.toLowerCase()!=="post")return i;if(i.body===void 0||i.body===null)return i.body=void 0,i;const n=i.body=Qn.normalizeBody(i.body),r=new URLSearchParams(i.query);return n.has("format")&&r.delete("format"),n.has("formatversion")&&r.delete("formatversion"),n.has("action")&&r.delete("action"),n.has("origin")&&(r.set("origin",""+n.get("origin")),n.delete("origin")),i.query=Object.fromEntries(r.entries()),i}),e.on("beforeInit",i=>(i.query=at.mergeQueries({},Qn.normalizeBody(i.query)),i)),e.on("beforeRequest",i=>{const n=new URL(i.url),r=at.mergeQueries(n.searchParams,i.query);if(globalThis.location&&(!r.origin&&location.origin!==n.origin?(r.origin=location.origin,e.baseConfigs.credentials="include",e.baseConfigs.mode="cors"):location.origin===n.origin&&(delete r.origin,e.baseConfigs.credentials=void 0,e.baseConfigs.mode=void 0)),r.origin){const s=encodeURIComponent(r.origin).replace(/\./g,"%2E");delete r.origin,i.query=r,i.url=`${n.origin}${n.pathname}?origin=${s}`}else i.query=r;return i}),e._tokens=new Map,e.on("afterResponse",i=>{const{data:n}=i,r=i.customEnv?.mwTokenName;r&&We.isBadTokenError(n)&&e._tokens.delete(r);const s=n?.query?.tokens;s&&typeof s=="object"&&Object.entries(s).forEach(([a,l])=>{typeof l=="string"&&e._tokens.set(a.replace(/token$/i,"").toLowerCase(),l)});const o=n?.login?.token;return typeof o=="string"&&e._tokens.set("login",o),i})),e}const tl=(t,e,i)=>{let n={...il.DEFAULT_CONFIGS};if(typeof t=="string"?n=xt(n,{baseURL:t,fexiosConfigs:e||{},defaultParams:i||{},throwOnApiError:!1}):typeof t=="object"&&t!==null&&(n=xt(n,t)),!n.baseURL&&typeof window=="object"&&window.mediaWiki){const{wgServer:r,wgScriptPath:s}=window.mediaWiki?.config?.get(["wgServer","wgScriptPath"])||{};typeof r=="string"&&typeof s=="string"&&(n.baseURL=`${r}${s}/api.php`)}if(typeof n.baseURL!="string")throw new Error("baseURL is required");return n},wh=()=>{},_h=async(t,e)=>{let i=0;const{retry:n=3,onRetry:r=wh,shouldRetry:s=()=>!0}=e;let o;do try{return await t()}catch(a){if(o=a,s(a,i))r(a,i),i++;else throw a}while(i<n);throw o||new Error("Retry failed")};const nn=class{constructor(e,i,n){this.version="7.3.0",this.token=this.getToken;const r=this.config=tl(e,i,n);this.request=el(r.baseURL)}setBaseURL(e){return this.config.baseURL=e,this.request.baseConfigs.baseURL=e,this}async get(e,i){const n=xt({},this.config.fexiosConfigs,{query:at.mergeQueries(this.config.defaultParams,e)},i);return this.runRequestWithApiErrorMapping(()=>this.request.get("",n))}async post(e,i){return this.runRequestWithApiErrorMapping(()=>this.request.post("",e,xt({},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&&We.includesMediaWikiApiError(i)?new Yt(We.extractMediaWikiApiErrors(i),i):i}}throwIfApiError(e){const i=We.extractMediaWikiApiErrors(e);if(i.length>0)throw new Yt(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,n){const{tokenName:r="token",retry:s=3,noCache:o=!1,fexiosOptions:a}=n||{};if(s<1)throw new We(tn.TOKEN_RETRY_LIMIT_EXCEEDED,"The limit of the number of times to automatically re-acquire the token has been exceeded");let l=0;return _h(async()=>{const c=await this.getToken(e,o||l>0);try{const u=await this.post({[r]:c,...i},xt(a||{},{customEnv:{mwTokenName:e}}));if(We.isBadTokenError(u.data))throw u;return u}catch(u){throw We.isBadTokenError(u)||u?.ok===!1||Yt.is(u)?u:new We(tn.HTTP_ERROR,"Network/transport or SDK-internal error (not a MediaWiki API error)",u)}},{retry:s,onRetry:(c,u)=>{l=u+1},shouldRetry:c=>We.isBadTokenError(c)||c?.ok===!1}).catch(c=>{throw We.isBadTokenError(c)||c?.ok===!1?new We(tn.TOKEN_RETRY_LIMIT_EXCEEDED,"Retry attempts for acquiring/using token exhausted",c):c})}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}};nn.INIT_DEFAULT_PARAMS={action:"query",errorformat:"plaintext",format:"json",formatversion:2},nn.DEFAULT_CONFIGS={baseURL:void 0,fexiosConfigs:{responseType:"json"},defaultParams:nn.INIT_DEFAULT_PARAMS,throwOnApiError:!1},nn.createRequestHandler=el;let il=nn;let $s=class extends il{async clientLogin(e,i,n){n||(n={}),!n.logincontinue&&!n.loginreturnurl&&(n.loginreturnurl=location?.origin);const r=await this.postWithToken("login",{action:"clientlogin",username:e,password:i,...n},{tokenName:"logintoken"});if(r?.data?.clientlogin?.status==="PASS")return r.data.clientlogin;throw new We(tn.LOGIN_FAILED,r.data.clientlogin.message,r)}};let xh=class extends $s{constructor(e,i,n){const r=tl(e,{credentials:"include",mode:"cors",...i},{origin:location.origin,...n});super(r)}};class kh{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 n=this.api=new $s({baseURL:i.baseURL.toString(),fexiosConfigs:{headers:{"x-api-user-agent":`InPageEdit-NEXT ${e.version}`,...i.headers},...i},throwOnApiError:!0});e.set("api",n),e.set("apiService",this)}getClientByFileRepo(e){const i=new URL(`${e.scriptDirUrl}/api.php`,location.origin),n=i.toString();if(n===this.ctx.root.config.apiConfigs.baseURL?.toString())return this.ctx.api;if(!this._apiClients.has(n)){const r=i.origin===location.origin,s={baseURL:i.toString(),throwOnApiError:!0},o=r?new $s(s):new xh(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(n,o)}return this._apiClients.get(n)}}const Es=(t,e=document)=>e.querySelector(t),Sh=(t,e=document)=>e.querySelectorAll(t);var $h=Object.create,Ps=Object.defineProperty,Eh=Object.getOwnPropertyDescriptor,nl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),rl=t=>{throw TypeError(t)},Ph=(t,e,i)=>e in t?Ps(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ch=(t,e)=>Ps(t,"name",{value:e,configurable:!0}),Rh=t=>[,,,$h(t?.[nl("metadata")]??null)],Ih=["class","method","getter","setter","accessor","field","value","get","set"],sl=t=>t!==void 0&&typeof t!="function"?rl("Function expected"):t,Ah=(t,e,i,n,r)=>({kind:Ih[t],name:e,metadata:n,addInitializer:s=>i._?rl("Already initialized"):r.push(sl(s||null))}),Oh=(t,e)=>Ph(e,nl("metadata"),t[3]),Th=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Lh=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Eh(r,i));Ch(r,i);for(var f=n.length-1;f>=0;f--)l=Ah(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,sl(o)&&(r=o);return Oh(t,r),p&&Ps(r,i,p),u?c^4?s:p:r},ol,Cs,al;ol=[be(["wiki","wikiTitle"])];class Yn extends(al=ht){constructor(i){super(i,"currentPage",!1);Qi(this,Ye);this.ctx=i,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 ot(this,Ye,Ra).call(this),ot(this,Ye,Of).call(this),window.addEventListener("popstate",ot(this,Ye,Ia).bind(this)),this.logger.info("initialized",this.wikiTitle)}stop(){window.removeEventListener("popstate",ot(this,Ye,Ia).bind(this))}get params(){return this.url.searchParams}get canonicalUrl(){const i=(Es('link[rel="alternate"][hreflang="x-default"]')||Es('link[rel="canonical"]'))?.href;let n=null;return i&&(n=new URL(i,location.origin)),Reflect.defineProperty(this,"canonicalUrl",{get:()=>n}),n}get wikiAction(){return this.params.get("action")||"view"}}Ye=new WeakSet,Ra=async function(){await ot(this,Ye,Lf).call(this),await ot(this,Ye,Tf).call(this)},Of=function(){const i=Symbol.for("InPageEdit.CurrentPageService.UrlChangeListenerInstalled");if(window[i])return;const n=history.pushState,r=history.replaceState;history.pushState=function(s,o,a){n.apply(this,[s,o,a]),window.dispatchEvent(new PopStateEvent("popstate",{state:s}))},history.replaceState=function(s,o,a){r.apply(this,[s,o,a]),window.dispatchEvent(new PopStateEvent("popstate",{state:s}))},window[i]=!0},Ia=async function(i){const n=this.url,r=new URL(window.location.href);this.url=r,(n.pathname!==r.pathname||n.searchParams.get("title")!==r.searchParams.get("title")||n.searchParams.get("curid")!==r.searchParams.get("curid"))&&(await ot(this,Ye,Ra).call(this),this.logger.info("location changed",r,this.wikiTitle))},Tf=async function(){const n=this.wikiTitle?.getMainDBKey()===this.ctx.wiki.mainPageName;return Reflect.defineProperty(this,"isMainPage",{get:()=>n}),n},Lf=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},Cs=Rh(al),Yn=Lh(Cs,0,"CurrentPageService",ol,Yn),Th(Cs,1,Yn);class Nh extends ht{constructor(e){super(e,"resourceLoader",!0),this.ctx=e}stop(){this.removeAll()}loadScript(e,i){if(!e)return Promise.resolve(null);const n=`script:${e}`,r=document.querySelector(`[data-ipe="${n}"]`);return r?Promise.resolve(r):new Promise((o,a)=>{const l=document.createElement("script");l.src=e,l.dataset.ipe=n,i&&Object.entries(i).forEach(([c,u])=>{typeof u>"u"||u===!1||u===null?l.removeAttribute(c):l.setAttribute(c,u)}),document.body.appendChild(l),l.onload=()=>o(l),l.onerror=c=>a(c)})}loadStyle(e,i){if(!e)return Promise.resolve(null);const n=`style:${e}`,r=document.querySelector(`[data-ipe="${n}"]`);return r?Promise.resolve(r):new Promise((o,a)=>{const l=document.createElement("link");l.rel="stylesheet",l.href=e,l.dataset.ipe=n,i&&Object.entries(i).forEach(([u,d])=>{typeof d>"u"||d===!1||d===null?l.removeAttribute(u):l.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(l),l.onload=()=>o(l),l.onerror=u=>a(u)})}removeStyle(e){const i=`style:${e}`,n=document.querySelector(`[data-ipe="${i}"]`);n&&n.remove()}removeScript(e){const i=`script:${e}`,n=document.querySelector(`[data-ipe="${i}"]`);n&&n.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 n=new URL(i);return n.pathname.endsWith(".js")||(n.pathname=n.pathname+"/"),new URL(e,n.toString()).toString()}}const Xn=Object.keys;function Mh(t){return typeof t=="boolean"}function Dh(t){return t&&typeof t.nodeType=="number"}function Jn(t){return typeof t=="string"}function ll(t){return typeof t=="number"}function oi(t){return typeof t=="object"?t!==null:rn(t)}function rn(t){return typeof t=="function"}function jh(t){return!!(t&&t.isComponent)}function Uh(t){return oi(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function Rs(t,e){if(t)for(const i of Xn(t))e(t[i],i)}function Fh(t){return oi(t)&&"current"in t}const Is={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 Bh(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const qh=["Webkit","ms","Moz","O"];Xn(Is).forEach(t=>{qh.forEach(e=>{Is[Bh(e,t)]=0})});const Hh=Symbol.for("jsx-dom:type");var cl=(function(t){return t.ShadowRoot="ShadowRoot",t})(cl||{});function zh(t){return t!=null&&t[Hh]===cl.ShadowRoot}const Kh="http://www.w3.org/2000/svg",Wh="http://www.w3.org/1999/xlink",Vh="http://www.w3.org/XML/1998/namespace";function ul(t){return!Mh(t)&&t!=null}function As(t){return Array.isArray(t)?t.map(As).filter(Boolean).join(" "):oi(t)?Symbol.iterator in t?As(Array.from(t)):Xn(t).filter(e=>t[e]).join(" "):ul(t)?""+t:""}const Gh={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},Qh=/^(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 ai(t){const e=document.createDocumentFragment();return Zn(t.children,e),e}function Yh(t,e,i){e={...e,children:i};const n=new t(e),r=n.render();return"ref"in e&&Os(e.ref,n),r}function h(t,e){let{children:i,...n}=e;!n.namespaceURI&&Gh[t]===0&&(n={...n,namespaceURI:Kh});let r;if(Jn(t)){if(r=n.namespaceURI?document.createElementNS(n.namespaceURI,t):document.createElement(t),Zh(n,r),Zn(i,r),r instanceof window.HTMLSelectElement&&n.value!=null)if(n.multiple===!0&&Array.isArray(n.value)){const s=n.value.map(o=>String(o));r.querySelectorAll("option").forEach(o=>o.selected=s.includes(o.value))}else r.value=n.value;Os(n.ref,r)}else if(rn(t))oi(t.defaultProps)&&(n={...t.defaultProps,...n}),r=jh(t)?Yh(t,n,i):t({...n,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return r}function sn(t,e){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return(Jn(e)||Array.isArray(e))&&(n.unshift(e),e={}),e=e||{},e.children!=null&&!n.length&&({children:n,...e}=e),h(t,{...e,children:n},e.key)}function Os(t,e){Fh(t)?t.current=e:rn(t)&&t(e)}function Zn(t,e){if(Uh(t))Xh(t,e);else if(Jn(t)||ll(t))Ts(document.createTextNode(t),e);else if(t===null)Ts(document.createComment(""),e);else if(Dh(t))Ts(t,e);else if(zh(t)){const i=e.attachShadow(t.attr);Zn(t.children,i),Os(t.ref,i)}}function Xh(t,e){for(const i of[...t])Zn(i,e);return e}function Ts(t,e){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}function er(t,e){return t.replace(/[A-Z]/g,i=>e+i.toLowerCase())}function dl(t,e){e==null||e===!1||(Array.isArray(e)?e.forEach(i=>dl(t,i)):Jn(e)?t.setAttribute("style",e):oi(e)&&Rs(e,(i,n)=>{n.indexOf("-")===0?t.style.setProperty(n,i):ll(i)&&Is[n]!==0?t.style[n]=i+"px":t.style[n]=i}))}function Jh(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":fl(i,Wh,er(t,":"),e);return;case"xmlnsXlink":Ei(i,er(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":fl(i,Vh,er(t,":"),e);return}switch(t){case"htmlFor":Ei(i,"for",e);return;case"dataset":Rs(e,(n,r)=>{n!=null&&(i.dataset[r]=n)});return;case"innerHTML":case"innerText":case"textContent":ul(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":oi(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":rn(e)?e(i):Ei(i,"class",As(e));return;case"ref":case"namespaceURI":return;case"style":dl(i,e);return;case"on":case"onCapture":Rs(e,(n,r)=>{i.addEventListener(r,n,t==="onCapture")});return}if(rn(e)){if(t[0]==="o"&&t[1]==="n"){let n=t.toLowerCase();const r=n.endsWith("capture");if(n==="ondoubleclick"?n="ondblclick":r&&n==="ondoubleclickcapture"&&(n="ondblclickcapture"),!r&&i[n]===null)i[n]=e;else if(r)i.addEventListener(n.substring(2,n.length-7),e,!0);else{let s;n in window?s=n.substring(2):s=n[2]+t.slice(3),i.addEventListener(s,e)}}}else oi(e)?i[t]=e:e===!0?Ei(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!Qh.test(t)?Ei(i,er(t,"-"),e):Ei(i,t,e))}function Ei(t,e,i){t.setAttribute(e,i)}function fl(t,e,i,n){t.setAttributeNS(e,i,n)}function Zh(t,e){for(const i of Xn(t))Jh(i,t[i],e);return e}const tr=Object.keys;function ep(t){return typeof t=="boolean"}function tp(t){return t&&typeof t.nodeType=="number"}function Ls(t){return typeof t=="string"}function hl(t){return typeof t=="number"}function li(t){return typeof t=="object"?t!==null:on(t)}function on(t){return typeof t=="function"}function ip(t){return!!(t&&t.isComponent)}function np(t){return li(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function Ns(t,e){if(t)for(const i of tr(t))e(t[i],i)}function rp(t){return li(t)&&"current"in t}const Ms={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 sp(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const op=["Webkit","ms","Moz","O"];tr(Ms).forEach(t=>{op.forEach(e=>{Ms[sp(e,t)]=0})});const ap=Symbol.for("jsx-dom:type");var pl=(function(t){return t.ShadowRoot="ShadowRoot",t})(pl||{});function lp(t){return t!=null&&t[ap]===pl.ShadowRoot}const cp="http://www.w3.org/2000/svg",up="http://www.w3.org/1999/xlink",dp="http://www.w3.org/XML/1998/namespace";function gl(t){return!ep(t)&&t!=null}function Ds(t){return Array.isArray(t)?t.map(Ds).filter(Boolean).join(" "):li(t)?Symbol.iterator in t?Ds(Array.from(t)):tr(t).filter(e=>t[e]).join(" "):gl(t)?""+t:""}const fp={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},hp=/^(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 pp(t){const e=document.createDocumentFragment();return ir(t.children,e),e}function gp(t,e,i){e={...e,children:i};const n=new t(e),r=n.render();return"ref"in e&&js(e.ref,n),r}function ve(t,e){let{children:i,...n}=e;!n.namespaceURI&&fp[t]===0&&(n={...n,namespaceURI:cp});let r;if(Ls(t)){if(r=n.namespaceURI?document.createElementNS(n.namespaceURI,t):document.createElement(t),bp(n,r),ir(i,r),r instanceof window.HTMLSelectElement&&n.value!=null)if(n.multiple===!0&&Array.isArray(n.value)){const s=n.value.map(o=>String(o));r.querySelectorAll("option").forEach(o=>o.selected=s.includes(o.value))}else r.value=n.value;js(n.ref,r)}else if(on(t))li(t.defaultProps)&&(n={...t.defaultProps,...n}),r=ip(t)?gp(t,n,i):t({...n,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return r}function js(t,e){rp(t)?t.current=e:on(t)&&t(e)}function ir(t,e){if(np(t))mp(t,e);else if(Ls(t)||hl(t))Us(document.createTextNode(t),e);else if(t===null)Us(document.createComment(""),e);else if(tp(t))Us(t,e);else if(lp(t)){const i=e.attachShadow(t.attr);ir(t.children,i),js(t.ref,i)}}function mp(t,e){for(const i of[...t])ir(i,e);return e}function Us(t,e){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}function nr(t,e){return t.replace(/[A-Z]/g,i=>e+i.toLowerCase())}function ml(t,e){e==null||e===!1||(Array.isArray(e)?e.forEach(i=>ml(t,i)):Ls(e)?t.setAttribute("style",e):li(e)&&Ns(e,(i,n)=>{n.indexOf("-")===0?t.style.setProperty(n,i):hl(i)&&Ms[n]!==0?t.style[n]=i+"px":t.style[n]=i}))}function yp(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":yl(i,up,nr(t,":"),e);return;case"xmlnsXlink":Pi(i,nr(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":yl(i,dp,nr(t,":"),e);return}switch(t){case"htmlFor":Pi(i,"for",e);return;case"dataset":Ns(e,(n,r)=>{n!=null&&(i.dataset[r]=n)});return;case"innerHTML":case"innerText":case"textContent":gl(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":li(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":on(e)?e(i):Pi(i,"class",Ds(e));return;case"ref":case"namespaceURI":return;case"style":ml(i,e);return;case"on":case"onCapture":Ns(e,(n,r)=>{i.addEventListener(r,n,t==="onCapture")});return}if(on(e)){if(t[0]==="o"&&t[1]==="n"){let n=t.toLowerCase();const r=n.endsWith("capture");if(n==="ondoubleclick"?n="ondblclick":r&&n==="ondoubleclickcapture"&&(n="ondblclickcapture"),!r&&i[n]===null)i[n]=e;else if(r)i.addEventListener(n.substring(2,n.length-7),e,!0);else{let s;n in window?s=n.substring(2):s=n[2]+t.slice(3),i.addEventListener(s,e)}}}else li(e)?i[t]=e:e===!0?Pi(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!hp.test(t)?Pi(i,nr(t,"-"),e):Pi(i,t,e))}function Pi(t,e,i){t.setAttribute(e,i)}function yl(t,e,i,n){t.setAttributeNS(e,i,n)}function bp(t,e){for(const i of tr(t))yp(i,t[i],e);return e}var Fs=(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))(Fs||{});let vp=0;const bl=t=>`${t}-${++vp}`;function an(t){return t instanceof Node?t:document.createTextNode(String(t))}function jt(t,e){if(!t)throw new Error(`${e??"Element"} not found`);return t}function vl(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 Ue(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[n,r]of Object.entries(e.attrs))i.setAttribute(n,r);return i}const wp=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/i.test(navigator.platform),wl=["ctrl","alt","shift","meta"];function _p(t){if(!t)return null;const e=String(t).trim().toLowerCase().split(/[+\-\s]+/g).filter(Boolean),i=[];let n=null;const r=o=>{i.includes(o)||i.push(o)};for(const o of e){let a=o;if(a==="control"||a==="ctrl"){r("ctrl");continue}if(a==="alt"||a==="option"){r("alt");continue}if(a==="shift"){r("shift");continue}if(a==="meta"||a==="cmd"||a==="command"||a==="super"){r("meta");continue}if(a==="mod"){r(wp?"meta":"ctrl");continue}a==="esc"&&(a="escape"),a==="return"&&(a="enter"),(a==="space"||a==="spacebar")&&(a="space"),n=a}const s=wl.filter(o=>i.includes(o));return!n||n===""?s.length?s.join("+"):null:s.length?`${s.join("+")}+${n}`:n}function xp(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 n=(i.length,i.toLowerCase()),r=wl.filter(s=>e.includes(s));return r.length?`${r.join("+")}+${n}`:n}class kp{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 n=new Set((Array.isArray(i)?i:i?[i]:[]).map(String)),r=new Set((Array.isArray(e)?e:e?[e]:[]).map(String));[...this.stack].reverse().forEach(s=>{const o=s.modalId,a=r.size?r.has(s.pluginName):!0,l=n.has(o);a&&!l&&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 Ve=new kp,Nn=class Nn{constructor(e={}){this.backdropId=bl("ipe-modal-backdrop"),this.modalId=bl("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=Fs,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 n=i.clientX-this.dragStartX,r=i.clientY-this.dragStartY,s=this.get$modal(),o=this.modalStartX+n,a=this.modalStartY+r;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(),n=this.get$window();i.classList.remove("is-dragging"),n.style.animation="none",requestAnimationFrame(()=>{this.applyAnimation(!0)})},this.options={...Nn.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=Ue("div",{className:"ipe-modal-backdrop",attrs:{id:this.backdropId,"data-modal-id":this.modalId}}));const n=Ue("div",{className:"ipe-modal-modal",attrs:{id:this.modalId,role:"dialog","aria-modal":"true",tabindex:"-1"}});if(n.modal=this,!e){n.classList.add("no-backdrop");const p=window.pageYOffset||document.documentElement.scrollTop,f=window.pageXOffset||document.documentElement.scrollLeft,w=window.innerWidth;n.style.top=`${p+60}px`,this.once("modal.show",()=>{n.style.left=`${f+w/2-n.offsetWidth/2}px`})}const r=Ue("div",{className:`ipe-modal-modal__window size--${this.options.sizeClass||"auto"} plugin--${this.pluginName}`});r.modal=this;const s=Ue("div",{className:"ipe-modal-modal__header"}),o=`${this.modalId}-title`,a=Ue("h2",{className:"ipe-modal-modal__title",attrs:{id:o,role:"heading","aria-level":"2"}});n.setAttribute("aria-labelledby",o);const l=Ue("div",{className:"ipe-modal-modal__icons"});if(this.options.closeIcon){const p=Ue("button",{className:"ipe-modal-modal__close",attrs:{type:"button","aria-label":"Close"},html:"&times;"});p.addEventListener("click",()=>{let f=!0;typeof this.options.onClickClose=="function"?this.options.onClickClose(this)===!1&&(f=!1):this.options.onClickClose===!1&&(f=!1),f&&this.close()}),l.appendChild(p)}s.append(a,l),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)),n.classList.add("is-draggable"));const c=Ue("div",{className:"ipe-modal-modal__content"}),u=Ue("div",{className:"ipe-modal-modal__footer"}),d=Ue("div",{className:"ipe-modal-modal__buttons ipe-modal-modal__buttons--left"}),y=Ue("div",{className:"ipe-modal-modal__buttons ipe-modal-modal__buttons--right"});return u.append(d,y),r.append(s,c,u),n.appendChild(r),this.$backdrop=i,this.$modal=n,this.$window=r,this.$header=s,this.$title=a,this.$icons=l,this.$content=c,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("pointerdown",p=>{this.options.outSideClose&&p.target===i&&this.close()}),this.options.draggable&&r.addEventListener("pointerdown",p=>{p.target&&r.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 n=this.emit("modal.beforeShow",!0),r=this.options.beforeShow?this.options.beforeShow(this)!==!1:!0;if(!n||!r)return this}this.lastFocused=document.activeElement??null,this.$backdrop&&document.body.appendChild(this.$backdrop),document.body.appendChild(this.$modal),this.shouldLockBodyOnOpen()&&Ve.lockBodyScroll(),requestAnimationFrame(()=>{this.$backdrop?.classList.add("is-open"),this.$modal.classList.add("is-open"),this.applyAnimation(!0),this.focusFirst()}),document.addEventListener("keydown",this.onKeyDown),Ve.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))},l=(c,u)=>{const d=()=>{c.removeEventListener(u,d),a()};c.addEventListener(u,d,{once:!0})};return s>0&&this.$window?(l(this.$window,"transitionend"),l(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 n=()=>{i||(i=!0,this.destroy(),this.options.onClose?.(this))},r=(s,o)=>{const a=()=>{s.removeEventListener(o,a),n()};s.addEventListener(o,a,{once:!0})};return e>0&&this.$window?(r(this.$window,"transitionend"),r(this.$window,"animationend"),window.setTimeout(n,e+20)):window.setTimeout(n,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=ci.indexOf(this);e!==-1&&ci.splice(e,1)}else this.$backdrop?.parentElement&&this.$backdrop.parentElement.removeChild(this.$backdrop),this.$modal?.parentElement&&this.$modal.parentElement.removeChild(this.$modal),Ve.remove(this),this.shouldUnlockBodyOnClose()&&Ve.unlockBodyScroll();return this.isOpen=!1,this.lastFocused?.focus?.(),this.emit("modal.destroy"),this._isDestroyed=!0,this}get$backdrop(){return this.$backdrop}get$modal(){return jt(this.$modal,"modal")}get$window(){return jt(this.$window,"window")}get$header(){return jt(this.$header,"header")}get$title(){return jt(this.$title,"title")}get$content(){return jt(this.$content,"content")}get$icons(){return jt(this.$icons,"icons")}get$buttons(e){return e==="leftButtons"?jt(this.$buttonsLeft,"leftButtons"):e==="rightButtons"?jt(this.$buttonsRight,"rightButtons"):jt(this.$footer,"buttons")}setTitle(e){const i=this.get$title();return i.innerHTML="",i.append(an(e)),this}setContent(e,i="replace"){const n=this.get$content();return i==="replace"?(n.innerHTML="",n.append(an(e))):i==="append"?n.append(an(e)):n.prepend(an(e)),this}setIcons(e){const i=this.get$icons();i.innerHTML="";for(const n of e){const r=Ue("button",{className:`ipe-modal-modal__icon ${n.className}`,attrs:{type:"button"}});r.addEventListener("click",n.method),i.appendChild(r)}return this}setButtons(e,i){const n=this.$buttonsLeft,r=this.$buttonsRight;[n,r].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",n=i==="link"?Ue("a"):Ue("button",{attrs:{type:"button"}});e.id&&(n.id=e.id),n.className=`ipe-modal-btn ${e.className??""}`.trim();const r=an(e.label??"OK");if(n.append(r),i==="link"&&e.href&&(n.href=e.href),e.method&&n.addEventListener("click",s=>{if(n._ipe_tmpDisabled){s.preventDefault(),s.stopPropagation();return}e.method.call(n,s,this)}),typeof e.closeAfter=="number"&&e.closeAfter>=0&&n.addEventListener("click",()=>{window.setTimeout(()=>this.close(),e.closeAfter)}),typeof e.enableAfter=="number"&&e.enableAfter>0){i==="button"&&n.setAttribute("disabled","true"),n._ipe_tmpDisabled=!0,n.setAttribute("aria-disabled","true");const s=()=>{i==="button"&&n.removeAttribute("disabled"),delete n._ipe_tmpDisabled,n.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=_p(o);a&&this.keyMap.set(a,n)}}return n}addButton(e,i){this.$footer&&(this.$footer.style.display="");const n=e.side??"right",r=n==="left"?this.$buttonsLeft:this.$buttonsRight,s=n==="left"?this.buttonElsLeft:this.buttonElsRight,o=this.generateButton(e),a=Math.max(0,Math.min(i??s.length,s.length));return a>=r.children.length?r.appendChild(o):r.insertBefore(o,r.children[a]),s.splice(a,0,o),this}removeButton(e){const i=this.buttonElsLeft,n=this.buttonElsRight,r=[...i,...n];let s=null;if(e==="*")return r.forEach(a=>{this.keyMap.delete(a.id),a.parentElement?.removeChild(a)}),this.$footer&&(this.$footer.style.display="none"),this;if(typeof e=="number"?s=r[e]??null:typeof e=="string"?s=r.find(a=>a.id===e)??null:e instanceof HTMLElement&&(s=r.find(a=>a===e)??null),!s)return this;for(const[a,l]of this.keyMap.entries())l===s&&this.keyMap.delete(a);let o=i.indexOf(s);return o!==-1?(i.splice(o,1),s.parentElement?.removeChild(s)):(o=n.indexOf(s),o!==-1&&(n.splice(o,1),s.parentElement?.removeChild(s))),i.length===0&&n.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 n=this.get$window(),r=Math.max(0,window.innerHeight-e);return n.style[i]=`${r}px`,r}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(),n=this.get$window(),r=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,l=typeof a=="string"?a:a&&(e?a.show:a.hide);!o||o===!1?(i.style.transition="none",n.style.animation="none",n.style.removeProperty("--ipe-modal-anim")):(i.style.removeProperty("transition"),n.style.setProperty("--ipe-modal-anim",o)),r&&(!l||l===!1?r.style.transition="none":r.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(n=>n.type!==e&&(i?n.listener!==i:!0)),this}once(e,i){const n=this.on(e,r=>(n(),i(r)));return n}emit(e,i){const n=this._hooks.filter(a=>a.type===e);let r=!0;for(const a of n){const l=new CustomEvent(e,{detail:this,cancelable:i}),c=a.listener(l);if(l.defaultPrevented&&(r=!1),c===!1&&(r=!1),!r)break}const s=this.$modal??document.body,o=new CustomEvent(e,{detail:this,cancelable:i});return(!s.dispatchEvent(o)||o.defaultPrevented)&&(r=!1),r}focusFirst(){const e=this.get$modal(),i=vl(e);i.length?i[0].focus():e.focus({preventScroll:!0})}onKeyDown(e){if(Ve.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=vl(i);if(!a.length)return;const l=a[0],c=a[a.length-1],u=document.activeElement;e.shiftKey&&u===l?(e.preventDefault(),c.focus()):!e.shiftKey&&u===c&&(e.preventDefault(),l.focus())}const n=e.ctrlKey||e.altKey||e.metaKey,r=e.target;if(!n&&(r&&["INPUT","TEXTAREA"].includes(r.tagName)||r.contentEditable==="true"))return;const s=xp(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 Ve.remove(this),Ve.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:!Ve.stack.some(e=>e!==this&&e.options.backdrop!==!1&&e.options.bodyScroll===!1)}shouldUnlockBodyOnClose(){return this.options.backdrop===!1||this.options.bodyScroll!==!1?!1:!Ve.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(),n=i.getBoundingClientRect();this.modalStartX=n.left+window.pageXOffset,this.modalStartY=n.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=Sp(e.position??"top right"),n=this.get$window();this.isToast=!0,n.style.pointerEvents="auto",this.applyAnimation(!0),i.appendChild(n);const r=(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 r>0&&(this.startCloseTimer(r),s&&(n.addEventListener("mouseenter",this.stopCloseTimer),n.addEventListener("mouseleave",()=>this.startCloseTimer(r)))),this.isOpen=!0,this.options.onShow?.(this),ci.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=Ve.top();return s?.close(),s}const i=typeof e=="string"?e:e.id,n=Ve.stack.find(s=>s.modalId===i);if(n)return n.close(),n;const r=ci.find(s=>s.modalId===i);return r?.close(),r}static closeAll(e,i){const n=new Set((Array.isArray(i)?i:i?[i]:[]).map(String)),r=new Set((Array.isArray(e)?e:e?[e]:[]).map(String));return Ve.closeAll(e,i),[...ci].forEach(s=>{const o=s.modalId,a=r.size?r.has(s.pluginName):!0,l=n.has(o);a&&!l&&s.close()}),Ve.top()??new Nn}static removeAll(){Ve.removeAll(),[...ci].forEach(e=>e.destroy())}static dialog(e,i){const n=new this({sizeClass:"dialog",buttons:[{label:"OK",className:"is-primary is-ghost",method:(r,s)=>{i?.(r,s),r.defaultPrevented||n.close()},keyPress:"Enter"}],...e});return n.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 n=e.okBtn??{label:"OK",className:"is-primary is-ghost"},r=e.cancelBtn??{label:"Cancel",className:"is-danger is-ghost"};return new this({sizeClass:"dialog",...e,buttons:[{label:r.label,className:r.className,keyPress:"n",method:(s,o)=>{i?.(!1,o,s),o.close()}},{label:n.label,className:n.className,keyPress:"y",method:(s,o)=>{i?.(!0,o,s),s.defaultPrevented||o.close()}}]}).init().show()}static getDefaultNotifyIcon(e){switch(e){case"success":return ve("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:[ve("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ve("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 ve("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:[ve("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ve("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 ve("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:[ve("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ve("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 ve("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:[ve("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ve("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 ve("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:[ve("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ve("path",{d:"M12 11v.01"}),ve("path",{d:"M8 11v.01"}),ve("path",{d:"M16 11v.01"}),ve("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 ve("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:[ve("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ve("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,n){var a,l,c,u;if(i?.overrideOther&&[...ci].forEach(d=>d.close()),typeof i.title>"u"){const d=e||"Notification";i.title=d[0].toUpperCase()+d.slice(1).toLowerCase()}const r=i.icon??this.getDefaultNotifyIcon(e);r&&(r instanceof Element&&r.classList.add("ipe-modal-notify-icon"),i.title=ve(pp,{children:[r,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"),(l=i.okBtn).className??(l.className="is-primary is-text ok-btn"),i.okBtn.method=(d,y)=>{n?.(!0,y,d),y.close()}),i.cancelBtn&&(typeof i.cancelBtn!="object"&&(i.cancelBtn={label:"Cancel"}),(c=i.cancelBtn).label??(c.label="Cancel"),(u=i.cancelBtn).className??(u.className="is-danger is-text cancel-btn"),i.cancelBtn.method=(d,y)=>{n?.(!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"})}};Nn.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 Bs=Nn;const ci=[];function Sp(t="top right"){const e="ipe-modal-toast-container",i=`${e}-${t.replace(/[\s-\.|\/]+/g,"-")}`;let n=document.getElementById(i);return n||(n=Ue("div",{className:`${e} ${t}`,attrs:{id:i,"data-position":t}}),document.body.appendChild(n)),n}const $p={ipe_progress:"_ipe_progress_so6hn_1"},ui=t=>{const e=t.indeterminate??!0,i=h("div",{class:`${$p.ipe_progress}`,"data-indeterminate":`${e}`,style:{width:"100%","--progress":t.progress?`${t.progress}%`:"0%"},...t});return i.setProgress=n=>{typeof n=="number"?(i.dataset.indeterminate="false",i.style.setProperty("--progress",`${n}%`)):(i.dataset.indeterminate="true",i.style.setProperty("--progress","0%"))},i};class Re extends Bs{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(n=>{n.disabled=!0}),this.get$content().append(h("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:h(ui,{style:{width:"80%",maxWidth:"800px"}})}))}else{this.get$window().querySelector("#ipe-modalLoadingWrapper")?.remove();const i=this._tmpDisabledActiveInputs;i&&i.forEach(n=>{n.disabled=!1})}}}class Ep{constructor(e){this.ctx=e,this.IPEModal=Re,this.IPEModalEvent=Fs,this.show=Re.show.bind(Re),this.createObject=Re.createObject.bind(Re),this.close=Re.close.bind(Re),this.closeAll=Re.closeAll.bind(Re),this.removeAll=Re.removeAll.bind(Re),this.dialog=Re.dialog.bind(Re),this.confirm=Re.confirm.bind(Re),this.notify=Re.notify.bind(Re),e.set("modal",this),e.on("dispose",()=>{Re.closeAll()})}}const _l=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,n]of Object.entries(t))if(n!=null){if(Array.isArray(n)){for(const r of n)e.append(i,r?.toString());continue}if(typeof n=="object"&&n!==null&&n.constructor===Object){for(const[r,s]of Object.entries(n))s!=null&&e.set(`${i}[${r}]`,s?.toString());continue}e.set(i,n?.toString())}return e},xl=(t,e,i)=>{const n=typeof t=="string"?new URL(t,window?.location?.origin):new URL(t),r=new URLSearchParams(n.search),s=_l(e);for(const[o,a]of s.entries())r.set(o,a);return n.search=r.toString(),n.hash="",n};var Pp=Object.create,qs=Object.defineProperty,Cp=Object.getOwnPropertyDescriptor,kl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Sl=t=>{throw TypeError(t)},Rp=(t,e,i)=>e in t?qs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ip=(t,e)=>qs(t,"name",{value:e,configurable:!0}),Ap=t=>[,,,Pp(t?.[kl("metadata")]??null)],Op=["class","method","getter","setter","accessor","field","value","get","set"],$l=t=>t!==void 0&&typeof t!="function"?Sl("Function expected"):t,Tp=(t,e,i,n,r)=>({kind:Op[t],name:e,metadata:n,addInitializer:s=>i._?Sl("Already initialized"):r.push($l(s||null))}),Lp=(t,e)=>Rp(e,kl("metadata"),t[3]),Np=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Mp=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Cp(r,i));Ip(r,i);for(var f=n.length-1;f>=0;f--)l=Tp(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,$l(o)&&(r=o);return Lp(t,r),p&&qs(r,i,p),u?c^4?s:p:r},El,Hs,Pl;El=[be(["api","storage"])];class rr extends(Pl=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,n)=>window?.mw?.config?.get?.(i,n)??n),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(h("div",{children:[h("h3",{children:i`Wiki Informations`}),h("ul",{children:[h("li",{children:[h("strong",{children:[i`Site`,":"]})," ",this.general.sitename," (",this.landingPageUrl,")"]}),h("li",{children:[h("strong",{children:i`User`}),": ",this.userInfo.name," (ID: ",this.userInfo.id,")"]}),h("li",{children:[h("strong",{children:i`Groups`}),": ",this.userGroups.join(", ")||"None"]})]}),h("div",{children:[h("p",{style:{fontStyle:"italic"},children:i`If the information shown above is incorrect (for example, the user is not you), click the button below.`}),h("button",{className:"btn danger",onClick:async n=>{n.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 n=i?null:await this.fetchFromCache(e);if(n)return this._data[e]=n,this.logger.debug("Using cached",e,n),n;{const r=await this.fetchFromApi(e);return this.saveToCache(e,r),this._data[e]=r,this.logger.debug("Fetched from API",e,r),r}}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 n=this.getCacheKey(e);return this.CACHE_DB.set(n,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(n=>n.id===i.id).map(n=>n.alias)})).sort((i,n)=>i.id-n.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 xl(this.siteInfo.general.base,e).toString()}getUrl(e,i){const n=_l(i);let r;return typeof e=="string"&&e!==""?r=new URL(`${this.articleBaseUrl.replace("$1",e)}`):typeof e=="number"?(n.set("curid",e.toString()),r=new URL(this.getSciprtUrl("index"))):r=new URL(this.getSciprtUrl("index")),r.search=n.toString(),r.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}}Hs=Ap(Pl),rr=Mp(Hs,0,"WikiMetadataService",El,rr),Np(Hs,1,rr);class Dp{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 jp=()=>new Proxy(new Dp,{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)}}),Up=(()=>{const t=Symbol.for("IPE.GlobalMemoryStorage");return t in globalThis||(globalThis[t]=jp()),globalThis[t]})();class Fp{constructor(e,i,n=1/0,r,s="localStorage"){this.dbName=e,this.storeName=i,this.ttl=n,this.version=r,this.engine=s,typeof n!="number"&&(this.ttl=Number(n)),(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=Up}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 n;try{n=JSON.parse(i)}catch{return this.deleteSync(e),null}const r=n;return typeof r.time!="number"||!("value"in r)?(this.deleteSync(e),null):typeof this.version<"u"&&typeof this.version<"u"&&r.version!==this.version?(this.deleteSync(e),null):r}getRaw(e){const i=this.makeKey(e);return this.db.getItem(i)}setRaw(e,i){const n=this.makeKey(e);try{this.db.setItem(n,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,n){const r=this.load(e),s=this.isExpired(r,i);if(!r||s){if(typeof n=="function"){const o=await n();return await this.set(e,o),o}return null}return r.value}async set(e,i){const n=Date.now();if(typeof e=="string"){const o=e,a=i;if(a===null||typeof a>"u"){await this.delete(o);return}const l={time:n,value:a,version:this.version};return this.setRaw(o,JSON.stringify(l)),l}const r=e,s={};for(const[o,a]of Object.entries(r)){if(a===null||typeof a>"u"){this.deleteSync(o);continue}const l={time:n,value:a,version:this.version};this.setRaw(o,JSON.stringify(l)),s[o]=l}return s}async has(e,i=this.ttl){const n=this.load(e);return n!==null&&!this.isExpired(n,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 n=0;n<this.db.length;n++){const r=this.db.key(n);r&&r.startsWith(e)&&i.push(r)}for(const n of i)this.db.removeItem(n);return this}async*keys(){const e=this.makeKey("");for(let i=0;i<this.db.length;i++){const n=this.db.key(i);n&&n.startsWith(e)&&(yield n.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 ke;(t=>{t.cache=new Map,t.defaults=Object.freeze({iterBatch:100,retry:{attempts:3,baseDelayMs:16}}),t.sleep=c=>new Promise(u=>setTimeout(u,c));function e(c){const u=c?.name??"";return u==="AbortError"||u==="InvalidStateError"||u==="TransactionInactiveError"||u==="UnknownError"}t.shouldReconnect=e;async function i(c,u,d){const y=Math.max(1,c.attempts);for(let p=0;p<y;p++)try{return await u(p)}catch(f){if(p===y-1)throw f;await d?.(f,p);const w=c.baseDelayMs*Math.pow(2,p)+Math.floor(Math.random()*10);await(0,t.sleep)(w)}throw new Error("withRetry exhausted unexpectedly")}t.withRetry=i;function n(c,u,d){return new Promise((y,p)=>{const f=indexedDB.open(c,u);f.onupgradeneeded=()=>{try{const w=f.result,x=f.transaction;d?.(w,x)}catch(w){p(w)}},f.onerror=()=>p(f.error),f.onblocked=()=>{},f.onsuccess=()=>{const w=f.result;w.onversionchange=()=>{try{w.close()}finally{t.cache.delete(c)}},y(w)}})}async function r(c,u,d){let y=!c.objectStoreNames.contains(u),p=[];if(!y&&d?.indexes?.length){const x=c.transaction(u,"readonly"),S=x.objectStore(u),I=new Set(Array.from(S.indexNames));p=(d.indexes||[]).filter(m=>!I.has(m.name)),await new Promise((m,g)=>{x.oncomplete=()=>m(),x.onabort=()=>g(x.error),x.onerror=()=>g(x.error)})}if(!y&&p.length===0)return c;const f=c.version+1;c.close();const w=await n(c.name,f,(x,S)=>{let I;x.objectStoreNames.contains(u)?I=S.objectStore(u):I=x.createObjectStore(u,{keyPath:d?.keyPath??void 0,autoIncrement:!!d?.autoIncrement});for(const m of p)I.indexNames.contains(m.name)||I.createIndex(m.name,m.keyPath,m.options)});return w.onversionchange=()=>{try{w.close()}finally{t.cache.delete(w.name)}},w}async function s(c,u,d){let y=t.cache.get(c);return y?(y=y.then(p=>r(p,u,d)),t.cache.set(c,y)):(y=(async()=>{const p=await n(c);return r(p,u,d)})(),t.cache.set(c,y)),y}t.getDB=s;async function o(c){const u=t.cache.get(c);if(t.cache.delete(c),u)try{(await u).close()}catch{}}t.closeConnection=o;function a(c){return new Promise((u,d)=>{c.onsuccess=()=>u(c.result),c.onerror=()=>d(c.error)})}t.asyncRequest=a;function l(c){return new Promise((u,d)=>{c.oncomplete=()=>u(),c.onabort=()=>d(c.error??new DOMException("Aborted","AbortError")),c.onerror=()=>d(c.error??new DOMException("TransactionError","UnknownError"))})}t.waitTx=l})(ke||(ke={}));let Bp=class{constructor(e,i,n={}){this.dbName=e,this.storeName=i,this.options=n}get _iterBatch(){return this.options.iterBatch??ke.defaults.iterBatch}get _retryCfg(){const e=this.options.retry??ke.defaults.retry;return{attempts:e.attempts??3,baseDelayMs:e.baseDelayMs??16}}async _withStore(e,i){const n=this._retryCfg;return ke.withRetry(n,async()=>{const r=await ke.getDB(this.dbName,this.storeName,this.options.ensure);try{const s=r.transaction(this.storeName,e),o=s.objectStore(this.storeName),a=await i(o);return await ke.waitTx(s),a}catch(s){throw s}},async r=>{ke.shouldReconnect(r)&&await ke.closeConnection(this.dbName)})}async get(e){return this._withStore("readonly",async i=>{const n=await ke.asyncRequest(i.get(e));return n===void 0?void 0:n})}async set(e,i){return await this._withStore("readwrite",async n=>{const r=this.options.ensure?.keyPath!=null?n.put(i):n.put(i,e);await ke.asyncRequest(r)}),this}async delete(e){return this._withStore("readwrite",async i=>{const n=await ke.asyncRequest(i.get(e))!==void 0;return await ke.asyncRequest(i.delete(e)),n})}async clear(){await this._withStore("readwrite",async e=>{await ke.asyncRequest(e.clear())})}async has(e){return await this.get(e)!==void 0}async count(){return this._withStore("readonly",async e=>await ke.asyncRequest(e.count())??0)}async*_iterateEntries(){let e=null,i=!1;const n=Math.max(1,this._iterBatch);for(;!i;){const r=await this._withStore("readonly",async s=>{const o=[],a=e===null?void 0:IDBKeyRange.lowerBound(e,!0);return await new Promise((l,c)=>{const u=s.openCursor(a);u.onerror=()=>c(u.error),u.onsuccess=()=>{const d=u.result;if(!d){i=!0,l();return}o.push([d.key,d.value]),e=d.key,o.length>=n?l():d.continue()}}),o});for(const s of r)yield s;if(r.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,n]of this.entries())await e(n,i,this)}async getMany(e){const i=new Map;for await(const n of e)i.set(n,void 0);return await this._withStore("readonly",async n=>{await Promise.all(i.keys().map(async r=>{const s=await ke.asyncRequest(n.get(r));i.set(r,s===void 0?void 0:s)}))}),i}async setMany(e){const i=this.options.ensure?.keyPath!=null;return await this._withStore("readwrite",async n=>{for await(const[r,s]of e){const o=i?n.put(s):n.put(s,r);await ke.asyncRequest(o)}}),this}async deleteMany(e){let i=0;return await this._withStore("readwrite",async n=>{for await(const r of e)await ke.asyncRequest(n.get(r))!==void 0&&i++,await ke.asyncRequest(n.delete(r))}),i}async disconnect(){await ke.closeConnection(this.dbName)}};class qp{constructor(e,i,n=1/0,r){this.dbName=e,this.storeName=i,this.ttl=n,this.version=r,this.db=new Bp(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[n,r]of this.db.entries())typeof r.time=="number"&&e-r.time>this.ttl&&i.push(n);i.length>0&&await this.db.deleteMany(i)}async get(e,i=this.ttl,n){const r=await this.loadFromDB(e),s=this.checkIfExpired(r,i);if(!r||s){if(typeof n=="function"){const o=await n();return await this.set(e,o),o}return null}return r.value}async set(e,i){const n=Date.now();if(typeof e=="string"){const l=e,c=i;if(c===null||typeof c>"u")return this.delete(l);const u={time:n,value:c,version:this.version};return await this.db.set(l,u),u}const r=e,s=[],o=[],a={};for(const[l,c]of Object.entries(r))if(c===null||typeof c>"u")o.push(l);else{const u={time:n,value:c,version:this.version};s.push([l,u]),a[l]=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 n=await this.loadFromDB(e),r=this.checkIfExpired(n,i);return n!==null&&!r}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 Hp 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,n,r="indexedDB"){const s="indexedDB"in window&&window.indexedDB!==null;switch(r==="indexedDB"&&!s&&(r="localStorage"),r){case"indexedDB":return new qp(this.config.dbName,e,i,n);case"localStorage":case"sessionStorage":case"memory":return new Fp(this.config.dbName,e,i,n,r);default:throw new Error(`Unsupported storage engine: ${r}`)}}}var pt=(t=>(t.preferences="preferences",t.watch="watch",t.unwatch="unwatch",t.nochange="nochange",t))(pt||{});function zp(t){const i=class i{constructor(r,s=!0){this._loaded=s,this.api=t,r.revisions?.forEach(o=>{typeof o?.slots?.main=="object"&&Object.assign(o,o.slots.main)}),this.pageInfo={...i.DEFAULT_PAGE_INFO,...r}}static async newFromApi(r){const{data:s}=await this.api.get({...i.DEFAULT_QUERY_PARAMS,...r}),o=s?.query?.pages?.[0];if(!o||!o.title)throw new Error("Invalid page info",{cause:s});return new i(o,!0)}static newBlankPage(r={}){return new i(r,!1)}static async newFromAnyKind(r){const{title:s,pageId:o,revisionId:a}=r||{};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(r){const{titles:s,pageids:o,revids:a,...l}=r||{},{data:c}=await this.api.post({...i.DEFAULT_QUERY_PARAMS,titles:s?.join("|")??void 0,pageids:o?.join("|")??void 0,revids:a?.join("|")??void 0,...l});return c?.query?.pages?.map(u=>new i(u,!0))||[]}async parse(r){return this.api.post({action:"parse",page:this.pageInfo.title,prop:"text|langlinks|categories|links|templates|images|externallinks|sections|revid|displaytitle|iwlinks|properties|parsewarnings",...r})}async preview(r,s){return this.parse({action:"parse",page:void 0,title:this.title,text:r,pst:1,preview:1,disableeditsection:1,disablelimitreport:1,...s})}async edit(r,s){const o=await this.api.postWithEditToken({action:"edit",title:this.title,starttimestamp:this.pageInfo.touched,basetimestamp:this.revisions[0]?.timestamp,...r,...s});if(o.data?.edit?.result==="Success")return o;throw new Yt([{module:"edit",code:"editfailure",text:"Unknown edit failure. Please try again.",docref:"https://www.mediawiki.org/wiki/API:Edit"}],o)}async createOnly(r,s){return this.edit(r,{createonly:1,recreate:r.recreate,...s})}async delete(r,s){return this.api.postWithEditToken({action:"delete",title:this.pageInfo.title||void 0,pageid:this.pageInfo.pageid||void 0,reason:r,deletetalk:s?.deletetalk,...s})}async moveTo(r,s,o){return this.api.postWithEditToken({action:"move",from:this.pageInfo.title,to:r,reason:s,movetalk:1,movesubpages:1,...o})}userCan(r){return!!this.pageInfo?.actions?.[r]}userCanEdit(){return this.userCan("edit")}async reloadSelfInfo(){const r=await i.newFromApi({pageids:this.pageInfo.pageid,titles:this.pageInfo.title}),s=(this.pageInfo.revisions||[]).concat(r.revisions||[]).sort((o,a)=>o.revid-a.revid).reduce((o,a)=>(o.find(l=>l.revid===a.revid)||o.push(a),o),[]);return this.pageInfo=r.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 Ea=class Ea extends ht{constructor(e){super(e,"wikiPage",!0),this.ctx=e,this.WikiPage=zp(this.ctx.api)}async createInstance(e,i=!1){return await this.WikiPage.newFromApi(e)}async newFromTitle(e,i=!1,n,r=!1){return this.createInstance({titles:e.toString(),converttitles:i,rvsection:n},r)}async newFromPageId(e,i,n=!1){return this.createInstance({pageids:e,rvsection:i},n)}async newFromRevision(e,i,n=!1){return await this.createInstance({revids:e,rvsection:i},n)}newBlankPage(e={}){return this.WikiPage.newBlankPage(e)}};Ea.inject=["api"];let zs=Ea;const Cl=new WeakMap,ln={toDBKey:t=>t.replace(/ /g,"_"),toNormalText:t=>t.replace(/_/g," "),ensureCase:(t,e)=>e==="first-letter"?t.charAt(0).toUpperCase()+t.slice(1):t},cn={normalizeSpecialPageName:t=>t.toLowerCase(),buildSpecialPageIndex:t=>{const e=new Map,i=new Map,n=new Map;for(const r of t.specialpagealiases){const s=r.realname;e.set(s,s);const o=cn.normalizeSpecialPageName(s);n.set(o,s);for(const a of r.aliases){i.set(a,s);const l=cn.normalizeSpecialPageName(a);n.set(l,s)}}return{byRealName:e,byAlias:i,byNormalized:n}},findSpecialPageRealName:(t,e)=>{const i=t.split("/")[0];let n=e.byRealName.get(i)??e.byAlias.get(i);if(n!==void 0)return n;const r=cn.normalizeSpecialPageName(i);return e.byNormalized.get(r)??null}},kt={normalizeNamespaceText:t=>t.replace(/[_\s]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),buildIndex:t=>{const e=new Map,i=new Map,n=new Map,r=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 l=kt.normalizeNamespaceText(o.name),c=kt.normalizeNamespaceText(o.canonical??"");r.set(l,a),r.set(c,a)}for(const s of t.namespacealiases){n.set(s.alias,s.id);const o=kt.normalizeNamespaceText(s.alias);r.set(o,s.id)}return{byName:e,byCanonical:i,byAlias:n,byNormalized:r}},findNamespaceId:(t,e)=>{let i=e.byName.get(t)??e.byCanonical.get(t)??e.byAlias.get(t);if(i!==void 0)return i;const n=kt.normalizeNamespaceText(t);return e.byNormalized.get(n)??null},isTalkPage:t=>t%2===1&&t>0,getDefaultNamespaceInfo:t=>({id:t,name:"",canonical:"",case:"first-letter",content:!1,nonincludable:!1,subpages:!1})};function Kp(t){var s,o;const e=Cl.get(t);if(e)return e;const i=kt.buildIndex(t),n=cn.buildSpecialPageIndex(t),a=class a{constructor(c,u){Qi(this,s);Qi(this,o);if(this.newTitle=a.create.bind(a),this.toText=this.getPrefixedText.bind(this),this.toString=this.getPrefixedDBKey.bind(this),Le(this,s,c||""),Le(this,o,u??0),u===void 0)this.fixNSByTitle();else{const d=this.parseTitlePrefix(ae(this,s));d&&d.namespaceId===ae(this,o)&&Le(this,s,d.mainTitle)}if(this.getMainText()==="")throw new Error("Invalid title")}static create(c,u){return new a(c,u)}parseTitlePrefix(c){const u=c.indexOf(":");if(u<=0)return null;const d=c.substring(0,u),y=c.substring(u+1),p=kt.findNamespaceId(d,a._namespaceIndex);return p===null?null:{namespaceId:p,mainTitle:y}}adoptNamespaceFromTitle(){const c=this.parseTitlePrefix(ae(this,s));c&&(Le(this,s,c.mainTitle),Le(this,o,c.namespaceId))}fixNSByTitle(){const c=ae(this,s).indexOf(":");if(c!==-1){if(c===0){Le(this,s,ae(this,s).substring(1));return}this.adoptNamespaceFromTitle()}}getNamespaceInfo(){return a._meta.namespaces[ae(this,o)]??kt.getDefaultNamespaceInfo(ae(this,o))}resolveSpecialFullTitle(){if(ae(this,o)!==-1)return null;const c=cn.findSpecialPageRealName(ae(this,s),a._specialPageIndex);if(!c)return null;const u=ae(this,s).includes("/")?ae(this,s).substring(ae(this,s).indexOf("/")):"";return c+u}formatMainForOutput(c){const u=this.getNamespaceInfo(),y=this.resolveSpecialFullTitle()??ae(this,s),p=c==="db"?ln.toDBKey(y):ln.toNormalText(y);return ln.ensureCase(p,u.case)}getMainDBKey(){return this.formatMainForOutput("db")}getMainText(){return this.formatMainForOutput("text")}getMainRootText(){return this.getMainText().split("/")[0]}getPrefixedDBKey(){return ae(this,o)===0?this.getMainDBKey():`${this.getNamespaceDBKey()}:${this.getMainDBKey()}`}getPrefixedText(){return ae(this,o)===0?this.getMainText():`${this.getNamespaceText()}:${this.getMainText()}`}getNamespaceId(){return ae(this,o)}getNamespaceText(){return this.getNamespaceInfo().name??""}getNamespaceDBKey(){const c=this.getNamespaceInfo();return ln.ensureCase(ln.toDBKey(this.getNamespaceText()),c.case)}getSubjectPage(){if(kt.isTalkPage(ae(this,o))){const c=ae(this,o)-1;return new a(ae(this,s),c)}return this}getTalkPage(){if(kt.isTalkPage(ae(this,o)))return this;if(ae(this,o)<0)return null;const c=ae(this,o)+1;return a._meta.namespaces[c.toString()]?new a(ae(this,s),c):null}getURL(c){const u=this.getPrefixedDBKey();return this.buildArticleURL(u,c)}buildArticleURL(c,u){const y=a._meta.general.articlepath.replace("$1",c),p=new URL(y,location.origin);return u&&(u instanceof URLSearchParams?u:new URLSearchParams(u)).forEach((w,x)=>{p.searchParams.set(x,w)}),p}setTitle(c){Le(this,s,c);const u=ae(this,o);Le(this,o,0);const d=this.parseTitlePrefix(ae(this,s));return d?(u!==0&&d.namespaceId===u?(Le(this,s,d.mainTitle),Le(this,o,u)):(Le(this,s,d.mainTitle),Le(this,o,d.namespaceId)),this):this}setMainText(c){return Le(this,s,c),this}setNamespaceText(c){const u=kt.findNamespaceId(c,a._namespaceIndex);return u!==null&&Le(this,o,u),this}setNamespaceId(c){return Le(this,o,c),this}equals(c){return typeof c=="string"&&(c=new a(c)),this.getPrefixedDBKey()===c.getPrefixedDBKey()}isSpecial(c){if(ae(this,o)!==-1)return!1;const u=new a(c,-1);return this.getMainRootText()===u.getMainRootText()}toJSON(){return{ns:ae(this,o),text:this.getMainText(),title:this.getPrefixedText(),url:this.getURL().toString(),isSpecial:ae(this,o)<0}}};s=new WeakMap,o=new WeakMap,a._meta=t,a._namespaceIndex=i,a._specialPageIndex=n;let r=a;return Cl.set(t,r),r}const Mn=class Mn 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=Kp(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:n,pageId:r,revId:s}=e??{};if(typeof n=="string")return this.newTitle(n);let o,a;if(s?(o=parseInt(s.toString(),10),a="revid"):r&&(o=parseInt(r.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:l,resolve:c,reject:u}=re();this._cachedTitles.set(`${a}:${o}`,l);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}`);c(this.newTitle(y.title))}catch(d){this._cachedTitles.delete(`${a}:${o}`),u(d)}return l}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 n,r,s="view";const o=i.getMainDBKey().split("/").slice(1).join("/")||"";if(i.isSpecial("edit")&&o)n=o,s="edit";else if(i.isSpecial("talkpage")&&o){const a=i.newTitle(o).getTalkPage();if(!a)return null;n=a.getPrefixedDBKey()}else if(i.isSpecial("mypage"))n=i.newTitle(this.ctx.wiki.userInfo.name,2).getPrefixedDBKey()+(o?`/${o}`:"");else if(i.isSpecial("mytalk"))n=i.newTitle(this.ctx.wiki.userInfo.name,3).getPrefixedDBKey()+(o?`/${o}`:"");else if(i.isSpecial("newsection")&&o)n=o,r="new",s="edit";else return null;return{title:new this.Title(n),section:r,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:!Mn.REG_SKIPPED_HREF.test(e)}parseWikiLink(e){if(!e||typeof e=="string"&&!this.validateHrefAttr(e))return null;const i=xl(e);if(!this.isWikiLink(i.toString()))return null;const n=i.searchParams,r=i.hash.replace("#",""),s=n.get("action")||"view",o=n.get("title")||"",a=parseInt(n.get("curid")||"0",10),l=parseInt(n.get("oldid")||"0",10);let c=o||(()=>{try{return decodeURIComponent(i.pathname.substring(this.wikiArticlePath.length))}catch(p){return this.logger.error("parseLink",i,p),""}})();c.endsWith("index.php")&&(c="");let u,d,y;if(l)y=l;else if(a)d=a;else if(c)u=this.newTitle(c);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:n,hash:r,action:s}}};Mn.inject=["wiki","wikiPage"],Mn.REG_SKIPPED_HREF=/^(#|javascript:|vbscript:|file:)/i;let Ks=Mn;const Rl=t=>typeof t=="function";async function Wp(t){return Rl(t)?await t():t}function Il(t){return Rl(t)?t():t}var Vp=Object.create,Ws=Object.defineProperty,Gp=Object.getOwnPropertyDescriptor,Al=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ol=t=>{throw TypeError(t)},Qp=(t,e,i)=>e in t?Ws(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Yp=(t,e)=>Ws(t,"name",{value:e,configurable:!0}),Xp=t=>[,,,Vp(t?.[Al("metadata")]??null)],Jp=["class","method","getter","setter","accessor","field","value","get","set"],Tl=t=>t!==void 0&&typeof t!="function"?Ol("Function expected"):t,Zp=(t,e,i,n,r)=>({kind:Jp[t],name:e,metadata:n,addInitializer:s=>i._?Ol("Already initialized"):r.push(Tl(s||null))}),eg=(t,e)=>Qp(e,Al("metadata"),t[3]),tg=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},ig=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Gp(r,i));Yp(r,i);for(var f=n.length-1;f>=0;f--)l=Zp(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,Tl(o)&&(r=o);return eg(t,r),p&&Ws(r,i,p),u?c^4?s:p:r},Ll,Vs,Nl;Ll=[be(["storage","wiki"])];class sr extends(Nl=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 r=this.defaultOf(e);return this.logger.debug(e,`(fallback value: ${r})`),r});const n=await this.db.get(e,void 0);return n!==null?n:await Wp(i)}async getAll(){const e=this.loadDefaultConfigs();for await(const[i,n]of this.db.entries())i!=="_touched"&&i in e&&(e[i]=n.value);return e}async set(e,i){return(await this.setMany({[e]:i}))[e]}async setMany(e){const i=this.loadDefaultConfigs(),n={};for(const[r,s]of Object.entries(e))s===i[r]||s===void 0?n[r]=void 0:n[r]=s;return await this.db.set(n),this.ctx.emit("preferences/changed",{ctx:this.ctx,input:e,changes:n}),n}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(),n={};return Object.entries(i).sort(([r],[s])=>r.localeCompare(s)).forEach(([r,s])=>{const o=e[r];o!==void 0&&o!==s&&(n[r]=o)}),n}loadDefaultConfigs(){const e={};return this.getConfigRegistries().forEach(i=>{try{const n=i.schema({});Object.entries(n).forEach(([r,s])=>{e[r]=s})}catch{}}),Object.entries(e).forEach(([i,n])=>{this._defaultPreferences[i]=n}),e}registerCustomConfig(e,i,n){const r={name:e,schema:i,category:n||"general"},s=this.customRegistries.findIndex(o=>o.name===e);return s>=0?this.customRegistries[s]=r:this.customRegistries.push(r),this}getConfigRegistries(e){return Array.from(this.ctx.registry.entries()).map(([i])=>i===null?{name:"@root",schema:Ri?.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(n=>n.name===e.name);return i<0?this.categoryDefinitions.push(e):this.categoryDefinitions[i]=e,this.categoryDefinitions.sort((n,r)=>(n.index??0)-(r.index??0)),this}getConfigCategories(){return this.categoryDefinitions}async _migrageFromLegacyMasterDB(){const e=this.ctx.storage.createDatabase("preferences",1/0);let i=0;for await(const[n,r]of e.entries())n!=="_touched"&&(await this.db.set(n,r.value),i++);return i&&this.logger.info(`Migrated ${i} preferences from master DB`),await e.clear(),await e?.db?.disconnect?.(),i}}Vs=Xp(Nl),sr=ig(Vs,0,"PreferencesService",Ll,sr),tg(Vs,1,sr);var St=(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))(St||{});const Ml="",Dl="",ng=/\\\{/g,rg=/\\\}/g,sg=new RegExp(Ml,"g"),og=new RegExp(Dl,"g");function jl(t){const e=t?{...t}:void 0;return(n,...r)=>ag(e,n,...r)}function ag(t,e,...i){if(!e)return"";let n=String(e).replace(ng,Ml).replace(rg,Dl),r={},s=[];i.length===1&&Array.isArray(i[0])?s=i[0]:i.length===1&&lg(i[0])?r=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(r&&Object.keys(r).length)for(const a of Object.keys(r))o[a]=r[a];if(t&&Object.keys(t).length)for(const a of Object.keys(t))typeof o[a]>"u"&&(o[a]=t[a]);return n=n.replace(/\{\{\s*([\s\S]*?)\s*\}\}/g,(a,l)=>{const c=String(l).trim();if(!c)return"";try{const u=cg(c,o);return u==null?"":String(u)}catch{return""}}),n.replace(sg,"{").replace(og,"}")}function lg(t){return typeof t=="object"&&t!==null&&t.constructor===Object}const cg=ug();function ug(){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",n)}get(e){if(this.ctx[U.internal][e]?.type!=="service")return;const n=this.ctx[U.isolate][e],r=this.ctx[U.store][n]?.value;return Ct(this.ctx,r)}set(e,i){this.provide(e);const n=this.ctx[U.isolate][e],r=this.ctx[U.store][n]?.value;i??(i=void 0);let s=X(()=>{},"dispose");if(r===i)return s;if(!Ce(i)&&!Ce(r))throw new Error(`service ${e} has been registered`);const o=this.ctx;Ce(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][n]={value:i,source:o},o.emit(a,"internal/service",e,r),s}provide(e,i,n){const r=this.ctx.root[U.internal];if(e in r)return;const s=Symbol(e);r[e]={type:"service",builtin:n},this.ctx.root[U.isolate][e]=s,_s(i)&&(this.ctx[U.store][s]={value:i,source:null},qe(i,U.tracker,{associate:e,property:"ctx"}))}_accessor(e,i){const n=this.ctx.root[U.internal];return e in n?()=>{}:(n[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 n=this.ctx.root[U.internal];if(!(e in n))for(const r of i)n[r]||(n[r]={type:"alias",name:e})}_mixin(e,i){const n=Array.isArray(i)?i.map(o=>[o,o]):Object.entries(i),r=typeof e=="string"?o=>o[e]:()=>e,s=n.map(([o,a])=>this._accessor(a,{get(c){const l=r(this);if(Ce(l))return l;const u=c?un(c,l):l,d=Reflect.get(l,o,u);return typeof d!="function"?d:d.bind(u??l)},set(c,l){const u=r(this),d=l?un(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 Ct(this.ctx,e)}bind(e){return new Proxy(e,{apply:X((i,n,r)=>i.apply(this.trace(n),r.map(s=>this.trace(s))),"apply")})}},X(bt,"ReflectService"),D(bt,"handler",{get:X((e,i,n)=>{if(typeof i!="string")return Reflect.get(e,i,n);if(Reflect.has(e,i))return Ct(n,Reflect.get(e,i,n),!0);const[r,s]=bt.resolveInject(e,i),o=new Error(`property ${r} is not registered, declare it as \`inject\` to suppress this warning`);return s?s.type==="accessor"?s.get.call(n,n[U.receiver]):(s.builtin||bt.checkInject(n,r,o),n.reflect.get(r)):(bt.checkInject(n,r,o),Reflect.get(e,r,n))},"get"),set:X((e,i,n,r)=>{if(typeof i!="string")return Reflect.set(e,i,n,r);const[s,o]=bt.resolveInject(e,i);return o?o.type==="accessor"?o.set?o.set.call(r,n,r[U.receiver]):!1:(r.reflect.set(s,n),!0):Reflect.set(e,s,n,r)},"set"),has:X((e,i)=>{if(typeof i!="string")return Reflect.has(e,i);if(Reflect.has(e,i))return!0;const[,n]=bt.resolveInject(e,i);return!!n},"has")}),bt),$s=hh;function Es(t){return t!==null&&t!==!1&&t!==void 0}X(Es,"isBailed");var ph=(Zi=class{constructor(e){D(this,"isActive",!1);D(this,"_tasks",new Set);D(this,"_hooks",{});this.ctx=e,qe(this,U.tracker,{associate:"lifecycle",property:"ctx"}),qe(this.on("internal/listener",function(n,r,s){const o=s.prepend?"unshift":"push";if(n==="ready")return this.lifecycle.isActive?(this.scope.ensure(async()=>r()),()=>!1):void 0;if(n==="dispose")return this.scope.disposables[o](r),qe(r,"name","event <dispose>"),()=>si(this.scope.disposables,r);if(n==="fork")return this.scope.runtime.forkables[o](r),this.scope.collect("event <fork>",()=>si(this.scope.runtime.forkables,r))}),Ze.static,e.scope);for(const n of["info","error","warning"])qe(this.on(`internal/${n}`,(r,...s)=>{this._hooks[`internal/${n}`].length>1}),Ze.static,e.scope);qe(this.on("internal/before-service",function(n){for(const r of this.registry.values()){if(!r.inject[n]?.required)continue;const s=r.isReusable?r.children:[r];for(const o of s)this[U.filter](o.ctx)&&(o.updateStatus(),o.reset())}},{global:!0}),Ze.static,e.scope),qe(this.on("internal/service",function(n){for(const r of this.registry.values()){if(!r.inject[n]?.required)continue;const s=r.isReusable?r.children:[r];for(const o of s)this[U.filter](o.ctx)&&o.start()}},{global:!0}),Ze.static,e.scope);const i=X((n,r)=>{if(!n.runtime.plugin)return!1;for(const s in n.runtime.inject)if(r===$s.resolveInject(n.ctx,s)[0])return!0;return i(n.parent.scope,r)},"checkInject");qe(this.on("internal/inject",function(n){return i(this.scope,n)},{global:!0}),Ze.static,e.scope)}async flush(){for(;this._tasks.size;)await Promise.all(Array.from(this._tasks))}filterHooks(e,i){return i=Ct(this.ctx,i),e.slice().filter(n=>{const r=i?.[Ze.filter];return n.global||!r||r.call(i,n.ctx)})}*dispatch(e,i){const n=typeof i[0]=="object"||typeof i[0]=="function"?i.shift():null,r=i.shift();r!=="internal/event"&&this.emit("internal/event",e,r,i,n);for(const s of this.filterHooks(this._hooks[r]||[],n))yield s.callback.apply(n,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(Es(i))return i}bail(...e){for(const i of this.dispatch("bail",e))if(Es(i))return i}register(e,i,n,r){const s=r.prepend?"unshift":"push";return i[s]({ctx:this.ctx,callback:n,...r}),this.ctx.state.collect(e,()=>this.unregister(i,n))}unregister(e,i){const n=e.findIndex(r=>r.callback===i);if(n>=0)return e.splice(n,1),!0}on(e,i,n){var a;typeof n!="object"&&(n={prepend:n}),this.ctx.scope.assertActive(),i=this.ctx.reflect.bind(i);const r=this.bail(this.ctx,"internal/listener",e,i,n);if(r)return r;const s=(a=this._hooks)[e]||(a[e]=[]),o=typeof e=="string"?`event <${e}>`:"event (Symbol)";return this.register(o,s,i,n)}once(e,i,n){const r=this.on(e,function(...s){return r(),i.apply(this,s)},n);return r}async start(){this.isActive=!0;const e=this._hooks.ready||[];for(;e.length;){const{ctx:i,callback:n}=e.shift();i.scope.ensure(async()=>n())}await this.flush()}async stop(){this.isActive=!1,this.ctx.scope.reset()}},X(Zi,"Lifecycle"),Zi),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||{});Q.CordisError=(Ai=class extends Error{constructor(e,i){super(i??Ai.Code[e]),this.code=e}},X(Ai,"CordisError"),Ai),(t=>{t.Code={INACTIVE_EFFECT:"cannot create effect on inactive context"}})(Q.CordisError||(Q.CordisError={}));var Ps=(en=class{constructor(e,i){D(this,"uid");D(this,"ctx");D(this,"disposables",[]);D(this,"error");D(this,"status",0);D(this,"isActive",!1);D(this,"context");D(this,"proxy");D(this,"acceptors",[]);D(this,"tasks",new Set);D(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((n,r)=>Reflect.get(this.config,r),"get")})}get _config(){return this.runtime.isReactive?this.proxy:this.config}assertActive(){if(!(this.uid!==null||this.isActive))throw new Q.CordisError("INACTIVE_EFFECT")}effect(e,i){this.assertActive();const n=vs(e)?new e(this.ctx,i):e(this.ctx,i);let r=!1;const s=typeof n=="function"?n:n.dispose.bind(n),o=X((...a)=>{if(!r)return r=!0,si(this.disposables,o),s(...a)},"wrapped");return this.disposables.push(o),typeof n=="function"?o:(n.dispose=o,n)}collect(e,i){const n=qe(()=>(si(this.disposables,n),i()),"name",e);return this.disposables.push(n),n}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(n=>{this.context.emit(this.ctx,"internal/error",n),this.cancel(n)}).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||!Ce(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 n={keys:Array.isArray(e[0])?e.shift():null,callback:e[0],...e[1]};return this.effect(()=>(this.acceptors.push(n),n.immediate&&n.callback?.(this.config),()=>si(this.acceptors,n)))}decline(e){return this.accept(e,()=>!0)}checkUpdate(e,i){if(i||!this.config)return[!0,!0];if(i===!1)return[!1,!1];const n=Object.create(null),r=X(l=>{const u=n[l]??(n[l]=!gi(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=r(h));if(!p)continue}u?.(e)&&(a=!0)}for(const l in{...this.config,...e})if(c!==!1&&!(l in n)&&!s.has(l)){const u=r(l);c===null&&(a||(a=u))}return[o,a]}},X(en,"EffectScope"),en),Ja=(tn=class extends Ps{constructor(i,n,r,s){super(i,r);D(this,"dispose");this.runtime=n,this.dispose=qe(i.scope.collect(`fork <${i.runtime.name}>`,()=>{this.uid=null,this.reset(),this.context.emit("internal/fork",this);const o=si(n.disposables,this.dispose);return si(n.children,this)&&!n.children.length&&i.registry.delete(n.plugin),o}),Ze.static,n),n.children.push(this),n.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,n){const r=this.config,s=this.runtime.isForkable?this:this.runtime;if(s.config!==r)return;let o;try{o=cn(this.runtime.plugin,i)}catch(l){return this.context.emit("internal/error",l),this.cancel(l)}const[a,c]=s.checkUpdate(o,n);this.context.emit("internal/before-update",this,i),this.config=o,s.config=o,a&&this.context.emit("internal/update",this,r),c&&s.restart()}},X(tn,"ForkScope"),tn),Cs=(nn=class extends Ps{constructor(i,n,r,s){super(i,r);D(this,"value");D(this,"runtime",this);D(this,"schema");D(this,"name");D(this,"inject",Object.create(null));D(this,"forkables",[]);D(this,"children",[]);D(this,"isReusable",!1);D(this,"isReactive",!1);D(this,"apply",X((i,n)=>{if(typeof this.plugin!="function")return this.plugin.apply(i,n);if(vs(this.plugin)){const r=new this.plugin(i,n),s=r[Ze.expose];return s&&i.set(s,r),r.fork&&this.forkables.push(r.fork.bind(r)),r}else return this.plugin(i,n)},"apply"));this.plugin=n,n?(this.setup(),this.init(s)):(this.name="root",this.isActive=!0)}get isForkable(){return this.forkables.length>0}fork(i,n,r){return new Ja(i,this,n,r)}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,n){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 r=this.config;let s;try{s=cn(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,n),c=this.children.find(l=>l.config===r);this.config=s,c&&(this.context.emit("internal/before-update",c,i),c.config=s,o&&this.context.emit("internal/update",c,r)),a&&this.restart()}},X(nn,"MainScope"),nn);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 n=this[U.tracker]?.property;if(!n)throw new Error("missing context tracker");this[n].inject(t,r=>{e.call(un(this,{[n]:r}))})});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:n,optional:r,...s}=i;return Array.isArray(n)&&Object.assign(s,Object.fromEntries(n.map(o=>[o,{required:!0}]))),Array.isArray(r)&&Object.assign(s,Object.fromEntries(r.map(o=>[o,{required:!1}]))),s}t.resolve=e,X(e,"resolve")})(xe||(xe={}));var gh=(rn=class{constructor(e,i){D(this,"_counter",0);D(this,"_internal",new Map);D(this,"context");this.ctx=e,qe(this,U.tracker,{associate:"registry",property:"ctx"}),this.context=e;const n=new Cs(e,null,i);e.scope=n,n.ctx=e,this.set(null,n)}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 n=this.resolve(e);this._internal.set(n,i)}delete(e){const i=this.resolve(e),n=i&&this._internal.get(i);if(n)return this._internal.delete(i),n.dispose(),n}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,n){if(this.resolve(e,!0),this.ctx.scope.assertActive(),!n)try{i=cn(e,i)}catch(s){this.context.emit(this.ctx,"internal/error",s),n=s,i=null}let r=this.get(e);return r?(r.isForkable||this.context.emit(this.ctx,"internal/warning",new Error(`duplicate plugin detected: ${e.name}`)),r.fork(this.ctx,i,n)):(r=new Cs(this.ctx,e,i,n),this.set(e,r),r.fork(this.ctx,i,n))}},X(rn,"Registry"),rn),mh=gh,Ze=(Le=class{static is(e){return!!e?.[Le.is]}static associate(e,i){return e}constructor(e){e=cn(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,$s.handler);i.root=i,i.reflect=new $s(i),i.registry=new mh(i,e),i.lifecycle=new Ya(i);const n=X(r=>{if(r){n(Object.getPrototypeOf(r));for(const s of Object.getOwnPropertyNames(r)){const o=r[s].prototype?.constructor;o&&(i[r[s].key]=new o(i,e),qe(i[r[s].key],"ctx",i))}}},"attach");return n(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,n=Object.assign(Object.create(Ct(this,this)),e);return i?Object.assign(Object.create(n),{[U.shadow]:i}):n}isolate(e,i){const n=Object.create(this[U.isolate]);return n[e]=i??Symbol(e),this.extend({[U.isolate]:n})}intercept(e,i){const n=Object.create(this[U.intercept]);return n[e]=i,this.extend({[U.intercept]:n})}},X(Le,"Context"),D(Le,"store",U.store),D(Le,"events",U.events),D(Le,"static",U.static),D(Le,"filter",U.filter),D(Le,"expose",U.expose),D(Le,"isolate",U.isolate),D(Le,"internal",U.internal),D(Le,"intercept",U.intercept),D(Le,"origin","ctx"),D(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 pt=(dt=class{constructor(...e){D(this,"ctx");D(this,"name");D(this,"config");let i,n,r,s;Ze.is(e[0])?(i=e[0],typeof e[1]=="string"?(n=e[1],r=e[2]):s=e[1]):s=e[0],n??(n=this.constructor[U.provide]),r??(r=this.constructor[U.immediate]);let o=this;const a={associate:n,property:"ctx"};return o[U.invoke]&&(o=Ss(n,ws(Object.getPrototypeOf(this),Function.prototype),a)),i?o.ctx=i:o[U.setup](),o.name=n,o.config=s,qe(o,U.tracker,a),o.ctx.provide(n),o.ctx.runtime.name=n,r&&(i?o[U.expose]=n:o.ctx.set(n,o)),o.ctx.on("ready",async()=>{await Promise.resolve(),await o.start(),r||o.ctx.set(n,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[dt.invoke]?i=Ss(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(dt,"Service"),D(dt,"setup",U.setup),D(dt,"invoke",U.invoke),D(dt,"extend",U.extend),D(dt,"tracker",U.tracker),D(dt,"provide",U.provide),D(dt,"immediate",U.immediate),dt),yh=Object.defineProperty,bh=Object.getOwnPropertyNames,ne=(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 E;var i=Symbol.for("schemastery"),n=Symbol.for("ValidationError");globalThis.__schemastery_index__??(globalThis.__schemastery_index__=0),globalThis.__schemastery_refs__=void 0;var r=(E=class extends TypeError{constructor(g,w){let S="$";for(const R of w.path||[])typeof R=="string"?S+="."+R:typeof R=="number"?S+="["+R+"]":typeof R=="symbol"&&(S+=`[Symbol(${R.toString()})]`);S.startsWith(".")&&(S=S.slice(1));super((S==="$"?"":`${S} `)+g);D(this,"name","ValidationError");this.options=w}static is(g){return!!g?.[n]}},ne(E,"ValidationError"),E);Object.defineProperty(r.prototype,n,{value:!0});var s=ne(function(y){const b=ne(function(g,w={}){return s.resolve(g,b,w)[0]},"schema");if(y.refs){const g=Kt(y.refs,S=>new s(S)),w=ne(S=>g[S],"getRef");for(const S in g){const R=g[S];R.sKey=w(R.sKey),R.inner=w(R.inner),R.list=R.list&&R.list.map(w),R.dict=R.dict&&Kt(R.dict,w)}return g[y.uid]}if(Object.assign(b,y),typeof b.callback=="string")try{b.callback=new Function("return "+b.callback)()}catch{}return Object.defineProperty(b,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(b,s.prototype),b.meta||(b.meta={}),b.toString=b.toString.bind(b),b},"Schema");s.prototype=Object.create(Function.prototype),s.prototype[i]=!0,s.ValidationError=r,s.prototype.toJSON=ne(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 b={uid:this.uid,refs:globalThis.__schemastery_refs__};return globalThis.__schemastery_refs__=void 0,b},"toJSON"),s.prototype.set=ne(function(b,g){return this.dict[b]=g,this},"set"),s.prototype.push=ne(function(b){return this.list.push(b),this},"push");function o(y,b){const g=typeof y=="string"?{"":y}:{...y};for(const w in b){const S=b[w];S?.$description||S?.$desc?g[w]=S.$description||S.$desc:typeof S=="string"&&(g[w]=S)}return g}ne(o,"mergeDesc");function a(y){return y?.$value??y?.$inner}ne(a,"getInner");function c(y){return qa(y??{},b=>!b.startsWith("$"))}ne(c,"extractKeys"),s.prototype.i18n=ne(function(b){const g=s(this),w=o(g.meta.description,b);return Object.keys(w).length&&(g.meta.description=w),g.dict&&(g.dict=Kt(g.dict,(S,R)=>S.i18n(Kt(b,B=>a(B)?.[R]??B?.[R])))),g.list&&(g.list=g.list.map((S,R)=>S.i18n(Kt(b,(B={})=>Array.isArray(a(B))?a(B)[R]:Array.isArray(B)?B[R]:c(B))))),g.inner&&(g.inner=g.inner.i18n(Kt(b,S=>a(S)?a(S):c(S)))),g.sKey&&(g.sKey=g.sKey.i18n(Kt(b,S=>S?.$key))),g},"i18n"),s.prototype.extra=ne(function(b,g){const w=s(this);return w.meta={...w.meta,[b]:g},w},"extra");for(const y of["required","disabled","collapse","hidden","loose"])Object.assign(s.prototype,{[y](b=!0){const g=s(this);return g.meta={...g.meta,[y]:b},g}});s.prototype.deprecated=ne(function(){var g;const b=s(this);return(g=b.meta).badges||(g.badges=[]),b.meta.badges.push({text:"deprecated",type:"danger"}),b},"deprecated"),s.prototype.experimental=ne(function(){var g;const b=s(this);return(g=b.meta).badges||(g.badges=[]),b.meta.badges.push({text:"experimental",type:"warning"}),b},"experimental"),s.prototype.pattern=ne(function(b){const g=s(this),w=za(b,["source","flags"]);return g.meta={...g.meta,pattern:w},g},"pattern"),s.prototype.simplify=ne(function(b){if(gi(b,this.meta.default,this.type==="dict"))return null;if(Ce(b))return b;if(this.type==="object"||this.type==="dict"){const g={};for(const w in b){const R=(this.type==="object"?this.dict[w]:this.inner)?.simplify(b[w]);(this.type==="dict"||!Ce(R))&&(g[w]=R)}return gi(g,this.meta.default,this.type==="dict")?null:g}else if(this.type==="array"||this.type==="tuple"){const g=[];return b.forEach((w,S)=>{const R=this.type==="array"?this.inner:this.list[S],B=R?R.simplify(w):w;g.push(B)}),g}else if(this.type==="intersect"){const g={};for(const w of this.list)Object.assign(g,w.simplify(b));return g}else if(this.type==="union")for(const g of this.list)try{return s.resolve(b,g,{}),g.simplify(b)}catch{}return b},"simplify"),s.prototype.toString=ne(function(b){return x[this.type]?.(this,b)??`Schema<${this.type}>`},"toString"),s.prototype.role=ne(function(y,b){const g=s(this);return g.meta={...g.meta,role:y,extra:b},g},"role");for(const y of["default","link","comment","description","max","min","step"])Object.assign(s.prototype,{[y](b){const g=s(this);return g.meta={...g.meta,[y]:b},g}});var l={};s.extend=ne(function(b,g){l[b]=g},"extend"),s.resolve=ne(function(b,g,w={},S=!1){if(!g)return[b];if(w.ignore?.(b,g))return[b];if(Ce(b)&&g.type!=="lazy"){if(g.meta.required)throw new r("missing required value",w);let B=g,N=g.meta.default;for(;B?.type==="intersect"&&Ce(N);)B=B.list[0],N=B?.meta.default;if(Ce(N))return[b];b=Zn(N)}const R=l[g.type];if(!R)throw new r(`unsupported type "${g.type}"`,w);try{return R(b,g,w,S)}catch(B){if(!g.meta.loose)throw B;return[g.meta.default]}},"resolve"),s.from=ne(function(b){if(Ce(b))return s.any();if(["string","number","boolean"].includes(typeof b))return s.const(b).required();if(b[i])return b;if(typeof b=="function")switch(b){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(b).required()}else throw new TypeError(`cannot infer schema from ${b}`)},"from"),s.lazy=ne(function(b){const g=ne(()=>(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:b,inner:{toJSON:g}});return w},"lazy"),s.natural=ne(function(){return s.number().step(1).min(0)},"natural"),s.percent=ne(function(){return s.number().step(.01).min(0).max(1).role("slider")},"percent"),s.date=ne(function(){return s.union([s.is(Date),s.transform(s.string().role("datetime"),(b,g)=>{const w=new Date(b);if(isNaN(+w))throw new r(`invalid date "${b}"`,g);return w},!0)])},"date"),s.regExp=ne(function(b=""){return s.union([s.is(RegExp),s.transform(s.string().role("regexp",{flag:b}),(g,w)=>{try{return new RegExp(g,b)}catch(S){throw new r(S.message,w)}},!0)])},"regExp"),s.arrayBuffer=ne(function(b){return s.union([s.is(ArrayBuffer),s.is(SharedArrayBuffer),s.transform(s.any(),(g,w)=>{if(Pt.isSource(g))return Pt.fromSource(g);throw new r(`expected ArrayBufferSource but got ${g}`,w)},!0),...b?[s.transform(s.string(),(g,w)=>{try{return b==="base64"?Pt.fromBase64(g):Pt.fromHex(g)}catch(S){throw new r(S.message,w)}},!0)]:[]])},"arrayBuffer"),s.extend("lazy",(y,b,g,w)=>(b.inner[i]||(b.inner=b.builder(),b.inner.meta={...b.meta,...b.inner.meta}),s.resolve(y,b.inner,g,w))),s.extend("any",y=>[y]),s.extend("never",(y,b,g)=>{throw new r(`expected nullable but got ${y}`,g)}),s.extend("const",(y,{value:b},g)=>{if(gi(y,b))return[b];throw new r(`expected ${b} but got ${y}`,g)});function u(y,b,g,w,S=!1){const{max:R=1/0,min:B=-1/0}=b;if(y>R)throw new r(`expected ${g} <= ${R} but got ${y}`,w);if(y<B&&!S)throw new r(`expected ${g} >= ${B} but got ${y}`,w)}ne(u,"checkWithinRange"),s.extend("string",(y,{meta:b},g)=>{if(typeof y!="string")throw new r(`expected string but got ${y}`,g);if(b.pattern){const w=new RegExp(b.pattern.source,b.pattern.flags);if(!w.test(y))throw new r(`expect string to match regexp ${w}`,g)}return u(y.length,b,"string length",g),[y]});function d(y,b){const g=y.toString();if(g.includes("e"))return y*Math.pow(10,b);const w=g.indexOf(".");if(w===-1)return y*Math.pow(10,b);const S=g.slice(w+1),R=g.slice(0,w);return S.length<=b?+(R+S.padEnd(b,"0")):+(R+S.slice(0,b)+"."+S.slice(b))}ne(d,"decimalShift");function m(y,b,g){if(g=Math.abs(g),!/^\d+\.\d+$/.test(g.toString()))return(y-b)%g===0;const w=g.toString().indexOf("."),S=g.toString().slice(w+1).length;return Math.abs(d(y,S)-d(b,S))%d(g,S)===0}ne(m,"isMultipleOf"),s.extend("number",(y,{meta:b},g)=>{if(typeof y!="number")throw new r(`expected number but got ${y}`,g);u(y,b,"number",g);const{step:w}=b;if(w&&!m(y,b.min??0,w))throw new r(`expected number multiple of ${w} but got ${y}`,g);return[y]}),s.extend("boolean",(y,b,g)=>{if(typeof y=="boolean")return[y];throw new r(`expected boolean but got ${y}`,g)}),s.extend("bitset",(y,{bits:b,meta:g},w)=>{let S=0,R=[];if(typeof y=="number"){S=y;for(const B in b)y&b[B]&&R.push(B)}else if(Array.isArray(y)){R=y;for(const B of R){if(typeof B!="string")throw new r(`expected string but got ${B}`,w);B in b&&(S|=b[B])}}else throw new r(`expected number or array but got ${y}`,w);return S===g.default?[S]:[S,R]}),s.extend("function",(y,b,g)=>{if(typeof y=="function")return[y];throw new r(`expected function but got ${y}`,g)}),s.extend("is",(y,{constructor:b},g)=>{if(typeof b=="function"){if(y instanceof b)return[y];throw new r(`expected ${b.name} but got ${y}`,g)}else{if(Ce(y))throw new r(`expected ${b} but got ${y}`,g);let w=Object.getPrototypeOf(y);for(;w;){if(w.constructor?.name===b)return[y];w=Object.getPrototypeOf(w)}throw new r(`expected ${b} but got ${y}`,g)}});function p(y,b,g,w){try{const[S,R]=s.resolve(y[b],g,{...w,path:[...w.path||[],b]});return R!==void 0&&(y[b]=R),S}catch(S){if(!w?.autofix)throw S;return delete y[b],g.meta.default}}ne(p,"property"),s.extend("array",(y,{inner:b,meta:g},w)=>{if(!Array.isArray(y))throw new r(`expected array but got ${y}`,w);return u(y.length,g,"array length",w,!Ce(b.meta.default)),[y.map((S,R)=>p(y,R,b,w))]}),s.extend("dict",(y,{inner:b,sKey:g},w,S)=>{if(!Jn(y))throw new r(`expected object but got ${y}`,w);const R={};for(const B in y){let N;try{N=s.resolve(B,g,w)[0]}catch(Y){if(S)continue;throw Y}R[N]=p(y,B,b,w),y[N]=y[B],B!==N&&delete y[B]}return[R]}),s.extend("tuple",(y,{list:b},g,w)=>{if(!Array.isArray(y))throw new r(`expected array but got ${y}`,g);const S=b.map((R,B)=>p(y,B,R,g));return w?[S]:(S.push(...y.slice(b.length)),[S])});function h(y,b){for(const g in b)g in y||(y[g]=b[g])}ne(h,"merge"),s.extend("object",(y,{dict:b},g,w)=>{if(!Jn(y))throw new r(`expected object but got ${y}`,g);const S={};for(const R in b){const B=p(y,R,b[R],g);(!Ce(B)||R in y)&&(S[R]=B)}return w||h(S,y),[S]}),s.extend("union",(y,{list:b,toString:g},w,S)=>{for(const R of b)try{return s.resolve(y,R,w,S)}catch{}throw new r(`expected ${g()} but got ${JSON.stringify(y)}`,w)}),s.extend("intersect",(y,{list:b,toString:g},w,S)=>{if(!b.length)return[y];let R;for(const B of b){const N=s.resolve(y,B,w,!0)[0];if(!Ce(N))if(Ce(R))R=N;else{if(typeof R!=typeof N)throw new r(`expected ${g()} but got ${JSON.stringify(y)}`,w);if(typeof N=="object")h(R??(R={}),N);else if(R!==N)throw new r(`expected ${g()} but got ${JSON.stringify(y)}`,w)}}return!S&&Jn(y)&&h(R,y),[R]}),s.extend("transform",(y,{inner:b,callback:g,preserve:w},S)=>{const[R,B=y]=s.resolve(y,b,S,!0);return w?[g(R)]:[g(R),g(B)]});var x={};function k(y,b,g){x[y]=g,Object.assign(s,{[y](...w){const S=new s({type:y});return b.forEach((R,B)=>{switch(R){case"sKey":S.sKey=w[B]??s.string();break;case"inner":S.inner=s.from(w[B]);break;case"list":S.list=w[B].map(s.from);break;case"dict":S.dict=Kt(w[B],s.from);break;case"bits":{S.bits={};for(const N in w[B])typeof w[B][N]=="number"&&(S.bits[N]=w[B][N]);break}case"callback":{const N=S.callback=w[B];N.toJSON||(N.toJSON=()=>N.toString());break}case"constructor":{const N=S.constructor=w[B];typeof N=="function"&&(N.toJSON||(N.toJSON=()=>N.name));break}default:S[R]=w[B]}}),y==="object"||y==="dict"?S.meta.default={}:y==="array"||y==="tuple"?S.meta.default=[]:y==="bitset"&&(S.meta.default=0),S}})}ne(k,"defineMethod"),k("is",["constructor"],({constructor:y})=>typeof y=="function"?y.name:y),k("any",[],()=>"any"),k("never",[],()=>"never"),k("const",["value"],({value:y})=>typeof y=="string"?JSON.stringify(y):y),k("string",[],()=>"string"),k("number",[],()=>"number"),k("boolean",[],()=>"boolean"),k("bitset",["bits"],()=>"bitset"),k("function",[],()=>"function"),k("array",["inner"],({inner:y})=>`${y.toString(!0)}[]`),k("dict",["inner","sKey"],({inner:y,sKey:b})=>`{ [key: ${b.toString()}]: ${y.toString()} }`),k("tuple",["list"],({list:y})=>`[${y.map(b=>b.toString()).join(", ")}]`),k("object",["dict"],({dict:y})=>Object.keys(y).length===0?"{}":`{ ${Object.entries(y).map(([b,g])=>`${b}${g.meta.required?"":"?"}: ${g.toString()}`).join(", ")} }`),k("union",["list"],({list:y},b)=>{const g=y.map(({toString:w})=>w()).join(" | ");return b?`(${g})`:g}),k("intersect",["list"],({list:y})=>`${y.map(b=>b.toString(!0)).join(" & ")}`),k("transform",["inner","callback","preserve"],({inner:y},b)=>y.toString(b)),e.exports=s}});const I=wh();var Is=(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))(Is||{});const Rs=globalThis||window,As=Symbol.for("__IPE_LOGGER_COLOR_MAP__");Rs[As]||(Rs[As]=new Map);const Ts=Rs[As];function ir(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,n=ir(t)%i,[r,s]=el[n],o=s-r,a=ir(t+":"+e),c=r+a%(o||1),l=ir(t+":s"),u=ir(t+":l");let d,m;if(e==="name")d=62+l%18,m=30+u%12;else{const p=c>=0&&c<50||c>330&&c<360,h=c>=200&&c<=300;d=55+l%20,h?m=55+u%8:p?m=48+u%6:m=50+u%8,d<60&&(d+=5)}return`hsl(${c}, ${d}%, ${m}%)`}function nr(t,e){if(e)return Ts.set(t,e),e;const i=Ts.get(t);if(i)return i;const n=t.startsWith("name:")?"name":"group",r=_h(t,n);return Ts.set(t,r),r}let tl=class Bf{constructor(e={}){this._custom=i=>{if(!this._enabled(i.level))return il;const[n,r]=this._prefix(i.label);return this._consoleMethod(i.method).bind(console,n,...r)},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&&nr(`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&&nr(`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=xh[e];if(!this._enabled(i.level))return il;const[n,r]=this._prefix(i.label);return this._consoleMethod(e).bind(console,n,...r)}_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 n="";if(this._name){const r=nr(`name:${this._name}`,this._nameColor);n+=`%c${this._name}%c`,i.push(`background:${r}; color:#fff; padding:1px 4px; border-radius:2px; font-weight:700;`,nl)}if(e&&(n+=` ${e}`),this._groupPath.length){const r=this._groupPath.join("/"),s=nr(`group:${r}`);n+=` %c${r}%c`,i.push(`color:${s}; text-decoration: underline;`,nl)}return[n,i]}};const il=()=>{},nl="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,n){return t.group(i,n)};return new Proxy(e,{get(i,n,r){return t[n]},set(i,n,r){return t[n]=r,!0},apply(i,n,r){return t.group(r[0],r[1])},has(i,n){return n in t}})}function rl(t){return new tl(t)}function Os(t){if(typeof globalThis.structuredClone=="function")try{return globalThis.structuredClone(t)}catch{}return Li(t,new WeakMap)}function Li(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(Li(c,e),Li(a,e))}),o}if(t instanceof Set){const o=new Set;return e.set(t,o),t.forEach(a=>o.add(Li(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]=Li(t[a],e);return o}const n=Object.getPrototypeOf(t),r=Object.create(n);e.set(t,r);const s=Object.getOwnPropertyDescriptors(t);for(const o of Reflect.ownKeys(s)){const a=s[o];"value"in a&&(a.value=Li(a.value,e)),Object.defineProperty(r,o,a)}return r}function It(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 n(...r){return Reflect.apply(i,n,r)}Reflect.setPrototypeOf(n,e);for(const r of Reflect.ownKeys(i)){const s=Reflect.getOwnPropertyDescriptor(i,r);s&&Reflect.defineProperty(n,r,s)}return n};sl.prototype=Object.create(Function.prototype);const Sh=sl;function Rt(t,...e){const i=Os(t||{});for(const n of e)if(n!=null)for(const r of Reflect.ownKeys(n)){const s=n[r];if(typeof s>"u")continue;if(s===null){delete i[r];continue}const o=i[r];It(o)&&It(s)?i[r]=Rt(o,s):i[r]=Os(s)}return i}var at=(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.BODY_TRANSFORM_ERROR="BODY_TRANSFORM_ERROR",t))(at||{});class Ve extends Error{constructor(i,n,r,s){super(n,s);D(this,"name","FexiosError");this.code=i,this.context=r}static is(i,n){return!(i instanceof Ve)||i instanceof Ni?!1:n?i.code===n:!0}}class Ni extends Ve{constructor(i,n,r){super(n.statusText,i,void 0,r);D(this,"name","FexiosResponseError");this.response=n}static is(i){return i instanceof Ni}}var dn;(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[n,r]of e.entries())if(r!=null)if(Array.isArray(r))for(const s of r)s!=null&&i.append(n,String(s));else i.append(n,String(r));return i}if(It(e)){for(const[n,r]of Object.entries(e))if(r!=null)if(Array.isArray(r))for(const s of r)s!=null&&i.append(n,String(s));else i.append(n,String(r));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((n,r)=>{i[r]=i[r]?[...i[r],n]:[n]}),i}if(e instanceof Map){const i={};for(const[n,r]of e.entries())if(r!=null)if(Array.isArray(r)){const s=r.filter(o=>o!=null).map(o=>String(o));s.length&&(i[n]=(i[n]??[]).concat(s))}else{const s=String(r);i[n]=i[n]?[...i[n],s]:[s]}return i}throw new TypeError(`unsupported type transformation, got: ${Object.prototype.toString.call(e)}`)},t.mergeHeaders=(...e)=>{const i=new Headers,n=r=>{for(const[s,o]of Object.entries(r))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 r of e){if(r==null)continue;if(r instanceof Headers){r.forEach((o,a)=>{i.set(a,o)});continue}if(It(r)){n(r);continue}const s=(0,t.toHeaderRecord)(r);for(const[o,a]of Object.entries(s)){i.delete(o);for(const c of a)i.append(o,c)}}return i}})(dn||(dn={}));var gt;(t=>{t.makeSearchParams=n=>{if(!n)return new URLSearchParams;if(n instanceof URLSearchParams)return n;if(typeof n!="object"||n?.constructor!==Object)throw new TypeError("only plain object is supported");const r=new URLSearchParams,s=(c,l)=>{l!=null&&r.append(c,l)},o=(c,l)=>{l!=null&&r.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 m=u.endsWith("[]"),p=m?u.slice(0,-2):u,h=`${c}[${p}]`;if(m){const x=`${h}[]`;if(Array.isArray(d))for(const k of d)s(x,k?.toString());else typeof d=="object"&&d!==null&&d.constructor===Object?a(`${h}[]`,d):s(x,d?.toString())}else if(Array.isArray(d))for(const x of d)s(h,x?.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(n))a(c,l);return r},t.makeQueryString=n=>(0,t.makeSearchParams)(n).toString(),t.makeURL=(n,r,s,o)=>{const a=typeof window<"u"&&window.location?.origin||"http://localhost",c=typeof n=="string"?new URL(n,o??a):new URL(n),l=(0,t.toQueryRecord)(c.searchParams),u=(0,t.mergeQueries)(l,r||{}),d=(0,t.makeSearchParams)(u);return c.search=d.toString(),typeof s<"u"&&(c.hash=s),c},t.toQueryRecord=n=>{typeof n=="string"&&(n=(0,t.fromString)(n));const r={},s=a=>{if(!a.includes("["))return{path:[a],forceArray:!1};const l=[a.slice(0,a.indexOf("["))],u=/\[([^\]]*)\]/g;let d,m=!1,p=!1;for(;d=u.exec(a);)d[1]===""?(m=!0,p=!0):(l.push(d[1]),p=!1);return m&&p&&(l[l.length-1]=l[l.length-1]+"[]"),{path:l,forceArray:m}},o=(a,c,l,u)=>{let d=a;for(let m=0;m<c.length;m++){const p=c[m];m===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 n.entries()){const{path:l,forceArray:u}=s(String(a));o(r,l,c?.toString(),u)}return r},t.fromString=n=>{const r=n.trim();if(!r)return new URLSearchParams;if(r.startsWith("?"))return new URLSearchParams(r.slice(1));const s=r.indexOf("?");if(s>=0){const o=r.indexOf("#",s+1),a=r.slice(s+1,o>=0?o:void 0);return new URLSearchParams(a)}return new URLSearchParams(r)},t.mergeQueries=(...n)=>{const r={};for(const s of n)s!=null&&i(r,e(s));return r};function e(n){if(!n)return{};if(n instanceof URLSearchParams||n instanceof FormData||n instanceof Map)return(0,t.toQueryRecord)(n);if(typeof n=="string")return(0,t.toQueryRecord)((0,t.fromString)(n));if(It(n))return n;throw new TypeError(`unsupported type transformation, got: ${Object.prototype.toString.call(n)}`)}function i(n,r){for(const[s,o]of Object.entries(r)){if(o===void 0)continue;if(o===null){delete n[s];continue}const a=n[s];It(a)&&It(o)?i(a,o):n[s]=Os(o)}}})(gt||(gt={}));class Ls{constructor(e,i,n){D(this,"ok");D(this,"status");D(this,"statusText");D(this,"headers");D(this,"url");D(this,"redirected");this.rawResponse=e,this.data=i,this.responseType=n,["ok","status","statusText","headers","url","redirected"].forEach(r=>{Reflect.defineProperty(this,r,{get:()=>e[r]})})}}const ol=t=>{const e=t.reduce((r,s)=>r+s.length,0),i=new Uint8Array(e);let n=0;for(const r of t)i.set(r,n),n+=r.length;return i};async function $h(t,e,i){const n=t.getReader();if(!n)throw new Ve(at.NO_BODY_READER,"Failed to get ReadableStream from response body");const r=[];let s=0;try{for(;;){const{done:a,value:c}=await n.read();if(a)break;r.push(c),s+=c.length,i&&e>0&&i(s/e,ol(r))}}finally{n.releaseLock?.()}const o=ol(r);return i?.(1,o),o}const Eh=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,n,r){const s=t.headers.get("content-type")?.toLowerCase()??"",o=t.headers.get("content-length"),a=o?Number(o):0,c=t.headers.get("upgrade")?.toLowerCase(),l=t.headers.get("connection")?.toLowerCase();let u=e??Eh(s)??"text";if(e||(c==="websocket"&&l==="upgrade"?u="ws":s.includes("text/event-stream")&&(u="stream")),u==="stream"){const k=t.url||t.url||"",E=await Ph(k,t,r),y=n?.(E);if(typeof y=="boolean"?y:!E.ok)throw new Ni(E.statusText,E);return E}if(u==="ws"){const k=t.url||t.url||"",E=await ll(k,t,r),y=n?.(E);if(typeof y=="boolean"?y:!E.ok)throw new Ni(E.statusText,E);return E}const d=/\bcharset=([^;]+)/i.exec(s)?.[1]?.trim()||"utf-8",m=new TextDecoder(d);let p;try{if(u==="form")p=await t.formData();else{const k=await $h(t.body,a,i);if(u==="arrayBuffer")p=k.buffer.slice(k.byteOffset,k.byteOffset+k.byteLength);else if(u==="blob")p=new Blob([k],{type:s||"application/octet-stream"});else if(u==="text"){const E=m.decode(k);if(e)p=E;else{const y=E.trim();if(y.startsWith("{")&&y.endsWith("}")||y.startsWith("[")&&y.endsWith("]"))try{p=JSON.parse(y),u="json"}catch{p=E}else p=E}}else if(u==="json"){const E=m.decode(k);p=E.length?JSON.parse(E):null}else p=k}}catch(k){if(!(k instanceof Error))throw k;try{p=await t.text(),u="text"}catch{throw new Ve(at.BODY_TRANSFORM_ERROR,`Failed to transform response body to ${u}`,void 0,{cause:k})}}const h=new Ls(t,p,u),x=n?.(h);if(typeof x=="boolean"?x:!h.ok)throw new Ni(h.statusText,h);return h}async function ll(t,e,i){const n=new WebSocket(t.toString()),r=i??6e4;return await new Promise((s,o)=>{const a=r>0?setTimeout(()=>{n.close(),o(new Ve(at.TIMEOUT,`WebSocket connection timed out after ${r}ms`))},r):void 0;let c=!1;const l=()=>{clearTimeout(a),n.removeEventListener("open",u),n.removeEventListener("error",d),n.removeEventListener("close",m)},u=()=>{c||(c=!0,l(),s())},d=p=>{c||(c=!0,l(),o(new Ve(at.NETWORK_ERROR,"WebSocket connection failed",void 0,{cause:p})))},m=p=>{c||(c=!0,l(),o(new Ve(at.NETWORK_ERROR,`WebSocket connection closed unexpectedly (code: ${p.code}, reason: ${p.reason})`,void 0,{cause:p})))};n.addEventListener("open",u),n.addEventListener("error",d),n.addEventListener("close",m)}),new Ls(e||new Response(null),n,"ws")}async function Ph(t,e,i){const n=new EventSource(t.toString()),r=i??6e4;return await new Promise((s,o)=>{const a=r>0?setTimeout(()=>{n.close(),o(new Ve(at.TIMEOUT,`EventSource connection timed out after ${r}ms`))},r):void 0;let c=!1;const l=()=>{clearTimeout(a),n.removeEventListener("open",u),n.removeEventListener("error",d)},u=()=>{c||(c=!0,l(),s())},d=m=>{c||(c=!0,l(),o(new Ve(at.NETWORK_ERROR,"EventSource connection failed",void 0,{cause:m})))};n.addEventListener("open",u),n.addEventListener("error",d)}),new Ls(e||new Response(null),n,"stream")}const Re=class Re extends Sh{constructor(i={}){super("request");D(this,"baseConfigs");D(this,"hooks",[]);D(this,"mergeQueries",gt.mergeQueries);D(this,"mergeHeaders",dn.mergeHeaders);D(this,"interceptors",{request:this.createInterceptor("beforeRequest"),response:this.createInterceptor("afterResponse")});D(this,"create",Re.create);D(this,"_plugins",new Map);D(this,"checkIsPlainObject",It);D(this,"mergeQuery",this.mergeQueries);this.baseConfigs=Rt(Re.DEFAULT_CONFIGS,i),Re.ALL_METHODS.forEach(n=>this.createMethodShortcut(n.toLowerCase()))}get defaults(){return this.baseConfigs}set defaults(i){this.baseConfigs=i}async request(i,n){let r=n||{};if(typeof i=="string"||i instanceof URL?r.url=i.toString():typeof i=="object"&&(r=i),r=await this.emit("beforeInit",r),r[Re.FINAL_SYMBOL])return r;if(r=this.applyDefaults(r),Re.METHODS_WITHOUT_BODY.includes(r.method?.toLocaleLowerCase())&&r.body)throw new Ve(at.BODY_NOT_ALLOWED,`Request method "${r.method}" does not allow body`);if(r=await this.emit("beforeRequest",r),r[Re.FINAL_SYMBOL])return r;let s;const o={};if(typeof r.body<"u"&&r.body!==null&&(r.body instanceof Blob||r.body instanceof FormData||r.body instanceof URLSearchParams?s=r.body:typeof r.body=="object"&&r.body!==null?(s=JSON.stringify(r.body),r.headers=this.mergeHeaders(r.headers,{"Content-Type":"application/json"})):s=r.body),!dn.makeHeaders(r.headers||{}).get("content-type")&&s&&(s instanceof FormData||s instanceof URLSearchParams?o["content-type"]=null:typeof s=="string"&&typeof r.body=="object"?o["content-type"]="application/json":s instanceof Blob&&(o["content-type"]=s.type||"application/octet-stream")),r.body=s,r=await this.emit("afterBodyTransformed",r),r[Re.FINAL_SYMBOL])return r;const c=r.abortController??(globalThis.AbortController?new AbortController:void 0),l=globalThis.location?.href||"http://localhost",u=new URL(r.baseURL||this.baseConfigs.baseURL||l,l),d=new URL(r.url,u),m=gt.makeURL(d,r.query,d.hash).toString(),p=new Request(m,{method:r.method||"GET",credentials:r.credentials,cache:r.cache,mode:r.mode,headers:dn.mergeHeaders(this.baseConfigs.headers,r.headers||{},o),body:r.body,signal:c?.signal});if(r.rawRequest=p,r=await this.emit("beforeActualFetch",r),r[Re.FINAL_SYMBOL])return r;const h=r.timeout??this.baseConfigs.timeout??60*1e3,x=r.shouldThrow??this.baseConfigs.shouldThrow;if(r.url.startsWith("ws")||r.responseType==="ws"){const E=await ll(r.url,void 0,h),y={...r,response:E,rawResponse:void 0,data:E.data,headers:E.headers};return this.emit("afterResponse",y)}let k;try{c&&(k=h>0?setTimeout(()=>{c.abort()},h):void 0);const y=await(r.fetch||this.baseConfigs.fetch||globalThis.fetch)(r.rawRequest).catch(b=>{throw k&&clearTimeout(k),c?.signal.aborted?new Ve(at.TIMEOUT,`Request timed out after ${h}ms`,r):new Ve(at.NETWORK_ERROR,b.message,r)});return k&&clearTimeout(k),r.rawResponse=y,r.response=await al(y,r.responseType,(b,g)=>{n?.onProgress?.(b,g)},x,h),Object.defineProperties(r,{url:{get:()=>y?.url||m},data:{get:()=>r.response.data},headers:{get:()=>y.headers},responseType:{get:()=>r.response.responseType}}),this.emit("afterResponse",r)}catch(E){throw k&&clearTimeout(k),E}}applyDefaults(i){const n=i;"customEnv"in this.baseConfigs&&(n.customEnv=Rt({},this.baseConfigs.customEnv,n.customEnv));const r=globalThis.location?.href||"http://localhost",s=n.baseURL||this.baseConfigs.baseURL||r,o=new URL(s,r),a=new URL(n.url.toString(),o),c=gt.toQueryRecord(o.searchParams),l=gt.toQueryRecord(a.searchParams),u=gt.mergeQueries(c,l);a.search=gt.makeSearchParams(u).toString(),n.url=a.toString();const d=gt.mergeQueries(this.baseConfigs.query,n.query);return n.query&&this.restoreNulls(d,n.query),n.query=d,n}restoreNulls(i,n){if(!(!n||typeof n!="object"))for(const[r,s]of Object.entries(n))s===null?i[r]=null:It(s)&&((!i[r]||typeof i[r]!="object")&&(i[r]={}),this.restoreNulls(i[r],s))}async emit(i,n,r={shouldHandleShortCircuitResponse:!0}){const s=this.hooks.filter(a=>a.event===i);if(s.length===0)return n;const o=async(a,c)=>{const l={...a,rawResponse:c},u=await al(c,a.responseType,(d,m)=>a.onProgress?.(d,m),a.shouldThrow??this.baseConfigs.shouldThrow,a.timeout??this.baseConfigs.timeout??60*1e3);if(l.response=u,l.data=u.data,l.headers=u.headers,i!=="afterResponse"){const d=await this.emit("afterResponse",l);return d[Re.FINAL_SYMBOL]=!0,d}else return l[Re.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{n[u]=u}catch{}const d=await c.action.call(this,n);try{delete n[u]}catch{}if(d===!1)throw new Ve(at.ABORTED_BY_HOOK,`Request aborted by hook "${l}"`,n);if(d instanceof Response){if(r.shouldHandleShortCircuitResponse!==!1)return o(n,d);n.rawResponse=d}else d&&typeof d=="object"&&d[u]===u&&(n=d)}return n}on(i,n,r=!1){if(typeof n!="function")throw new Ve(at.INVALID_HOOK_CALLBACK,`Hook should be a function, but got "${typeof n}"`);return this.hooks[r?"unshift":"push"]({event:i,action:n}),this}off(i,n){return i==="*"||!i?this.hooks=this.hooks.filter(r=>r.action!==n):this.hooks=this.hooks.filter(r=>r.event!==i||r.action!==n),this}createInterceptor(i){return{handlers:()=>this.hooks.filter(n=>n.event===i).map(n=>n.action),use:(n,r=!1)=>this.on(i,n,r),clear:()=>{this.hooks=this.hooks.filter(n=>n.event!==i)}}}createMethodShortcut(i){return Reflect.defineProperty(this,i,{get:()=>(n,r,s)=>(Re.METHODS_WITHOUT_BODY.includes(i.toLocaleLowerCase())?s=r:(s=s||{},s.body=r),this.request(n,{...s,method:i}))}),this}extends(i){const n=new Re(Rt(this.baseConfigs,i));return n.hooks=[...this.hooks],n._plugins=new Map(this._plugins),n._plugins.forEach(async r=>{await n.plugin(r)}),n}static create(i){return new Re(i)}async plugin(i){if(typeof i?.name=="string"&&typeof i?.install=="function"){if(this._plugins.has(i.name))return this;const n=await i.install(this);if(this._plugins.set(i.name,i),n instanceof Re)return n}return this}};D(Re,"version","5.2.0"),D(Re,"FINAL_SYMBOL",Symbol("FEXIOS_FINAL_CONTEXT")),D(Re,"DEFAULT_CONFIGS",{baseURL:"",timeout:0,credentials:void 0,headers:{},query:{},responseType:void 0,shouldThrow(i){return!i.ok},fetch:globalThis.fetch}),D(Re,"ALL_METHODS",["get","post","put","patch","delete","head","options","trace"]),D(Re,"METHODS_WITHOUT_BODY",["get","head","options","trace"]);let fn=Re;const Ch=fn.create;Ch();var rr;(t=>{function e(n){return Array.isArray(n)?n.join("|"):typeof n=="boolean"||n===null?n?"1":void 0:typeof n=="number"?""+n:n}t.normalizeParamValue=e;function i(n){const r=o=>o&&(o instanceof URLSearchParams||o instanceof FormData);if(n==null)return;const s=new FormData;if(r(n))return n.forEach((o,a)=>{const c=e(o);c!=null&&s.append(a,c)}),s;if(It(n))return Object.entries(n).forEach(([o,a])=>{const c=e(a);c!=null&&s.append(o,c)}),s}t.normalizeBody=i})(rr||(rr={}));var hn=(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))(hn||{});class et extends Error{constructor(i,n="",r){super();D(this,"name","WikiSaikouError");this.code=i,this.message=n,this.cause=r}static is(i,n){return i instanceof this&&(n===void 0||i.code===n)}}class At extends Error{constructor(i,n){super();D(this,"name","MediaWikiApiError");D(this,"code");this.errors=i,this.cause=n,this.errors=At.normalizeErrors(i),this.message=i.map(r=>r.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(n=>typeof n=="object"&&!!n?.code).map(n=>n.text?n:n.info?{...n,text:n.info}:n["*"]?{...n,text:n["*"]}:{...n,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 n(s).length>0}t.includesMediaWikiApiError=i,t.normalizeMwApiErrors=At.normalizeErrors;function n(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=n;function r(s){if(At.is(s))return s.isBadTokenError();{const o=n(s);return new At(o).isBadTokenError()}}t.isBadTokenError=r})(et||(et={}));const cl=Symbol.for("__FEXIOS_SAIKOU__");function ul(t){const e=t instanceof fn?t:new fn({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.method?.toLowerCase()!=="post")return i;if(i.body===void 0||i.body===null)return i.body=void 0,i;const n=i.body=rr.normalizeBody(i.body),r=new URLSearchParams(i.query);return n.has("format")&&r.delete("format"),n.has("formatversion")&&r.delete("formatversion"),n.has("action")&&r.delete("action"),n.has("origin")&&(r.set("origin",""+n.get("origin")),n.delete("origin")),i.query=Object.fromEntries(r.entries()),i}),e.on("beforeInit",i=>(i.query=gt.mergeQueries({},rr.normalizeBody(i.query)),i)),e.on("beforeRequest",i=>{const n=new URL(i.url),r=gt.mergeQueries(n.searchParams,i.query);if(globalThis.location&&(!r.origin&&location.origin!==n.origin?(r.origin=location.origin,e.baseConfigs.credentials="include",e.baseConfigs.mode="cors"):location.origin===n.origin&&(delete r.origin,e.baseConfigs.credentials=void 0,e.baseConfigs.mode=void 0)),r.origin){const s=encodeURIComponent(r.origin).replace(/\./g,"%2E");delete r.origin,i.query=r,i.url=`${n.origin}${n.pathname}?origin=${s}`}else i.query=r;return i}),e._tokens=new Map,e.on("afterResponse",i=>{const{data:n}=i,r=i.customEnv?.mwTokenName;r&&et.isBadTokenError(n)&&e._tokens.delete(r);const s=n?.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=n?.login?.token;return typeof o=="string"&&e._tokens.set("login",o),i})),e}const dl=(t,e,i)=>{let n={...sr.DEFAULT_CONFIGS};if(typeof t=="string"?n=Rt(n,{baseURL:t,fexiosConfigs:e||{},defaultParams:i||{},throwOnApiError:!1}):typeof t=="object"&&t!==null&&(n=Rt(n,t)),!n.baseURL&&typeof window=="object"&&window.mediaWiki){const{wgServer:r,wgScriptPath:s}=window.mediaWiki?.config?.get(["wgServer","wgScriptPath"])||{};typeof r=="string"&&typeof s=="string"&&(n.baseURL=`${r}${s}/api.php`)}if(typeof n.baseURL!="string")throw new Error("baseURL is required");return n},Ih=()=>{},Rh=async(t,e)=>{let i=0;const{retry:n=3,onRetry:r=Ih,shouldRetry:s=()=>!0}=e;let o;do try{return await t()}catch(a){if(o=a,s(a,i))r(a,i),i++;else throw a}while(i<n);throw o||new Error("Retry failed")};const sn=class sn{constructor(e,i,n){D(this,"config");D(this,"version","7.4.1");D(this,"request");D(this,"token",this.getToken);const r=this.config=dl(e,i,n);this.request=ul(r.baseURL)}setBaseURL(e){return this.config.baseURL=e,this.request.baseConfigs.baseURL=e,this}async get(e,i){const n=Rt({},this.config.fexiosConfigs,{query:gt.mergeQueries(this.config.defaultParams,e)},i);return this.runRequestWithApiErrorMapping(()=>this.request.get("",n))}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,n){const{tokenName:r="token",retry:s=3,noCache:o=!1,fexiosOptions:a}=n||{};if(s<1)throw new et(hn.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({[r]: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(hn.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(hn.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}};D(sn,"INIT_DEFAULT_PARAMS",{action:"query",errorformat:"plaintext",format:"json",formatversion:2}),D(sn,"DEFAULT_CONFIGS",{baseURL:void 0,fexiosConfigs:{responseType:"json"},defaultParams:sn.INIT_DEFAULT_PARAMS,throwOnApiError:!1}),D(sn,"createRequestHandler",ul);let sr=sn;class Ns extends sr{async clientLogin(e,i,n){n||(n={}),!n.logincontinue&&!n.loginreturnurl&&(n.loginreturnurl=location?.origin);const r=await this.postWithToken("login",{action:"clientlogin",username:e,password:i,...n},{tokenName:"logintoken"});if(r?.data?.clientlogin?.status==="PASS")return r.data.clientlogin;throw new et(hn.LOGIN_FAILED,r.data.clientlogin.message,r)}}class Ah extends Ns{constructor(e,i,n){const r=dl(e,{credentials:"include",mode:"cors",...i},{origin:location.origin,...n});super(r)}}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 n=this.api=new Ns({baseURL:i.baseURL.toString(),fexiosConfigs:{headers:{"x-api-user-agent":`InPageEdit-NEXT ${e.version}`,...i.headers},...i},throwOnApiError:!0});e.set("api",n),e.set("apiService",this)}getClientByFileRepo(e){const i=new URL(`${e.scriptDirUrl}/api.php`,location.origin),n=i.toString();if(n===this.ctx.root.config.apiConfigs.baseURL?.toString())return this.ctx.api;if(!this._apiClients.has(n)){const r=i.origin===location.origin,s={baseURL:i.toString(),throwOnApiError:!0},o=r?new Ns(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(n,o)}return this._apiClients.get(n)}}const Ms=(t,e=document)=>e.querySelector(t),Oh=(t,e=document)=>e.querySelectorAll(t);var Lh=Object.create,Ds=Object.defineProperty,Nh=Object.getOwnPropertyDescriptor,fl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),hl=t=>{throw TypeError(t)},Mh=(t,e,i)=>e in t?Ds(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Dh=(t,e)=>Ds(t,"name",{value:e,configurable:!0}),jh=t=>[,,,Lh(t?.[fl("metadata")]??null)],Uh=["class","method","getter","setter","accessor","field","value","get","set"],pl=t=>t!==void 0&&typeof t!="function"?hl("Function expected"):t,Fh=(t,e,i,n,r)=>({kind:Uh[t],name:e,metadata:n,addInitializer:s=>i._?hl("Already initialized"):r.push(pl(s||null))}),Bh=(t,e)=>Mh(e,fl("metadata"),t[3]),qh=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},zh=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&Nh(r,i));Dh(r,i);for(var h=n.length-1;h>=0;h--)c=Fh(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,pl(o)&&(r=o);return Bh(t,r),p&&Ds(r,i,p),u?l^4?s:p:r},gl,js,ml;gl=[xe(["wiki","wikiTitle"])];class or extends(ml=pt){constructor(i){super(i,"currentPage",!1);an(this,rt);this.ctx=i,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 ht(this,rt,Fa).call(this),ht(this,rt,qf).call(this),window.addEventListener("popstate",ht(this,rt,Ba).bind(this)),this.logger.info("initialized",this.wikiTitle)}stop(){window.removeEventListener("popstate",ht(this,rt,Ba).bind(this))}get params(){return this.url.searchParams}get canonicalUrl(){const i=(Ms('link[rel="alternate"][hreflang="x-default"]')||Ms('link[rel="canonical"]'))?.href;let n=null;return i&&(n=new URL(i,location.origin)),Reflect.defineProperty(this,"canonicalUrl",{get:()=>n}),n}get wikiAction(){return this.params.get("action")||"view"}}rt=new WeakSet,Fa=async function(){await ht(this,rt,Hf).call(this),await ht(this,rt,zf).call(this)},qf=function(){const i=Symbol.for("InPageEdit.CurrentPageService.UrlChangeListenerInstalled");if(window[i])return;const n=history.pushState,r=history.replaceState;history.pushState=function(s,o,a){n.apply(this,[s,o,a]),window.dispatchEvent(new PopStateEvent("popstate",{state:s}))},history.replaceState=function(s,o,a){r.apply(this,[s,o,a]),window.dispatchEvent(new PopStateEvent("popstate",{state:s}))},window[i]=!0},Ba=async function(i){const n=this.url,r=new URL(window.location.href);this.url=r,(n.pathname!==r.pathname||n.searchParams.get("title")!==r.searchParams.get("title")||n.searchParams.get("curid")!==r.searchParams.get("curid"))&&(await ht(this,rt,Fa).call(this),this.logger.info("location changed",r,this.wikiTitle))},zf=async function(){const n=this.wikiTitle?.getMainDBKey()===this.ctx.wiki.mainPageName;return Reflect.defineProperty(this,"isMainPage",{get:()=>n}),n},Hf=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},js=jh(ml),or=zh(js,0,"CurrentPageService",gl,or),qh(js,1,or);class Hh extends pt{constructor(e){super(e,"resourceLoader",!0),this.ctx=e}stop(){this.removeAll()}loadScript(e,i){if(!e)return Promise.resolve(null);const n=`script:${e}`,r=document.querySelector(`[data-ipe="${n}"]`);return r?Promise.resolve(r):new Promise((o,a)=>{const c=document.createElement("script");c.src=e,c.dataset.ipe=n,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 n=`style:${e}`,r=document.querySelector(`[data-ipe="${n}"]`);return r?Promise.resolve(r):new Promise((o,a)=>{const c=document.createElement("link");c.rel="stylesheet",c.href=e,c.dataset.ipe=n,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}`,n=document.querySelector(`[data-ipe="${i}"]`);n&&n.remove()}removeScript(e){const i=`script:${e}`,n=document.querySelector(`[data-ipe="${i}"]`);n&&n.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 n=new URL(i);return n.pathname.endsWith(".js")||(n.pathname=n.pathname+"/"),new URL(e,n.toString()).toString()}}const ar=Object.keys;function Wh(t){return typeof t=="boolean"}function Kh(t){return t&&typeof t.nodeType=="number"}function lr(t){return typeof t=="string"}function yl(t){return typeof t=="number"}function mi(t){return typeof t=="object"?t!==null:pn(t)}function pn(t){return typeof t=="function"}function Vh(t){return!!(t&&t.isComponent)}function Gh(t){return mi(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function Us(t,e){if(t)for(const i of ar(t))e(t[i],i)}function Qh(t){return mi(t)&&"current"in t}const Fs={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 Yh(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const Xh=["Webkit","ms","Moz","O"];ar(Fs).forEach(t=>{Xh.forEach(e=>{Fs[Yh(e,t)]=0})});const Jh=Symbol.for("jsx-dom:type");var bl=(function(t){return t.ShadowRoot="ShadowRoot",t})(bl||{});function Zh(t){return t!=null&&t[Jh]===bl.ShadowRoot}const ep="http://www.w3.org/2000/svg",tp="http://www.w3.org/1999/xlink",ip="http://www.w3.org/XML/1998/namespace";function vl(t){return!Wh(t)&&t!=null}function Bs(t){return Array.isArray(t)?t.map(Bs).filter(Boolean).join(" "):mi(t)?Symbol.iterator in t?Bs(Array.from(t)):ar(t).filter(e=>t[e]).join(" "):vl(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},rp=/^(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 yi(t){const e=document.createDocumentFragment();return cr(t.children,e),e}function sp(t,e,i){e={...e,children:i};const n=new t(e),r=n.render();return"ref"in e&&qs(e.ref,n),r}function f(t,e){let{children:i,...n}=e;!n.namespaceURI&&np[t]===0&&(n={...n,namespaceURI:ep});let r;if(lr(t)){if(r=n.namespaceURI?document.createElementNS(n.namespaceURI,t):document.createElement(t),lp(n,r),cr(i,r),r instanceof window.HTMLSelectElement&&n.value!=null)if(n.multiple===!0&&Array.isArray(n.value)){const s=n.value.map(o=>String(o));r.querySelectorAll("option").forEach(o=>o.selected=s.includes(o.value))}else r.value=n.value;qs(n.ref,r)}else if(pn(t))mi(t.defaultProps)&&(n={...t.defaultProps,...n}),r=Vh(t)?sp(t,n,i):t({...n,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return r}function gn(t,e){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return(lr(e)||Array.isArray(e))&&(n.unshift(e),e={}),e=e||{},e.children!=null&&!n.length&&({children:n,...e}=e),f(t,{...e,children:n},e.key)}function qs(t,e){Qh(t)?t.current=e:pn(t)&&t(e)}function cr(t,e){if(Gh(t))op(t,e);else if(lr(t)||yl(t))zs(document.createTextNode(t),e);else if(t===null)zs(document.createComment(""),e);else if(Kh(t))zs(t,e);else if(Zh(t)){const i=e.attachShadow(t.attr);cr(t.children,i),qs(t.ref,i)}}function op(t,e){for(const i of[...t])cr(i,e);return e}function zs(t,e){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}function ur(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)):lr(e)?t.setAttribute("style",e):mi(e)&&Us(e,(i,n)=>{n.indexOf("-")===0?t.style.setProperty(n,i):yl(i)&&Fs[n]!==0?t.style[n]=i+"px":t.style[n]=i}))}function ap(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":_l(i,tp,ur(t,":"),e);return;case"xmlnsXlink":Mi(i,ur(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":_l(i,ip,ur(t,":"),e);return}switch(t){case"htmlFor":Mi(i,"for",e);return;case"dataset":Us(e,(n,r)=>{n!=null&&(i.dataset[r]=n)});return;case"innerHTML":case"innerText":case"textContent":vl(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":mi(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":pn(e)?e(i):Mi(i,"class",Bs(e));return;case"ref":case"namespaceURI":return;case"style":wl(i,e);return;case"on":case"onCapture":Us(e,(n,r)=>{i.addEventListener(r,n,t==="onCapture")});return}if(pn(e)){if(t[0]==="o"&&t[1]==="n"){let n=t.toLowerCase();const r=n.endsWith("capture");if(n==="ondoubleclick"?n="ondblclick":r&&n==="ondoubleclickcapture"&&(n="ondblclickcapture"),!r&&i[n]===null)i[n]=e;else if(r)i.addEventListener(n.substring(2,n.length-7),e,!0);else{let s;n in window?s=n.substring(2):s=n[2]+t.slice(3),i.addEventListener(s,e)}}}else mi(e)?i[t]=e:e===!0?Mi(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!rp.test(t)?Mi(i,ur(t,"-"),e):Mi(i,t,e))}function Mi(t,e,i){t.setAttribute(e,i)}function _l(t,e,i,n){t.setAttributeNS(e,i,n)}function lp(t,e){for(const i of ar(t))ap(i,t[i],e);return e}const dr=Object.keys;function cp(t){return typeof t=="boolean"}function up(t){return t&&typeof t.nodeType=="number"}function Hs(t){return typeof t=="string"}function xl(t){return typeof t=="number"}function bi(t){return typeof t=="object"?t!==null:mn(t)}function mn(t){return typeof t=="function"}function dp(t){return!!(t&&t.isComponent)}function fp(t){return bi(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function Ws(t,e){if(t)for(const i of dr(t))e(t[i],i)}function hp(t){return bi(t)&&"current"in t}const Ks={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 pp(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const gp=["Webkit","ms","Moz","O"];dr(Ks).forEach(t=>{gp.forEach(e=>{Ks[pp(e,t)]=0})});const mp=Symbol.for("jsx-dom:type");var kl=(function(t){return t.ShadowRoot="ShadowRoot",t})(kl||{});function yp(t){return t!=null&&t[mp]===kl.ShadowRoot}const bp="http://www.w3.org/2000/svg",vp="http://www.w3.org/1999/xlink",wp="http://www.w3.org/XML/1998/namespace";function Sl(t){return!cp(t)&&t!=null}function Vs(t){return Array.isArray(t)?t.map(Vs).filter(Boolean).join(" "):bi(t)?Symbol.iterator in t?Vs(Array.from(t)):dr(t).filter(e=>t[e]).join(" "):Sl(t)?""+t:""}const _p={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},xp=/^(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 kp(t){const e=document.createDocumentFragment();return fr(t.children,e),e}function Sp(t,e,i){e={...e,children:i};const n=new t(e),r=n.render();return"ref"in e&&Gs(e.ref,n),r}function $e(t,e){let{children:i,...n}=e;!n.namespaceURI&&_p[t]===0&&(n={...n,namespaceURI:bp});let r;if(Hs(t)){if(r=n.namespaceURI?document.createElementNS(n.namespaceURI,t):document.createElement(t),Pp(n,r),fr(i,r),r instanceof window.HTMLSelectElement&&n.value!=null)if(n.multiple===!0&&Array.isArray(n.value)){const s=n.value.map(o=>String(o));r.querySelectorAll("option").forEach(o=>o.selected=s.includes(o.value))}else r.value=n.value;Gs(n.ref,r)}else if(mn(t))bi(t.defaultProps)&&(n={...t.defaultProps,...n}),r=dp(t)?Sp(t,n,i):t({...n,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return r}function Gs(t,e){hp(t)?t.current=e:mn(t)&&t(e)}function fr(t,e){if(fp(t))$p(t,e);else if(Hs(t)||xl(t))Qs(document.createTextNode(t),e);else if(t===null)Qs(document.createComment(""),e);else if(up(t))Qs(t,e);else if(yp(t)){const i=e.attachShadow(t.attr);fr(t.children,i),Gs(t.ref,i)}}function $p(t,e){for(const i of[...t])fr(i,e);return e}function Qs(t,e){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}function hr(t,e){return t.replace(/[A-Z]/g,i=>e+i.toLowerCase())}function $l(t,e){e==null||e===!1||(Array.isArray(e)?e.forEach(i=>$l(t,i)):Hs(e)?t.setAttribute("style",e):bi(e)&&Ws(e,(i,n)=>{n.indexOf("-")===0?t.style.setProperty(n,i):xl(i)&&Ks[n]!==0?t.style[n]=i+"px":t.style[n]=i}))}function Ep(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":El(i,vp,hr(t,":"),e);return;case"xmlnsXlink":Di(i,hr(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":El(i,wp,hr(t,":"),e);return}switch(t){case"htmlFor":Di(i,"for",e);return;case"dataset":Ws(e,(n,r)=>{n!=null&&(i.dataset[r]=n)});return;case"innerHTML":case"innerText":case"textContent":Sl(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":bi(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":mn(e)?e(i):Di(i,"class",Vs(e));return;case"ref":case"namespaceURI":return;case"style":$l(i,e);return;case"on":case"onCapture":Ws(e,(n,r)=>{i.addEventListener(r,n,t==="onCapture")});return}if(mn(e)){if(t[0]==="o"&&t[1]==="n"){let n=t.toLowerCase();const r=n.endsWith("capture");if(n==="ondoubleclick"?n="ondblclick":r&&n==="ondoubleclickcapture"&&(n="ondblclickcapture"),!r&&i[n]===null)i[n]=e;else if(r)i.addEventListener(n.substring(2,n.length-7),e,!0);else{let s;n in window?s=n.substring(2):s=n[2]+t.slice(3),i.addEventListener(s,e)}}}else bi(e)?i[t]=e:e===!0?Di(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!xp.test(t)?Di(i,hr(t,"-"),e):Di(i,t,e))}function Di(t,e,i){t.setAttribute(e,i)}function El(t,e,i,n){t.setAttributeNS(e,i,n)}function Pp(t,e){for(const i of dr(t))Ep(i,t[i],e);return e}var Ys=(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))(Ys||{});let Cp=0;const Pl=t=>`${t}-${++Cp}`;function yn(t){return t instanceof Node?t:document.createTextNode(String(t))}function Vt(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[n,r]of Object.entries(e.attrs))i.setAttribute(n,r);return i}const Ip=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/i.test(navigator.platform),Il=["ctrl","alt","shift","meta"];function Rp(t){if(!t)return null;const e=String(t).trim().toLowerCase().split(/[+\-\s]+/g).filter(Boolean),i=[];let n=null;const r=o=>{i.includes(o)||i.push(o)};for(const o of e){let a=o;if(a==="control"||a==="ctrl"){r("ctrl");continue}if(a==="alt"||a==="option"){r("alt");continue}if(a==="shift"){r("shift");continue}if(a==="meta"||a==="cmd"||a==="command"||a==="super"){r("meta");continue}if(a==="mod"){r(Ip?"meta":"ctrl");continue}a==="esc"&&(a="escape"),a==="return"&&(a="enter"),(a==="space"||a==="spacebar")&&(a="space"),n=a}const s=Il.filter(o=>i.includes(o));return!n||n===""?s.length?s.join("+"):null:s.length?`${s.join("+")}+${n}`:n}function Ap(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 n=(i.length,i.toLowerCase()),r=Il.filter(s=>e.includes(s));return r.length?`${r.join("+")}+${n}`:n}class Tp{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 n=new Set((Array.isArray(i)?i:i?[i]:[]).map(String)),r=new Set((Array.isArray(e)?e:e?[e]:[]).map(String));[...this.stack].reverse().forEach(s=>{const o=s.modalId,a=r.size?r.has(s.pluginName):!0,c=n.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 Tp,Kn=class Kn{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=Ys,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 n=i.clientX-this.dragStartX,r=i.clientY-this.dragStartY,s=this.get$modal(),o=this.modalStartX+n,a=this.modalStartY+r;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(),n=this.get$window();i.classList.remove("is-dragging"),n.style.animation="none",requestAnimationFrame(()=>{this.applyAnimation(!0)})},this.options={...Kn.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 n=Ge("div",{className:"ipe-modal-modal",attrs:{id:this.modalId,role:"dialog","aria-modal":"true",tabindex:"-1"}});if(n.modal=this,!e){n.classList.add("no-backdrop");const p=window.pageYOffset||document.documentElement.scrollTop,h=window.pageXOffset||document.documentElement.scrollLeft,x=window.innerWidth;n.style.top=`${p+60}px`,this.once("modal.show",()=>{n.style.left=`${h+x/2-n.offsetWidth/2}px`})}const r=Ge("div",{className:`ipe-modal-modal__window size--${this.options.sizeClass||"auto"} plugin--${this.pluginName}`});r.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"}});n.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)),n.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"}),m=Ge("div",{className:"ipe-modal-modal__buttons ipe-modal-modal__buttons--right"});return u.append(d,m),r.append(s,l,u),n.appendChild(r),this.$backdrop=i,this.$modal=n,this.$window=r,this.$header=s,this.$title=a,this.$icons=c,this.$content=l,this.$footer=u,this.$buttonsLeft=d,this.$buttonsRight=m,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("pointerdown",p=>{this.options.outSideClose&&p.target===i&&this.close()}),this.options.draggable&&r.addEventListener("pointerdown",p=>{p.target&&r.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 n=this.emit("modal.beforeShow",!0),r=this.options.beforeShow?this.options.beforeShow(this)!==!1:!0;if(!n||!r)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 n=()=>{i||(i=!0,this.destroy(),this.options.onClose?.(this))},r=(s,o)=>{const a=()=>{s.removeEventListener(o,a),n()};s.addEventListener(o,a,{once:!0})};return e>0&&this.$window?(r(this.$window,"transitionend"),r(this.$window,"animationend"),window.setTimeout(n,e+20)):window.setTimeout(n,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=vi.indexOf(this);e!==-1&&vi.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 Vt(this.$modal,"modal")}get$window(){return Vt(this.$window,"window")}get$header(){return Vt(this.$header,"header")}get$title(){return Vt(this.$title,"title")}get$content(){return Vt(this.$content,"content")}get$icons(){return Vt(this.$icons,"icons")}get$buttons(e){return e==="leftButtons"?Vt(this.$buttonsLeft,"leftButtons"):e==="rightButtons"?Vt(this.$buttonsRight,"rightButtons"):Vt(this.$footer,"buttons")}setTitle(e){const i=this.get$title();return i.innerHTML="",i.append(yn(e)),this}setContent(e,i="replace"){const n=this.get$content();return i==="replace"?(n.innerHTML="",n.append(yn(e))):i==="append"?n.append(yn(e)):n.prepend(yn(e)),this}setIcons(e){const i=this.get$icons();i.innerHTML="";for(const n of e){const r=Ge("button",{className:`ipe-modal-modal__icon ${n.className}`,attrs:{type:"button"}});r.addEventListener("click",n.method),i.appendChild(r)}return this}setButtons(e,i){const n=this.$buttonsLeft,r=this.$buttonsRight;[n,r].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",n=i==="link"?Ge("a"):Ge("button",{attrs:{type:"button"}});e.id&&(n.id=e.id),n.className=`ipe-modal-btn ${e.className??""}`.trim();const r=yn(e.label??"OK");if(n.append(r),i==="link"&&e.href&&(n.href=e.href),e.method&&n.addEventListener("click",s=>{if(n._ipe_tmpDisabled){s.preventDefault(),s.stopPropagation();return}e.method.call(n,s,this)}),typeof e.closeAfter=="number"&&e.closeAfter>=0&&n.addEventListener("click",()=>{window.setTimeout(()=>this.close(),e.closeAfter)}),typeof e.enableAfter=="number"&&e.enableAfter>0){i==="button"&&n.setAttribute("disabled","true"),n._ipe_tmpDisabled=!0,n.setAttribute("aria-disabled","true");const s=()=>{i==="button"&&n.removeAttribute("disabled"),delete n._ipe_tmpDisabled,n.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=Rp(o);a&&this.keyMap.set(a,n)}}return n}addButton(e,i){this.$footer&&(this.$footer.style.display="");const n=e.side??"right",r=n==="left"?this.$buttonsLeft:this.$buttonsRight,s=n==="left"?this.buttonElsLeft:this.buttonElsRight,o=this.generateButton(e),a=Math.max(0,Math.min(i??s.length,s.length));return a>=r.children.length?r.appendChild(o):r.insertBefore(o,r.children[a]),s.splice(a,0,o),this}removeButton(e){const i=this.buttonElsLeft,n=this.buttonElsRight,r=[...i,...n];let s=null;if(e==="*")return r.forEach(a=>{this.keyMap.delete(a.id),a.parentElement?.removeChild(a)}),this.$footer&&(this.$footer.style.display="none"),this;if(typeof e=="number"?s=r[e]??null:typeof e=="string"?s=r.find(a=>a.id===e)??null:e instanceof HTMLElement&&(s=r.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=n.indexOf(s),o!==-1&&(n.splice(o,1),s.parentElement?.removeChild(s))),i.length===0&&n.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 n=this.get$window(),r=Math.max(0,window.innerHeight-e);return n.style[i]=`${r}px`,r}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(),n=this.get$window(),r=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",n.style.animation="none",n.style.removeProperty("--ipe-modal-anim")):(i.style.removeProperty("transition"),n.style.setProperty("--ipe-modal-anim",o)),r&&(!c||c===!1?r.style.transition="none":r.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(n=>n.type!==e&&(i?n.listener!==i:!0)),this}once(e,i){const n=this.on(e,r=>(n(),i(r)));return n}emit(e,i){const n=this._hooks.filter(a=>a.type===e);let r=!0;for(const a of n){const c=new CustomEvent(e,{detail:this,cancelable:i}),l=a.listener(c);if(c.defaultPrevented&&(r=!1),l===!1&&(r=!1),!r)break}const s=this.$modal??document.body,o=new CustomEvent(e,{detail:this,cancelable:i});return(!s.dispatchEvent(o)||o.defaultPrevented)&&(r=!1),r}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 n=e.ctrlKey||e.altKey||e.metaKey,r=e.target;if(!n&&(r&&["INPUT","TEXTAREA"].includes(r.tagName)||r.contentEditable==="true"))return;const s=Ap(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(),n=i.getBoundingClientRect();this.modalStartX=n.left+window.pageXOffset,this.modalStartY=n.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=Op(e.position??"top right"),n=this.get$window();this.isToast=!0,n.style.pointerEvents="auto",this.applyAnimation(!0),i.appendChild(n);const r=(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 r>0&&(this.startCloseTimer(r),s&&(n.addEventListener("mouseenter",this.stopCloseTimer),n.addEventListener("mouseleave",()=>this.startCloseTimer(r)))),this.isOpen=!0,this.options.onShow?.(this),vi.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,n=tt.stack.find(s=>s.modalId===i);if(n)return n.close(),n;const r=vi.find(s=>s.modalId===i);return r?.close(),r}static closeAll(e,i){const n=new Set((Array.isArray(i)?i:i?[i]:[]).map(String)),r=new Set((Array.isArray(e)?e:e?[e]:[]).map(String));return tt.closeAll(e,i),[...vi].forEach(s=>{const o=s.modalId,a=r.size?r.has(s.pluginName):!0,c=n.has(o);a&&!c&&s.close()}),tt.top()??new Kn}static removeAll(){tt.removeAll(),[...vi].forEach(e=>e.destroy())}static dialog(e,i){const n=new this({sizeClass:"dialog",buttons:[{label:"OK",className:"is-primary is-ghost",method:(r,s)=>{i?.(r,s),r.defaultPrevented||n.close()},keyPress:"Enter"}],...e});return n.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 n=e.okBtn??{label:"OK",className:"is-primary is-ghost"},r=e.cancelBtn??{label:"Cancel",className:"is-danger is-ghost"};return new this({sizeClass:"dialog",...e,buttons:[{label:r.label,className:r.className,keyPress:"n",method:(s,o)=>{i?.(!1,o,s),o.close()}},{label:n.label,className:n.className,keyPress:"y",method:(s,o)=>{i?.(!0,o,s),s.defaultPrevented||o.close()}}]}).init().show()}static getDefaultNotifyIcon(e){switch(e){case"success":return $e("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:[$e("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),$e("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 $e("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:[$e("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),$e("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 $e("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:[$e("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),$e("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 $e("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:[$e("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),$e("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 $e("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:[$e("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),$e("path",{d:"M12 11v.01"}),$e("path",{d:"M8 11v.01"}),$e("path",{d:"M16 11v.01"}),$e("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 $e("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:[$e("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),$e("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,n){var a,c,l,u;if(i?.overrideOther&&[...vi].forEach(d=>d.close()),typeof i.title>"u"){const d=e||"Notification";i.title=d[0].toUpperCase()+d.slice(1).toLowerCase()}const r=i.icon??this.getDefaultNotifyIcon(e);r&&(r instanceof Element&&r.classList.add("ipe-modal-notify-icon"),i.title=$e(kp,{children:[r,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,m)=>{n?.(!0,m,d),m.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,m)=>{n?.(!1,m,d),m.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"})}};Kn.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 Xs=Kn;const vi=[];function Op(t="top right"){const e="ipe-modal-toast-container",i=`${e}-${t.replace(/[\s-\.|\/]+/g,"-")}`;let n=document.getElementById(i);return n||(n=Ge("div",{className:`${e} ${t}`,attrs:{id:i,"data-position":t}}),document.body.appendChild(n)),n}const Lp={ipe_progress:"_ipe_progress_so6hn_1"},wi=t=>{const e=t.indeterminate??!0,i=f("div",{class:`${Lp.ipe_progress}`,"data-indeterminate":`${e}`,style:{width:"100%","--progress":t.progress?`${t.progress}%`:"0%"},...t});return i.setProgress=n=>{typeof n=="number"?(i.dataset.indeterminate="false",i.style.setProperty("--progress",`${n}%`)):(i.dataset.indeterminate="true",i.style.setProperty("--progress","0%"))},i};class Me extends Xs{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(n=>{n.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(wi,{style:{width:"80%",maxWidth:"800px"}})}))}else{this.get$window().querySelector("#ipe-modalLoadingWrapper")?.remove();const i=this._tmpDisabledActiveInputs;i&&i.forEach(n=>{n.disabled=!1})}}}class Np{constructor(e){this.ctx=e,this.IPEModal=Me,this.IPEModalEvent=Ys,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 Rl=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,n]of Object.entries(t))if(n!=null){if(Array.isArray(n)){for(const r of n)e.append(i,r?.toString());continue}if(typeof n=="object"&&n!==null&&n.constructor===Object){for(const[r,s]of Object.entries(n))s!=null&&e.set(`${i}[${r}]`,s?.toString());continue}e.set(i,n?.toString())}return e},Al=(t,e,i)=>{const n=typeof t=="string"?new URL(t,window?.location?.origin):new URL(t),r=new URLSearchParams(n.search),s=Rl(e);for(const[o,a]of s.entries())r.set(o,a);return n.search=r.toString(),n.hash="",n};var Mp=Object.create,Js=Object.defineProperty,Dp=Object.getOwnPropertyDescriptor,Tl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ol=t=>{throw TypeError(t)},jp=(t,e,i)=>e in t?Js(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Up=(t,e)=>Js(t,"name",{value:e,configurable:!0}),Fp=t=>[,,,Mp(t?.[Tl("metadata")]??null)],Bp=["class","method","getter","setter","accessor","field","value","get","set"],Ll=t=>t!==void 0&&typeof t!="function"?Ol("Function expected"):t,qp=(t,e,i,n,r)=>({kind:Bp[t],name:e,metadata:n,addInitializer:s=>i._?Ol("Already initialized"):r.push(Ll(s||null))}),zp=(t,e)=>jp(e,Tl("metadata"),t[3]),Hp=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Wp=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&Dp(r,i));Up(r,i);for(var h=n.length-1;h>=0;h--)c=qp(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,Ll(o)&&(r=o);return zp(t,r),p&&Js(r,i,p),u?l^4?s:p:r},Nl,Zs,Ml;Nl=[xe(["api","storage"])];class pr extends(Ml=pt){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,n)=>window?.mw?.config?.get?.(i,n)??n),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",I.object({WikiMetadataService:I.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 n=>{n.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 n=i?null:await this.fetchFromCache(e);if(n)return this._data[e]=n,this.logger.debug("Using cached",e,n),n;{const r=await this.fetchFromApi(e);return this.saveToCache(e,r),this._data[e]=r,this.logger.debug("Fetched from API",e,r),r}}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 n=this.getCacheKey(e);return this.CACHE_DB.set(n,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(n=>n.id===i.id).map(n=>n.alias)})).sort((i,n)=>i.id-n.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 Al(this.siteInfo.general.base,e).toString()}getUrl(e,i){const n=Rl(i);let r;return typeof e=="string"&&e!==""?r=new URL(`${this.articleBaseUrl.replace("$1",e)}`):typeof e=="number"?(n.set("curid",e.toString()),r=new URL(this.getSciprtUrl("index"))):r=new URL(this.getSciprtUrl("index")),r.search=n.toString(),r.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}}Zs=Fp(Ml),pr=Wp(Zs,0,"WikiMetadataService",Nl,pr),Hp(Zs,1,pr);class Kp{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 Vp=()=>new Proxy(new Kp,{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)}}),Gp=(()=>{const t=Symbol.for("IPE.GlobalMemoryStorage");return t in globalThis||(globalThis[t]=Vp()),globalThis[t]})();class Qp{constructor(e,i,n=1/0,r,s="localStorage"){this.dbName=e,this.storeName=i,this.ttl=n,this.version=r,this.engine=s,typeof n!="number"&&(this.ttl=Number(n)),(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=Gp}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 n;try{n=JSON.parse(i)}catch{return this.deleteSync(e),null}const r=n;return typeof r.time!="number"||!("value"in r)?(this.deleteSync(e),null):typeof this.version<"u"&&typeof this.version<"u"&&r.version!==this.version?(this.deleteSync(e),null):r}getRaw(e){const i=this.makeKey(e);return this.db.getItem(i)}setRaw(e,i){const n=this.makeKey(e);try{this.db.setItem(n,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,n){const r=this.load(e),s=this.isExpired(r,i);if(!r||s){if(typeof n=="function"){const o=await n();return await this.set(e,o),o}return null}return r.value}async set(e,i){const n=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:n,value:a,version:this.version};return this.setRaw(o,JSON.stringify(c)),c}const r=e,s={};for(const[o,a]of Object.entries(r)){if(a===null||typeof a>"u"){this.deleteSync(o);continue}const c={time:n,value:a,version:this.version};this.setRaw(o,JSON.stringify(c)),s[o]=c}return s}async has(e,i=this.ttl){const n=this.load(e);return n!==null&&!this.isExpired(n,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 n=0;n<this.db.length;n++){const r=this.db.key(n);r&&r.startsWith(e)&&i.push(r)}for(const n of i)this.db.removeItem(n);return this}async*keys(){const e=this.makeKey("");for(let i=0;i<this.db.length;i++){const n=this.db.key(i);n&&n.startsWith(e)&&(yield n.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 m=Math.max(1,l.attempts);for(let p=0;p<m;p++)try{return await u(p)}catch(h){if(p===m-1)throw h;await d?.(h,p);const x=l.baseDelayMs*Math.pow(2,p)+Math.floor(Math.random()*10);await(0,t.sleep)(x)}throw new Error("withRetry exhausted unexpectedly")}t.withRetry=i;function n(l,u,d){return new Promise((m,p)=>{const h=indexedDB.open(l,u);h.onupgradeneeded=()=>{try{const x=h.result,k=h.transaction;d?.(x,k)}catch(x){p(x)}},h.onerror=()=>p(h.error),h.onblocked=()=>{},h.onsuccess=()=>{const x=h.result;x.onversionchange=()=>{try{x.close()}finally{t.cache.delete(l)}},m(x)}})}async function r(l,u,d){let m=!l.objectStoreNames.contains(u),p=[];if(!m&&d?.indexes?.length){const k=l.transaction(u,"readonly"),E=k.objectStore(u),y=new Set(Array.from(E.indexNames));p=(d.indexes||[]).filter(b=>!y.has(b.name)),await new Promise((b,g)=>{k.oncomplete=()=>b(),k.onabort=()=>g(k.error),k.onerror=()=>g(k.error)})}if(!m&&p.length===0)return l;const h=l.version+1;l.close();const x=await n(l.name,h,(k,E)=>{let y;k.objectStoreNames.contains(u)?y=E.objectStore(u):y=k.createObjectStore(u,{keyPath:d?.keyPath??void 0,autoIncrement:!!d?.autoIncrement});for(const b of p)y.indexNames.contains(b.name)||y.createIndex(b.name,b.keyPath,b.options)});return x.onversionchange=()=>{try{x.close()}finally{t.cache.delete(x.name)}},x}async function s(l,u,d){let m=t.cache.get(l);return m?(m=m.then(p=>r(p,u,d)),t.cache.set(l,m)):(m=(async()=>{const p=await n(l);return r(p,u,d)})(),t.cache.set(l,m)),m}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 Yp=class{constructor(e,i,n={}){this.dbName=e,this.storeName=i,this.options=n}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 n=this._retryCfg;return Te.withRetry(n,async()=>{const r=await Te.getDB(this.dbName,this.storeName,this.options.ensure);try{const s=r.transaction(this.storeName,e),o=s.objectStore(this.storeName),a=await i(o);return await Te.waitTx(s),a}catch(s){throw s}},async r=>{Te.shouldReconnect(r)&&await Te.closeConnection(this.dbName)})}async get(e){return this._withStore("readonly",async i=>{const n=await Te.asyncRequest(i.get(e));return n===void 0?void 0:n})}async set(e,i){return await this._withStore("readwrite",async n=>{const r=this.options.ensure?.keyPath!=null?n.put(i):n.put(i,e);await Te.asyncRequest(r)}),this}async delete(e){return this._withStore("readwrite",async i=>{const n=await Te.asyncRequest(i.get(e))!==void 0;return await Te.asyncRequest(i.delete(e)),n})}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 n=Math.max(1,this._iterBatch);for(;!i;){const r=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>=n?c():d.continue()}}),o});for(const s of r)yield s;if(r.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,n]of this.entries())await e(n,i,this)}async getMany(e){const i=new Map;for await(const n of e)i.set(n,void 0);return await this._withStore("readonly",async n=>{await Promise.all(i.keys().map(async r=>{const s=await Te.asyncRequest(n.get(r));i.set(r,s===void 0?void 0:s)}))}),i}async setMany(e){const i=this.options.ensure?.keyPath!=null;return await this._withStore("readwrite",async n=>{for await(const[r,s]of e){const o=i?n.put(s):n.put(s,r);await Te.asyncRequest(o)}}),this}async deleteMany(e){let i=0;return await this._withStore("readwrite",async n=>{for await(const r of e)await Te.asyncRequest(n.get(r))!==void 0&&i++,await Te.asyncRequest(n.delete(r))}),i}async disconnect(){await Te.closeConnection(this.dbName)}};class Xp{constructor(e,i,n=1/0,r){this.dbName=e,this.storeName=i,this.ttl=n,this.version=r,this.db=new Yp(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[n,r]of this.db.entries())typeof r.time=="number"&&e-r.time>this.ttl&&i.push(n);i.length>0&&await this.db.deleteMany(i)}async get(e,i=this.ttl,n){const r=await this.loadFromDB(e),s=this.checkIfExpired(r,i);if(!r||s){if(typeof n=="function"){const o=await n();return await this.set(e,o),o}return null}return r.value}async set(e,i){const n=Date.now();if(typeof e=="string"){const c=e,l=i;if(l===null||typeof l>"u")return this.delete(c);const u={time:n,value:l,version:this.version};return await this.db.set(c,u),u}const r=e,s=[],o=[],a={};for(const[c,l]of Object.entries(r))if(l===null||typeof l>"u")o.push(c);else{const u={time:n,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 n=await this.loadFromDB(e),r=this.checkIfExpired(n,i);return n!==null&&!r}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 Jp extends pt{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,n,r="indexedDB"){const s="indexedDB"in window&&window.indexedDB!==null;switch(r==="indexedDB"&&!s&&(r="localStorage"),r){case"indexedDB":return new Xp(this.config.dbName,e,i,n);case"localStorage":case"sessionStorage":case"memory":return new Qp(this.config.dbName,e,i,n,r);default:throw new Error(`Unsupported storage engine: ${r}`)}}}function Tt(t){return function(e){return e.PreferencesSchema=t,e}}var Zp=Object.create,eo=Object.defineProperty,eg=Object.getOwnPropertyDescriptor,Dl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),jl=t=>{throw TypeError(t)},tg=(t,e,i)=>e in t?eo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ig=(t,e)=>eo(t,"name",{value:e,configurable:!0}),ng=t=>[,,,Zp(t?.[Dl("metadata")]??null)],rg=["class","method","getter","setter","accessor","field","value","get","set"],Ul=t=>t!==void 0&&typeof t!="function"?jl("Function expected"):t,sg=(t,e,i,n,r)=>({kind:rg[t],name:e,metadata:n,addInitializer:s=>i._?jl("Already initialized"):r.push(Ul(s||null))}),og=(t,e)=>tg(e,Dl("metadata"),t[3]),ag=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},lg=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&eg(r,i));ig(r,i);for(var h=n.length-1;h>=0;h--)c=sg(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,Ul(o)&&(r=o);return og(t,r),p&&eo(r,i,p),u?l^4?s:p:r},Fl,to,Bl;Fl=[xe(["preferences"]),Tt(I.object({theme:I.union([I.const("auto").description("Follow system"),I.const("light").description("Light mode"),I.const("dark").description("Dark mode"),I.const("fandom").description("Follow Fandom")]).default("auto").description("Theme preference")}).description("Theme settings").extra("category","general"))];class gr extends(Bl=pt){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"}}to=ng(Bl),gr=lg(to,0,"ThemeService",Fl,gr),ag(to,1,gr);var wt=(t=>(t.preferences="preferences",t.watch="watch",t.unwatch="unwatch",t.nochange="nochange",t))(wt||{});function cg(t){const i=class i{constructor(r,s=!0){this._loaded=s,this.api=t,r.revisions?.forEach(o=>{typeof o?.slots?.main=="object"&&Object.assign(o,o.slots.main)}),this.pageInfo={...i.DEFAULT_PAGE_INFO,...r}}static async newFromApi(r){const{data:s}=await this.api.get({...i.DEFAULT_QUERY_PARAMS,...r}),o=s?.query?.pages?.[0];if(!o||!o.title)throw new Error("Invalid page info",{cause:s});return new i(o,!0)}static newBlankPage(r={}){return new i(r,!1)}static async newFromAnyKind(r){const{title:s,pageId:o,revisionId:a}=r||{};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(r){const{titles:s,pageids:o,revids:a,...c}=r||{},{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(r){return this.api.post({action:"parse",page:this.pageInfo.title,prop:"text|langlinks|categories|links|templates|images|externallinks|sections|revid|displaytitle|iwlinks|properties|parsewarnings",...r})}async preview(r,s){return this.parse({action:"parse",page:void 0,title:this.title,text:r,pst:1,preview:1,disableeditsection:1,disablelimitreport:1,...s})}async edit(r,s){const o=await this.api.postWithEditToken({action:"edit",title:this.title,starttimestamp:this.pageInfo.touched,basetimestamp:this.revisions[0]?.timestamp,...r,...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(r,s){return this.edit(r,{createonly:1,recreate:r.recreate,...s})}async delete(r,s){return this.api.postWithEditToken({action:"delete",title:this.pageInfo.title||void 0,pageid:this.pageInfo.pageid||void 0,reason:r,deletetalk:s?.deletetalk,...s})}async moveTo(r,s,o){return this.api.postWithEditToken({action:"move",from:this.pageInfo.title,to:r,reason:s,movetalk:1,movesubpages:1,...o})}userCan(r){return!!this.pageInfo?.actions?.[r]}userCanEdit(){return this.userCan("edit")}async reloadSelfInfo(){const r=await i.newFromApi({pageids:this.pageInfo.pageid,titles:this.pageInfo.title}),s=(this.pageInfo.revisions||[]).concat(r.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=r.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 ja=class ja extends pt{constructor(e){super(e,"wikiPage",!0),this.ctx=e,this.WikiPage=cg(this.ctx.api)}async createInstance(e,i=!1){return await this.WikiPage.newFromApi(e)}async newFromTitle(e,i=!1,n,r=!1){return this.createInstance({titles:e.toString(),converttitles:i,rvsection:n},r)}async newFromPageId(e,i,n=!1){return this.createInstance({pageids:e,rvsection:i},n)}async newFromRevision(e,i,n=!1){return await this.createInstance({revids:e,rvsection:i},n)}newBlankPage(e={}){return this.WikiPage.newBlankPage(e)}};ja.inject=["api"];let io=ja;const ql=new WeakMap,bn={toDBKey:t=>t.replace(/ /g,"_"),toNormalText:t=>t.replace(/_/g," "),ensureCase:(t,e)=>e==="first-letter"?t.charAt(0).toUpperCase()+t.slice(1):t},vn={normalizeSpecialPageName:t=>t.toLowerCase(),buildSpecialPageIndex:t=>{const e=new Map,i=new Map,n=new Map;for(const r of t.specialpagealiases){const s=r.realname;e.set(s,s);const o=vn.normalizeSpecialPageName(s);n.set(o,s);for(const a of r.aliases){i.set(a,s);const c=vn.normalizeSpecialPageName(a);n.set(c,s)}}return{byRealName:e,byAlias:i,byNormalized:n}},findSpecialPageRealName:(t,e)=>{const i=t.split("/")[0];let n=e.byRealName.get(i)??e.byAlias.get(i);if(n!==void 0)return n;const r=vn.normalizeSpecialPageName(i);return e.byNormalized.get(r)??null}},Ot={normalizeNamespaceText:t=>t.replace(/[_\s]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),buildIndex:t=>{const e=new Map,i=new Map,n=new Map,r=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??"");r.set(c,a),r.set(l,a)}for(const s of t.namespacealiases){n.set(s.alias,s.id);const o=Ot.normalizeNamespaceText(s.alias);r.set(o,s.id)}return{byName:e,byCanonical:i,byAlias:n,byNormalized:r}},findNamespaceId:(t,e)=>{let i=e.byName.get(t)??e.byCanonical.get(t)??e.byAlias.get(t);if(i!==void 0)return i;const n=Ot.normalizeNamespaceText(t);return e.byNormalized.get(n)??null},isTalkPage:t=>t%2===1&&t>0,getDefaultNamespaceInfo:t=>({id:t,name:"",canonical:"",case:"first-letter",content:!1,nonincludable:!1,subpages:!1})};function ug(t){var s,o;const e=ql.get(t);if(e)return e;const i=Ot.buildIndex(t),n=vn.buildSpecialPageIndex(t),a=class a{constructor(l,u){an(this,s);an(this,o);if(this.newTitle=a.create.bind(a),this.toText=this.getPrefixedText.bind(this),this.toString=this.getPrefixedDBKey.bind(this),Be(this,s,l||""),Be(this,o,u??0),u===void 0)this.fixNSByTitle();else{const d=this.parseTitlePrefix(de(this,s));d&&d.namespaceId===de(this,o)&&Be(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),m=l.substring(u+1),p=Ot.findNamespaceId(d,a._namespaceIndex);return p===null?null:{namespaceId:p,mainTitle:m}}adoptNamespaceFromTitle(){const l=this.parseTitlePrefix(de(this,s));l&&(Be(this,s,l.mainTitle),Be(this,o,l.namespaceId))}fixNSByTitle(){const l=de(this,s).indexOf(":");if(l!==-1){if(l===0){Be(this,s,de(this,s).substring(1));return}this.adoptNamespaceFromTitle()}}getNamespaceInfo(){return a._meta.namespaces[de(this,o)]??Ot.getDefaultNamespaceInfo(de(this,o))}resolveSpecialFullTitle(){if(de(this,o)!==-1)return null;const l=vn.findSpecialPageRealName(de(this,s),a._specialPageIndex);if(!l)return null;const u=de(this,s).includes("/")?de(this,s).substring(de(this,s).indexOf("/")):"";return l+u}formatMainForOutput(l){const u=this.getNamespaceInfo(),m=this.resolveSpecialFullTitle()??de(this,s),p=l==="db"?bn.toDBKey(m):bn.toNormalText(m);return bn.ensureCase(p,u.case)}getMainDBKey(){return this.formatMainForOutput("db")}getMainText(){return this.formatMainForOutput("text")}getMainRootText(){return this.getMainText().split("/")[0]}getPrefixedDBKey(){return de(this,o)===0?this.getMainDBKey():`${this.getNamespaceDBKey()}:${this.getMainDBKey()}`}getPrefixedText(){return de(this,o)===0?this.getMainText():`${this.getNamespaceText()}:${this.getMainText()}`}getNamespaceId(){return de(this,o)}getNamespaceText(){return this.getNamespaceInfo().name??""}getNamespaceDBKey(){const l=this.getNamespaceInfo();return bn.ensureCase(bn.toDBKey(this.getNamespaceText()),l.case)}getSubjectPage(){if(Ot.isTalkPage(de(this,o))){const l=de(this,o)-1;return new a(de(this,s),l)}return this}getTalkPage(){if(Ot.isTalkPage(de(this,o)))return this;if(de(this,o)<0)return null;const l=de(this,o)+1;return a._meta.namespaces[l.toString()]?new a(de(this,s),l):null}getURL(l){const u=this.getPrefixedDBKey();return this.buildArticleURL(u,l)}buildArticleURL(l,u){const m=a._meta.general.articlepath.replace("$1",l),p=new URL(m,location.origin);return u&&(u instanceof URLSearchParams?u:new URLSearchParams(u)).forEach((x,k)=>{p.searchParams.set(k,x)}),p}setTitle(l){Be(this,s,l);const u=de(this,o);Be(this,o,0);const d=this.parseTitlePrefix(de(this,s));return d?(u!==0&&d.namespaceId===u?(Be(this,s,d.mainTitle),Be(this,o,u)):(Be(this,s,d.mainTitle),Be(this,o,d.namespaceId)),this):this}setMainText(l){return Be(this,s,l),this}setNamespaceText(l){const u=Ot.findNamespaceId(l,a._namespaceIndex);return u!==null&&Be(this,o,u),this}setNamespaceId(l){return Be(this,o,l),this}equals(l){return typeof l=="string"&&(l=new a(l)),this.getPrefixedDBKey()===l.getPrefixedDBKey()}isSpecial(l){if(de(this,o)!==-1)return!1;const u=new a(l,-1);return this.getMainRootText()===u.getMainRootText()}toJSON(){return{ns:de(this,o),text:this.getMainText(),title:this.getPrefixedText(),url:this.getURL().toString(),isSpecial:de(this,o)<0}}};s=new WeakMap,o=new WeakMap,a._meta=t,a._namespaceIndex=i,a._specialPageIndex=n;let r=a;return ql.set(t,r),r}const wn=()=>{let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}},Vn=class Vn extends pt{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=ug(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:n,pageId:r,revId:s}=e??{};if(typeof n=="string")return this.newTitle(n);let o,a;if(s?(o=parseInt(s.toString(),10),a="revid"):r&&(o=parseInt(r.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}=wn();this._cachedTitles.set(`${a}:${o}`,c);try{const{wikiPage:d}=this.ctx;let m=null;if(a==="pageid")m=await d.newFromPageId(o);else if(a==="revid")m=await d.newFromRevision(o);else throw new Error(`Invalid kind: ${a}`);l(this.newTitle(m.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 n,r,s="view";const o=i.getMainDBKey().split("/").slice(1).join("/")||"";if(i.isSpecial("edit")&&o)n=o,s="edit";else if(i.isSpecial("talkpage")&&o){const a=i.newTitle(o).getTalkPage();if(!a)return null;n=a.getPrefixedDBKey()}else if(i.isSpecial("mypage"))n=i.newTitle(this.ctx.wiki.userInfo.name,2).getPrefixedDBKey()+(o?`/${o}`:"");else if(i.isSpecial("mytalk"))n=i.newTitle(this.ctx.wiki.userInfo.name,3).getPrefixedDBKey()+(o?`/${o}`:"");else if(i.isSpecial("newsection")&&o)n=o,r="new",s="edit";else return null;return{title:new this.Title(n),section:r,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:!Vn.REG_SKIPPED_HREF.test(e)}parseWikiLink(e){if(!e||typeof e=="string"&&!this.validateHrefAttr(e))return null;const i=Al(e);if(!this.isWikiLink(i.toString()))return null;const n=i.searchParams,r=i.hash.replace("#",""),s=n.get("action")||"view",o=n.get("title")||"",a=parseInt(n.get("curid")||"0",10),c=parseInt(n.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,m;if(c)m=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:m,url:i,params:n,hash:r,action:s}}};Vn.inject=["wiki","wikiPage"],Vn.REG_SKIPPED_HREF=/^(#|javascript:|vbscript:|file:)/i;let no=Vn;const zl=t=>typeof t=="function";async function dg(t){return zl(t)?await t():t}function Hl(t){return zl(t)?t():t}var fg=Object.create,ro=Object.defineProperty,hg=Object.getOwnPropertyDescriptor,Wl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Kl=t=>{throw TypeError(t)},pg=(t,e,i)=>e in t?ro(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,gg=(t,e)=>ro(t,"name",{value:e,configurable:!0}),mg=t=>[,,,fg(t?.[Wl("metadata")]??null)],yg=["class","method","getter","setter","accessor","field","value","get","set"],Vl=t=>t!==void 0&&typeof t!="function"?Kl("Function expected"):t,bg=(t,e,i,n,r)=>({kind:yg[t],name:e,metadata:n,addInitializer:s=>i._?Kl("Already initialized"):r.push(Vl(s||null))}),vg=(t,e)=>pg(e,Wl("metadata"),t[3]),wg=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},_g=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&hg(r,i));gg(r,i);for(var h=n.length-1;h>=0;h--)c=bg(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,Vl(o)&&(r=o);return vg(t,r),p&&ro(r,i,p),u?l^4?s:p:r},Gl,so,Ql;Gl=[xe(["storage","wiki"])];class mr extends(Ql=pt){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 r=this.defaultOf(e);return this.logger.debug(e,`(fallback value: ${r})`),r});const n=await this.db.get(e,void 0);return n!==null?n:await dg(i)}async getAll(){const e=this.loadDefaultConfigs();for await(const[i,n]of this.db.entries())i!=="_touched"&&i in e&&(e[i]=n.value);return e}async set(e,i){return(await this.setMany({[e]:i}))[e]}async setMany(e){const i=this.loadDefaultConfigs(),n={};for(const[r,s]of Object.entries(e))s===i[r]||s===void 0?n[r]=void 0:n[r]=s;return await this.db.set(n),this.ctx.emit("preferences/changed",{ctx:this.ctx,input:e,changes:n}),n}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(),n={};return Object.entries(i).sort(([r],[s])=>r.localeCompare(s)).forEach(([r,s])=>{const o=e[r];o!==void 0&&o!==s&&(n[r]=o)}),n}loadDefaultConfigs(){const e={};return this.getConfigRegistries().forEach(i=>{try{const n=i.schema({});Object.entries(n).forEach(([r,s])=>{e[r]=s})}catch{}}),Object.entries(e).forEach(([i,n])=>{this._defaultPreferences[i]=n}),e}registerCustomConfig(e,i,n){const r={name:e,schema:i,category:n||"general"},s=this.customRegistries.findIndex(o=>o.name===e);return s>=0?this.customRegistries[s]=r:this.customRegistries.push(r),this}getConfigRegistries(e){return Array.from(this.ctx.registry.entries()).map(([i])=>i===null?{name:"@root",schema:Ui?.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 I(I.intersect(this.getConfigRegistries().map(e=>e.schema)))}defineCategory(e){const i=this.categoryDefinitions.findIndex(n=>n.name===e.name);return i<0?this.categoryDefinitions.push(e):this.categoryDefinitions[i]=e,this.categoryDefinitions.sort((n,r)=>(n.index??0)-(r.index??0)),this}getConfigCategories(){return this.categoryDefinitions}async _migrageFromLegacyMasterDB(){const e=this.ctx.storage.createDatabase("preferences",1/0);let i=0;for await(const[n,r]of e.entries())n!=="_touched"&&(await this.db.set(n,r.value),i++);return i&&this.logger.info(`Migrated ${i} preferences from master DB`),await e.clear(),await e?.db?.disconnect?.(),i}}so=mg(Ql),mr=_g(so,0,"PreferencesService",Gl,mr),wg(so,1,mr);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 Yl="",Xl="",xg=/\\\{/g,kg=/\\\}/g,Sg=new RegExp(Yl,"g"),$g=new RegExp(Xl,"g");function Jl(t){const e=t?{...t}:void 0;return(n,...r)=>Eg(e,n,...r)}function Eg(t,e,...i){if(!e)return"";let n=String(e).replace(xg,Yl).replace(kg,Xl),r={},s=[];i.length===1&&Array.isArray(i[0])?s=i[0]:i.length===1&&Pg(i[0])?r=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(r&&Object.keys(r).length)for(const a of Object.keys(r))o[a]=r[a];if(t&&Object.keys(t).length)for(const a of Object.keys(t))typeof o[a]>"u"&&(o[a]=t[a]);return n=n.replace(/\{\{\s*([\s\S]*?)\s*\}\}/g,(a,c)=>{const l=String(c).trim();if(!l)return"";try{const u=Cg(l,o);return u==null?"":String(u)}catch{return""}}),n.replace(Sg,"{").replace($g,"}")}function Pg(t){return typeof t=="object"&&t!==null&&t.constructor===Object}const Cg=Ig();function Ig(){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,n)=>{const r=new Proxy(n,{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,r)}}function Ul(t){return t.charAt(0).toLowerCase()+t.slice(1)}function Ci(t){return Ul(t).replace(/_/g,"-").replace(/.[A-Z]+/g,e=>e[0]+"-"+e.slice(1).toLowerCase())}function dg(t){return Ul(t).replace(/-/g,"_").replace(/.[A-Z]+/g,e=>e[0]+"_"+e.slice(1).toLowerCase())}function Xt(t,e){let i=t[0]??"";for(let n=0;n<e.length;n++)i+=String(e[n])+(t[n+1]??"");return i}class fg{constructor(e,i){this.languages=new Map,this.currentLanguage="en",this.missingKeys=new Map,this.usedKeys=new Set;const n=i?.language||"en";this.currentLanguage=n,this.interpolate=jl(i?.globals),e&&Object.keys(e).length&&this.setLanguageData(n,e)}setGlobals(e){return this.interpolate=jl(e),this}set(e,i){const n=this.currentLanguage,r=this.ensureLanguageMap(n);if(typeof e=="string"&&typeof i=="string")r.set(e,i);else if(typeof e=="object"){const s=this.toStringRecord(e);for(const[o,a]of Object.entries(s))r.set(o,a)}return this}setLanguageData(e,i){e=Ci(e).toLowerCase();const n=this.ensureLanguageMap(e),r=this.toStringRecord(i);for(const[s,o]of Object.entries(r))n.set(s,o);return this}setLanguage(e){return e=Ci(e).toLowerCase(),this.currentLanguage=e,this}getLanguage(){return this.currentLanguage}hasLanguage(e){e=Ci(e).toLowerCase();const i=this.languages.get(e);return i&&Object.keys(i).length>0}toStringRecord(e,i){const n={};for(const[r,s]of Object.entries(e)){const o=i?`${i}.${r}`:r;if(s&&typeof s=="object"&&!Array.isArray(s)){const a=this.toStringRecord(s,o);for(const[l,c]of Object.entries(a))n[l]=String(c)}else n[o]=String(s)}return n}has(e){const i=this.resolveLanguageOrder(this.currentLanguage);for(const n of i)if(this.languages.get(n)?.has(e))return!0;return!1}get(e){this.recordUsedKey(e);const i=this.resolveLanguageOrder(this.currentLanguage),n=[];for(const r of i){const o=this.languages.get(r)?.get(e);if(typeof o<"u")return n.length&&this.recordMissing(e,n),o;n.push(r)}n.length&&this.recordMissing(e,n)}translate(e,...i){if(!e)return"";if(this.currentLanguage==="qqx")return`⧼${e}⧽`;const n=this.get(e);return typeof n>"u"?this.interpolate(e,...i):this.interpolate(n,...i)}$(...e){if(Array.isArray(e[0])&&e[0]?.raw){const r=e[0],s=e.slice(1),o=Xt(r,s);return this.translate(o)}const n=e;return(r,...s)=>{const o=Xt(r,s);return this.translate(o,...n)}}translateRaw(e){return e?this.currentLanguage==="qqx"?`⧼${e}⧽`:this.get(e)??e:""}$raw(...e){if(Array.isArray(e[0])&&e[0]?.raw){const n=e[0],r=e.slice(1),s=Xt(n,r);return this.translateRaw(s)}return(n,...r)=>{const s=Xt(n,r);return this.translateRaw(s)}}message(e,...i){if(!e)return"";if(this.currentLanguage==="qqx")return`⧼${e}⧽`;const n=this.get(e);return typeof n>"u"?`(${e})`:this.interpolate(n,...i)}$$(...e){if(Array.isArray(e[0])&&e[0]?.raw){const r=e[0],s=e.slice(1),o=Xt(r,s);return this.message(o)}const n=e;return(r,...s)=>{const o=Xt(r,s);return this.message(o,...n)}}messageRaw(e){return e?this.currentLanguage==="qqx"?`⧼${e}⧽`:this.get(e)??`(${e})`:""}$$raw(...e){if(Array.isArray(e[0])&&e[0].raw){const n=e[0],r=e.slice(1),s=Xt(n,r);return this.messageRaw(s)}return(n,...r)=>{const s=Xt(n,r);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 n=this.missingKeys.get(e)||[];for(const r of i)n.includes(r)||n.push(r);this.missingKeys.set(e,n)}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}}function Ut(t){return function(e){return e.PreferencesSchema=t,e}}var hg=Object.create,Gs=Object.defineProperty,pg=Object.getOwnPropertyDescriptor,Fl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Bl=t=>{throw TypeError(t)},gg=(t,e,i)=>e in t?Gs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,mg=(t,e)=>Gs(t,"name",{value:e,configurable:!0}),yg=t=>[,,,hg(t?.[Fl("metadata")]??null)],bg=["class","method","getter","setter","accessor","field","value","get","set"],ql=t=>t!==void 0&&typeof t!="function"?Bl("Function expected"):t,vg=(t,e,i,n,r)=>({kind:bg[t],name:e,metadata:n,addInitializer:s=>i._?Bl("Already initialized"):r.push(ql(s||null))}),wg=(t,e)=>gg(e,Fl("metadata"),t[3]),_g=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},xg=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&pg(r,i));mg(r,i);for(var f=n.length-1;f>=0;f--)l=vg(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,ql(o)&&(r=o);return wg(t,r),p&&Gs(r,i,p),u?c^4?s:p:r},Hl,Qs,zl;const Kl=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()}));Hl=[be(["wiki","preferences"]),Ut(R.object({"i18n.index_url":R.string().description("I18n index URL (DO NOT CHANGE THIS) ").default(St.I18N_INDEX_URL)}).description("").extra("category","general"))];class or extends(zl=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 fg({},{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 n=await this.ctx.preferences.get("language"),r=this.normalizeLanguageCode(n);this.logger.debug("Settings",{prefer:n,normalized:r});try{await this.switchLanguage(r),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"),Ci(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,n){const r=n?.namespace?{[n.namespace]:i}:i;this.manager.setLanguageData(e,r),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,n])=>(e.push({code:i,...n}),e),[])}findLanguageMeta(e,i){const n=Ci(String(i)).toLowerCase(),r=e.languages[n];if(r)return{code:n,...r};{const s=e.languages.en;if(s)return{code:"en",...s}}}async getI18nIndex(e,i=!1){if(!i){const r=await this.i18nIndexDB.get(e);if(r)try{return Kl(r)}catch(s){this.logger.error("Failed to parse cached i18n index",s),this.i18nIndexDB.delete(e)}}const n=await this.fetchI18nIndex(e);return this.i18nIndexDB.set(e,n),n}async fetchI18nIndex(e){const i=await fetch(e).then(n=>n.json());return Kl(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 n=this.findLanguageMeta(this._indexCache,e);if(!n)return{};const r=`${this._indexUrl}#${n.file}`;if(!i){const o=await this.i18nDataDB.get(r);if(o&&Object.keys(o).length>0)return this.logger.debug("Using cached language data",e,o),o}const s=n.data||await fetch(new URL(n.file,this._indexUrl).toString()).then(o=>o.json());return this.i18nDataDB.set(r,s),this.logger.debug("Language data fetched",e,n.file,s),s}getMissingReport(){return this.manager.getMissingReport()}clearMissingReport(){this.manager.clearMissingReport()}async onClearCache(){await this.i18nIndexDB.clear(),await this.i18nDataDB.clear()}}Qs=yg(zl),or=xg(Qs,0,"I18nService",Hl,or),_g(Qs,1,or);const kg=new TextEncoder;function Sg(t){if(typeof t=="string")return kg.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 $g(t){let e="";for(let i=0;i<t.length;i++){const n=t[i].toString(16).padStart(2,"0");e+=n}return e}function Eg(t,e){return t<<e|t>>>32-e}const Pg=[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],Cg=new Array(64).fill(0).map((t,e)=>Math.floor(Math.abs(Math.sin(e+1))*2**32)>>>0);function Rg(t){const e=Sg(t),i=(56-(e.length+1)%64+64)%64,n=e.length+1+i+8,r=new Uint8Array(n);r.set(e,0),r[e.length]=128;const s=e.length,o=s<<3>>>0,a=s>>>29>>>0,l=new DataView(r.buffer);l.setUint32(n-8,o,!0),l.setUint32(n-4,a,!0);let c=1732584193,u=4023233417,d=2562383102,y=271733878;const p=new Uint32Array(16);for(let x=0;x<r.length;x+=64){for(let b=0;b<16;b++)p[b]=l.getUint32(x+b*4,!0);let S=c,I=u,m=d,g=y;for(let b=0;b<64;b++){let k,P;b<16?(k=I&m|~I&g,P=b):b<32?(k=g&I|~g&m,P=(5*b+1)%16):b<48?(k=I^m^g,P=(3*b+5)%16):(k=m^(I|~g),P=7*b%16);const L=g,C=S+k+Cg[b]+p[P]>>>0;g=m,m=I,I=I+Eg(C,Pg[b])>>>0,S=L}c=c+S>>>0,u=u+I>>>0,d=d+m>>>0,y=y+g>>>0}const f=new Uint8Array(16),w=new DataView(f.buffer);return w.setUint32(0,c,!0),w.setUint32(4,u,!0),w.setUint32(8,d,!0),w.setUint32(12,y,!0),f}var Ig=Object.create,Ys=Object.defineProperty,Ag=Object.getOwnPropertyDescriptor,Wl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Vl=t=>{throw TypeError(t)},Og=(t,e,i)=>e in t?Ys(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Tg=(t,e)=>Ys(t,"name",{value:e,configurable:!0}),Lg=t=>[,,,Ig(t?.[Wl("metadata")]??null)],Ng=["class","method","getter","setter","accessor","field","value","get","set"],Gl=t=>t!==void 0&&typeof t!="function"?Vl("Function expected"):t,Mg=(t,e,i,n,r)=>({kind:Ng[t],name:e,metadata:n,addInitializer:s=>i._?Vl("Already initialized"):r.push(Gl(s||null))}),Dg=(t,e)=>Og(e,Wl("metadata"),t[3]),jg=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Ug=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Ag(r,i));Tg(r,i);for(var f=n.length-1;f>=0;f--)l=Mg(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,Gl(o)&&(r=o);return Dg(t,r),p&&Ys(r,i,p),u?c^4?s:p:r},Ql,Xs,Yl;Ql=[be(["wiki","wikiTitle","wikiPage","apiService"])];class ar extends(Yl=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 n=this.getFileName(e),r=$g(Rg(n));let s=[];for(let o=1;o<=i;o++)s.push(r.slice(0,o));return s.push(n),s.join("/")}getFileUrl(e,i){if(i=i||this.defaultFileRepo,!i)throw new Error("No file repository found");const n=this.getHashPath(e);return new URL(`${i.rootUrl}/${n}`,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}})}}Xs=Lg(Yl),ar=Ug(Xs,0,"WikiFileService",Ql,ar),jg(Xs,1,ar);const Dn=class Dn extends Ke{constructor(i){super({name:"InPageEdit"});Qi(this,dt);this.version="0.15.0",this.Endpoints=St,this.schema=R,this.config=xt(Dn.DEFAULT_CONFIG,i),this.logger=Va({name:"IPE",color:"#33aaff",level:this.config.logLevel}),ot(this,dt,Nf).call(this)}async withInject(i){const{promise:n,resolve:r}=re();return this.inject(i,s=>{r(s)}),n}};dt=new WeakSet,Nf=async function(){await ot(this,dt,Mf).call(this),this.config.autoInstallCorePlugins&&ot(this,dt,jf).call(this),ot(this,dt,Uf).call(this)},Mf=async function(){this.plugin(or),this.plugin(kh,this.config.apiConfigs),this.plugin(Yn),this.plugin(Nh),this.plugin(Ep),this.plugin(sr),this.plugin(Hp,{dbName:this.config.storageNamespace}),this.plugin(ar),this.plugin(rr),this.plugin(zs),this.plugin(Ks),ot(this,dt,Df).call(this,["i18n","$","$$","api","currentPage","resourceLoader","modal","preferences","storage","wikiPage","wikiTitle","wiki","getUrl","getSciprtUrl","getMainpageUrl"])},Df=function(i){if(!Array.isArray(i)||i.length===0)return this;for(const n of i){const r=this[Dn.internal][n];r?.type==="service"&&(r.builtin=!0)}return this},jf=async function(){[Promise.resolve().then(()=>Jg).then(({PluginAnalytics:n})=>n),Promise.resolve().then(()=>cm).then(({PluginInArticleLinks:n})=>n),Promise.resolve().then(()=>Kb).then(({PluginPluginStore:n})=>n),Promise.resolve().then(()=>bv).then(({PluginPreferencesUI:n})=>n),Promise.resolve().then(()=>Tv).then(({PluginQuickEdit:n})=>n),Promise.resolve().then(()=>zv).then(({PluginQuickMove:n})=>n),Promise.resolve().then(()=>tw).then(({PluginQuickPreview:n})=>n),Promise.resolve().then(()=>bw).then(({PluginQuickDiff:n})=>n),Promise.resolve().then(()=>vw).then(({PluginQuickRedirect:n})=>n),Promise.resolve().then(()=>Aw).then(({PluginQuickUpload:n})=>n),Promise.resolve().then(()=>Tw).then(({PluginQuickUsage:n})=>n),Promise.resolve().then(()=>zw).then(({PluginToolbox:n})=>n)].forEach(async n=>{this.plugin(await n)})},Uf=async function(){this.inject(["resourceLoader"],i=>{})},Dn.DEFAULT_CONFIG={apiConfigs:{},legacyPreferences:{},logLevel:vs.info,storageNamespace:"InPageEdit",autoloadStyles:!0,autoInstallCorePlugins:!0};let Ri=Dn;const ns=class ns{constructor(e,i=void 0,n){Qi(this,jn);this.ctx=e,this.disposeHandlers=[],this.name=n||"",this.config=i||{};const{promise:r,resolve:s,reject:o}=Promise.withResolvers();queueMicrotask(()=>{this.name||(this.name=this.constructor.name);try{const a=this.start();a&&typeof a.then=="function"?a.then(()=>s()).catch(l=>{this.logger.error("start() returns a rejected promise",l),o(l)}):s()}catch(a){this.logger.error("start() threw synchronously",a),o(a)}r.then(()=>{this.logger.debug("started")}),r.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){Le(this,jn,dg(e).toUpperCase())}get name(){return ae(this,jn)}get logger(){return this.ctx.logger(this.name)}};jn=new WeakMap,ns.inject=[],ns.reusable=!1;let Ae=ns;window.RLQ||(window.RLQ=[]),window.__IPE_MODULES__||(window.__IPE_MODULES__=[]),Bg("InPageEdit#autoload",()=>{const t=Xl();t&&Fg({baseURL:t,InPageEdit:Ri})});async function Fg(t={baseURL:Xl(),InPageEdit:Ri}){const{baseURL:e,InPageEdit:i}=t;typeof window?.ipe?.stop=="function"&&await window.ipe.stop();const n=window.InPageEdit||{},r=new i({apiConfigs:{baseURL:e},legacyPreferences:n?.myPreferences||{}});if(window.ipe=r,await r.start(),window.RLQ.push(()=>{mw.hook("InPageEdit.ready").fire(r)}),Array.isArray(window.__IPE_MODULES__)){const s=[];for(;window.__IPE_MODULES__.length;)try{const o=window.__IPE_MODULES__.shift();typeof o=="function"&&o?.(r),s.push(o)}catch{}window.__IPE_MODULES__={push:o=>{typeof o=="function"&&o(r),s.push(o)}},r.on("dispose",()=>{window.__IPE_MODULES__=s})}r.logger("AUTOLOAD").info(`
12
+ `);return(i,n)=>{const r=new Proxy(n,{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,r)}}function Zl(t){return t.charAt(0).toLowerCase()+t.slice(1)}function ji(t){return Zl(t).replace(/_/g,"-").replace(/.[A-Z]+/g,e=>e[0]+"-"+e.slice(1).toLowerCase())}function Rg(t){return Zl(t).replace(/-/g,"_").replace(/.[A-Z]+/g,e=>e[0]+"_"+e.slice(1).toLowerCase())}function ai(t,e){let i=t[0]??"";for(let n=0;n<e.length;n++)i+=String(e[n])+(t[n+1]??"");return i}class Ag{constructor(e,i){this.languages=new Map,this.currentLanguage="en",this.missingKeys=new Map,this.usedKeys=new Set;const n=i?.language||"en";this.currentLanguage=n,this.interpolate=Jl(i?.globals),e&&Object.keys(e).length&&this.setLanguageData(n,e)}setGlobals(e){return this.interpolate=Jl(e),this}set(e,i){const n=this.currentLanguage,r=this.ensureLanguageMap(n);if(typeof e=="string"&&typeof i=="string")r.set(e,i);else if(typeof e=="object"){const s=this.toStringRecord(e);for(const[o,a]of Object.entries(s))r.set(o,a)}return this}setLanguageData(e,i){e=ji(e).toLowerCase();const n=this.ensureLanguageMap(e),r=this.toStringRecord(i);for(const[s,o]of Object.entries(r))n.set(s,o);return this}setLanguage(e){return e=ji(e).toLowerCase(),this.currentLanguage=e,this}getLanguage(){return this.currentLanguage}hasLanguage(e){e=ji(e).toLowerCase();const i=this.languages.get(e);return i&&Object.keys(i).length>0}toStringRecord(e,i){const n={};for(const[r,s]of Object.entries(e)){const o=i?`${i}.${r}`:r;if(s&&typeof s=="object"&&!Array.isArray(s)){const a=this.toStringRecord(s,o);for(const[c,l]of Object.entries(a))n[c]=String(l)}else n[o]=String(s)}return n}has(e){const i=this.resolveLanguageOrder(this.currentLanguage);for(const n of i)if(this.languages.get(n)?.has(e))return!0;return!1}get(e){this.recordUsedKey(e);const i=this.resolveLanguageOrder(this.currentLanguage),n=[];for(const r of i){const o=this.languages.get(r)?.get(e);if(typeof o<"u")return n.length&&this.recordMissing(e,n),o;n.push(r)}n.length&&this.recordMissing(e,n)}translate(e,...i){if(!e)return"";if(this.currentLanguage==="qqx")return`⧼${e}⧽`;const n=this.get(e);return typeof n>"u"?this.interpolate(e,...i):this.interpolate(n,...i)}$(...e){if(Array.isArray(e[0])&&e[0]?.raw){const r=e[0],s=e.slice(1),o=ai(r,s);return this.translate(o)}const n=e;return(r,...s)=>{const o=ai(r,s);return this.translate(o,...n)}}translateRaw(e){return e?this.currentLanguage==="qqx"?`⧼${e}⧽`:this.get(e)??e:""}$raw(...e){if(Array.isArray(e[0])&&e[0]?.raw){const n=e[0],r=e.slice(1),s=ai(n,r);return this.translateRaw(s)}return(n,...r)=>{const s=ai(n,r);return this.translateRaw(s)}}message(e,...i){if(!e)return"";if(this.currentLanguage==="qqx")return`⧼${e}⧽`;const n=this.get(e);return typeof n>"u"?`(${e})`:this.interpolate(n,...i)}$$(...e){if(Array.isArray(e[0])&&e[0]?.raw){const r=e[0],s=e.slice(1),o=ai(r,s);return this.message(o)}const n=e;return(r,...s)=>{const o=ai(r,s);return this.message(o,...n)}}messageRaw(e){return e?this.currentLanguage==="qqx"?`⧼${e}⧽`:this.get(e)??`(${e})`:""}$$raw(...e){if(Array.isArray(e[0])&&e[0].raw){const n=e[0],r=e.slice(1),s=ai(n,r);return this.messageRaw(s)}return(n,...r)=>{const s=ai(n,r);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 n=this.missingKeys.get(e)||[];for(const r of i)n.includes(r)||n.push(r);this.missingKeys.set(e,n)}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 Tg=Object.create,oo=Object.defineProperty,Og=Object.getOwnPropertyDescriptor,ec=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),tc=t=>{throw TypeError(t)},Lg=(t,e,i)=>e in t?oo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ng=(t,e)=>oo(t,"name",{value:e,configurable:!0}),Mg=t=>[,,,Tg(t?.[ec("metadata")]??null)],Dg=["class","method","getter","setter","accessor","field","value","get","set"],ic=t=>t!==void 0&&typeof t!="function"?tc("Function expected"):t,jg=(t,e,i,n,r)=>({kind:Dg[t],name:e,metadata:n,addInitializer:s=>i._?tc("Already initialized"):r.push(ic(s||null))}),Ug=(t,e)=>Lg(e,ec("metadata"),t[3]),Fg=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Bg=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&Og(r,i));Ng(r,i);for(var h=n.length-1;h>=0;h--)c=jg(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,ic(o)&&(r=o);return Ug(t,r),p&&oo(r,i,p),u?l^4?s:p:r},nc,ao,rc;const sc=new I(I.object({manifest_version:I.const(1).required(),base_language:I.string().required(),last_modified:I.string().required(),languages:I.dict(I.object({file:I.string().required(),fallback:I.string(),iso_name:I.string(),endonym:I.string(),data:I.transform(I.dict(I.any()).default({}),t=>Object.keys(t).length>0?t:void 0)})).required()}));nc=[xe(["wiki","preferences"]),Tt(I.object({"i18n.index_url":I.string().description("I18n index URL (DO NOT CHANGE THIS) ").default(Lt.I18N_INDEX_URL)}).description("").extra("category","general"))];class yr extends(rc=pt){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 Ag({},{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",I.object({language:I.union(["@user","@site",I.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 n=await this.ctx.preferences.get("language"),r=this.normalizeLanguageCode(n);this.logger.debug("Settings",{prefer:n,normalized:r});try{await this.switchLanguage(r),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",I.object({language:I.union([I.const("@user").description(this.$`Same as your personal language`),I.const("@site").description(this.$`Same as the site language`),...this.getAvailableLanguageCodes().map(({code:s,endonym:o,iso_name:a})=>I.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"),ji(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,n){const r=n?.namespace?{[n.namespace]:i}:i;this.manager.setLanguageData(e,r),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,n])=>(e.push({code:i,...n}),e),[])}findLanguageMeta(e,i){const n=ji(String(i)).toLowerCase(),r=e.languages[n];if(r)return{code:n,...r};{const s=e.languages.en;if(s)return{code:"en",...s}}}async getI18nIndex(e,i=!1){if(!i){const r=await this.i18nIndexDB.get(e);if(r)try{return sc(r)}catch(s){this.logger.error("Failed to parse cached i18n index",s),this.i18nIndexDB.delete(e)}}const n=await this.fetchI18nIndex(e);return this.i18nIndexDB.set(e,n),n}async fetchI18nIndex(e){const i=await fetch(e).then(n=>n.json());return sc(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 n=this.findLanguageMeta(this._indexCache,e);if(!n)return{};const r=`${this._indexUrl}#${n.file}`;if(!i){const o=await this.i18nDataDB.get(r);if(o&&Object.keys(o).length>0)return this.logger.debug("Using cached language data",e,o),o}const s=n.data||await fetch(new URL(n.file,this._indexUrl).toString()).then(o=>o.json());return this.i18nDataDB.set(r,s),this.logger.debug("Language data fetched",e,n.file,s),s}getMissingReport(){return this.manager.getMissingReport()}clearMissingReport(){this.manager.clearMissingReport()}async onClearCache(){await this.i18nIndexDB.clear(),await this.i18nDataDB.clear()}}ao=Mg(rc),yr=Bg(ao,0,"I18nService",nc,yr),Fg(ao,1,yr);const qg=new TextEncoder;function zg(t){if(typeof t=="string")return qg.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 Hg(t){let e="";for(let i=0;i<t.length;i++){const n=t[i].toString(16).padStart(2,"0");e+=n}return e}function Wg(t,e){return t<<e|t>>>32-e}const Kg=[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],Vg=new Array(64).fill(0).map((t,e)=>Math.floor(Math.abs(Math.sin(e+1))*2**32)>>>0);function Gg(t){const e=zg(t),i=(56-(e.length+1)%64+64)%64,n=e.length+1+i+8,r=new Uint8Array(n);r.set(e,0),r[e.length]=128;const s=e.length,o=s<<3>>>0,a=s>>>29>>>0,c=new DataView(r.buffer);c.setUint32(n-8,o,!0),c.setUint32(n-4,a,!0);let l=1732584193,u=4023233417,d=2562383102,m=271733878;const p=new Uint32Array(16);for(let k=0;k<r.length;k+=64){for(let w=0;w<16;w++)p[w]=c.getUint32(k+w*4,!0);let E=l,y=u,b=d,g=m;for(let w=0;w<64;w++){let S,R;w<16?(S=y&b|~y&g,R=w):w<32?(S=g&y|~g&b,R=(5*w+1)%16):w<48?(S=y^b^g,R=(3*w+5)%16):(S=b^(y|~g),R=7*w%16);const B=g,N=E+S+Vg[w]+p[R]>>>0;g=b,b=y,y=y+Wg(N,Kg[w])>>>0,E=B}l=l+E>>>0,u=u+y>>>0,d=d+b>>>0,m=m+g>>>0}const h=new Uint8Array(16),x=new DataView(h.buffer);return x.setUint32(0,l,!0),x.setUint32(4,u,!0),x.setUint32(8,d,!0),x.setUint32(12,m,!0),h}var Qg=Object.create,lo=Object.defineProperty,Yg=Object.getOwnPropertyDescriptor,oc=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ac=t=>{throw TypeError(t)},Xg=(t,e,i)=>e in t?lo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Jg=(t,e)=>lo(t,"name",{value:e,configurable:!0}),Zg=t=>[,,,Qg(t?.[oc("metadata")]??null)],em=["class","method","getter","setter","accessor","field","value","get","set"],lc=t=>t!==void 0&&typeof t!="function"?ac("Function expected"):t,tm=(t,e,i,n,r)=>({kind:em[t],name:e,metadata:n,addInitializer:s=>i._?ac("Already initialized"):r.push(lc(s||null))}),im=(t,e)=>Xg(e,oc("metadata"),t[3]),nm=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},rm=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&Yg(r,i));Jg(r,i);for(var h=n.length-1;h>=0;h--)c=tm(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,lc(o)&&(r=o);return im(t,r),p&&lo(r,i,p),u?l^4?s:p:r},cc,co,uc;cc=[xe(["wiki","wikiTitle","wikiPage","apiService"])];class br extends(uc=pt){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 n=this.getFileName(e),r=Hg(Gg(n));let s=[];for(let o=1;o<=i;o++)s.push(r.slice(0,o));return s.push(n),s.join("/")}getFileUrl(e,i){if(i=i||this.defaultFileRepo,!i)throw new Error("No file repository found");const n=this.getHashPath(e);return new URL(`${i.rootUrl}/${n}`,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}})}}co=Zg(uc),br=rm(co,0,"WikiFileService",cc,br),nm(co,1,br);const Gn=class Gn extends Ze{constructor(i){super({name:"InPageEdit"});an(this,vt);this.version="0.16.0",this.Endpoints=Lt,this.schema=I,this.config=Rt(Gn.DEFAULT_CONFIG,i),this.logger=rl({name:"IPE",color:"#33aaff",level:this.config.logLevel}),ht(this,vt,Wf).call(this)}async withInject(i){const{promise:n,resolve:r}=wn();return this.inject(i,s=>{r(s)}),n}};vt=new WeakSet,Wf=async function(){await ht(this,vt,Kf).call(this),this.config.autoInstallCorePlugins&&ht(this,vt,Gf).call(this),ht(this,vt,Qf).call(this)},Kf=async function(){this.plugin(yr),this.plugin(Th,this.config.apiConfigs),this.plugin(or),this.plugin(Hh),this.plugin(Np),this.plugin(mr),this.plugin(Jp,{dbName:this.config.storageNamespace}),this.plugin(gr),this.plugin(br),this.plugin(pr),this.plugin(io),this.plugin(no),ht(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 n of i){const r=this[Gn.internal][n];r?.type==="service"&&(r.builtin=!0)}return this},Gf=async function(){[Promise.resolve().then(()=>ym).then(({PluginAnalytics:n})=>n),Promise.resolve().then(()=>Cm).then(({PluginInArticleLinks:n})=>n),Promise.resolve().then(()=>uv).then(({PluginPluginStore:n})=>n),Promise.resolve().then(()=>Dv).then(({PluginPreferencesUI:n})=>n),Promise.resolve().then(()=>Jv).then(({PluginQuickEdit:n})=>n),Promise.resolve().then(()=>cw).then(({PluginQuickMove:n})=>n),Promise.resolve().then(()=>_w).then(({PluginQuickPreview:n})=>n),Promise.resolve().then(()=>Dw).then(({PluginQuickDiff:n})=>n),Promise.resolve().then(()=>jw).then(({PluginQuickRedirect:n})=>n),Promise.resolve().then(()=>Xw).then(({PluginQuickUpload:n})=>n),Promise.resolve().then(()=>Zw).then(({PluginQuickUsage:n})=>n),Promise.resolve().then(()=>u_).then(({PluginToolbox:n})=>n)].forEach(async n=>{this.plugin(await n)})},Qf=async function(){this.inject(["resourceLoader"],i=>{})},Gn.DEFAULT_CONFIG={apiConfigs:{},legacyPreferences:{},logLevel:Is.info,storageNamespace:"InPageEdit",autoloadStyles:!0,autoInstallCorePlugins:!0};let Ui=Gn;const ps=class ps{constructor(e,i=void 0,n){an(this,Qn);this.ctx=e,this.disposeHandlers=[],this.name=n||"",this.config=i||{};const{promise:r,resolve:s,reject:o}=wn();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)}r.then(()=>{this.logger.debug("started")}),r.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){Be(this,Qn,Rg(e).toUpperCase())}get name(){return de(this,Qn)}get logger(){return this.ctx.logger(this.name)}};Qn=new WeakMap,ps.inject=[],ps.reusable=!1;let je=ps;window.RLQ||(window.RLQ=[]),window.__IPE_MODULES__||(window.__IPE_MODULES__=[]),om("InPageEdit#autoload",()=>{const t=dc();t&&sm({baseURL:t,InPageEdit:Ui})});async function sm(t={baseURL:dc(),InPageEdit:Ui}){const{baseURL:e,InPageEdit:i}=t;typeof window?.ipe?.stop=="function"&&await window.ipe.stop();const n=window.InPageEdit||{},r=new i({apiConfigs:{baseURL:e},legacyPreferences:n?.myPreferences||{}});if(window.ipe=r,await r.start(),window.RLQ.push(()=>{mw.hook("InPageEdit.ready").fire(r)}),Array.isArray(window.__IPE_MODULES__)){const s=[];for(;window.__IPE_MODULES__.length;)try{const o=window.__IPE_MODULES__.shift();typeof o=="function"&&o?.(r),s.push(o)}catch{}window.__IPE_MODULES__={push:o=>{typeof o=="function"&&o(r),s.push(o)}},r.on("dispose",()=>{window.__IPE_MODULES__=s})}r.logger("AUTOLOAD").info(`
13
13
  ____ ____ ______ ___ __
14
14
  / _/___ / __ \\____ _____ ____ / ____/___/ (_) /_
15
15
  / // __ \\/ /_/ / __ \`/ __ \`/ _ \\/ __/ / __ / / __/
@@ -17,16 +17,20 @@
17
17
  /___/_/ /_/_/ \\__,_/\\__, /\\___/_____/\\__,_/_/\\__/
18
18
  /____/ v`+r.version+`
19
19
  - Wiki API Endpoint: ${e}
20
- - Documentation: ${St.HOME_URL}
21
- - Bug Reports: ${St.GITHUB_URL}`)}function Xl(){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 Bg(t,e){const i=Symbol.for(t);return window[i]?!1:(window[i]=!0,e(),!0)}var qg=Object.create,Js=Object.defineProperty,Hg=Object.getOwnPropertyDescriptor,Jl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Zl=t=>{throw TypeError(t)},zg=(t,e,i)=>e in t?Js(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Kg=(t,e)=>Js(t,"name",{value:e,configurable:!0}),Wg=t=>[,,,qg(t?.[Jl("metadata")]??null)],Vg=["class","method","getter","setter","accessor","field","value","get","set"],ec=t=>t!==void 0&&typeof t!="function"?Zl("Function expected"):t,Gg=(t,e,i,n,r)=>({kind:Vg[t],name:e,metadata:n,addInitializer:s=>i._?Zl("Already initialized"):r.push(ec(s||null))}),Qg=(t,e)=>zg(e,Jl("metadata"),t[3]),Yg=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Xg=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Hg(r,i));Kg(r,i);for(var f=n.length-1;f>=0;f--)l=Gg(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,ec(o)&&(r=o);return Qg(t,r),p&&Js(r,i,p),u?c^4?s:p:r},tc,Zs,ic;tc=[be(["wiki","preferences","$"])];class lr extends(ic=Ae){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(h("section",{children:[h("h3",{children:i`InPageEdit Analytics`}),h("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.`}),h("h4",{children:i`What data will be collected?`}),h("ol",{style:{listStyle:"number",paddingLeft:"1em"},children:[h("li",{children:[h("strong",{children:i`Usage data`}),":"," ",i`When and which features you use, what pages you edit, etc.`]}),h("li",{children:[h("strong",{children:i`User information`}),": ",i`Your user name and user ID.`]}),h("li",{children:[h("strong",{children:i`Site information`}),": ",i`This wiki's url and site name.`]})]}),h("p",{children:h("strong",{children:i`NO sensitive data will be collected.`})}),h("div",{style:{display:"grid",gap:"0.5rem"},children:[h("a",{href:this.analyticsDashUrl,target:"_blank",rel:"noopener noreferrer",children:h("button",{className:"btn",style:{width:"100%"},children:i`Analytics Platform`})}),h("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:h("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 St.ANALYTICS_DASH_URL}get analyticsApiBase(){return St.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 n="analytics/confirm-shown",r=await i.storage.simpleKV.get(n),s=await i.preferences.get("analytics.enabled");r||s||i.modal.notify("confirm",{title:e`Enable Analytics`,content:h("div",{children:[h("p",{children:e`Help us improve InPageEdit by sharing your usage data with us.`}),h("p",{children:e`What data will be collected?`}),h("ul",{style:{listStyle:"auto",paddingLeft:"1.5em"},children:[h("li",{children:[e`Usage data`,": ",e`When and which features you use, what pages you edit, etc.`]}),h("li",{children:[e`User information`,": ",e`Your user name and user ID.`]}),h("li",{children:[e`Site information`,": ",e`This wiki's url and site name.`]})]}),h("p",{children:h("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(n,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",Ci(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:n,by:r})=>{r==="new-added"&&this.addEvent("plugin-store","plugin-installed",`${n}@${i.name}`)}),e.on("plugin-store/plugin-uninstalled",({registry:i,id:n})=>{this.addEvent("plugin-store","plugin-uninstalled",`${n}@${i.name}`)})}addEvent(e,i,n){if(!e)return;const r={ts:Date.now(),feature:e,subtype:i,page:n};return this._usages.push(r),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),n={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},r=JSON.stringify(n),s=`${this.analyticsApiBase}/submit`;if(navigator?.sendBeacon?.(s,r))return this.logger.debug("Beacon sent successfully",n),!0;{this.logger.debug("Beacon failed, sending via XMLHttpRequest");const{promise:a,resolve:l,reject:c}=re();try{const u=new XMLHttpRequest;u.open("POST",s,!0),u.setRequestHeader("Content-Type","application/json"),u.send(r),u.onload=()=>{this.logger.debug("Beacon sent successfully via XMLHttpRequest",n),l(u.status>=200&&u.status<300)},u.onerror=()=>{c(new Error("Failed to send beacon"))}}catch(u){c(u)}return a}}stop(){this._timer!==null&&(clearInterval(this._timer),this._timer=null),this._usages.length>0&&this.sendBeacon()}}Zs=Wg(ic),lr=Xg(Zs,0,"PluginAnalytics",tc,lr),Yg(Zs,1,lr);const Jg=Object.freeze(Object.defineProperty({__proto__:null,get PluginAnalytics(){return lr}},Symbol.toStringTag,{value:"Module"}));var Zg=Object.create,eo=Object.defineProperty,em=Object.getOwnPropertyDescriptor,nc=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),rc=t=>{throw TypeError(t)},tm=(t,e,i)=>e in t?eo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,im=(t,e)=>eo(t,"name",{value:e,configurable:!0}),nm=t=>[,,,Zg(t?.[nc("metadata")]??null)],rm=["class","method","getter","setter","accessor","field","value","get","set"],sc=t=>t!==void 0&&typeof t!="function"?rc("Function expected"):t,sm=(t,e,i,n,r)=>({kind:rm[t],name:e,metadata:n,addInitializer:s=>i._?rc("Already initialized"):r.push(sc(s||null))}),om=(t,e)=>tm(e,nc("metadata"),t[3]),am=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},lm=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&em(r,i));im(r,i);for(var f=n.length-1;f>=0;f--)l=sm(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,sc(o)&&(r=o);return om(t,r),p&&eo(r,i,p),u?c^4?s:p:r},oc,to,ac;oc=[be(["wiki","wikiTitle","preferences","$"]),Ut(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 cr extends(ac=Ae){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 n=e.getAttribute("href")||"";if(!this.ctx.wikiTitle.validateHrefAttr(n))return null;const r=e.href||"",s=this.ctx.wikiTitle.parseWikiLink(r);if(!s)return null;const o={$el:e,kind:e.closest('[typeof^="mw:File"]')?"mw:File":"normal",external:e.classList.contains("external")||!!n.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 n=e.querySelectorAll("a[href]");return Array.from(n).map(r=>this.parseAnchor(r)).filter(r=>r!==null&&(!i||i(r)))}onContentReady(e){const i=()=>{if(!window.mw)return;window.mw.hook("wikipage.content").add(e);const n=window.$?.("#mw-content-text");n?.length&&e(n)};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"],n=>{e=!0,n.on("dispose",()=>{e=!1}),this.onContentReady(r=>{if(!e)return;this.scanAnchors(r.get(0),({action:o,title:a,redlink:l})=>i||!l?["edit","create"].includes(o)?!0:a?.isSpecial("edit")||a?.isSpecial("newsection")?a.getMainText().split("/").length>=2:!1:!1).forEach(o=>{const{$el:a,title:l,pageId:c,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=l?.getPrefixedDBKey()||"",p=u.get("section")?.replace(/^T-/,"")||void 0,f=u.get("oldid"),w=u.has("redlink");let x;p==="new"||l?.isSpecial("newsection")?x="new":p&&/^\d+$/.test(p)&&(x=parseInt(p,10));const S=f?parseInt(f,10):void 0,I={title:y,pageId:c||void 0,section:x,revision:S,createOnly:w},m=n.quickEdit.createQuickEditButton(I,{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=n=>["prev","next","cur"].includes(n);this.ctx.inject(["quickDiff"],n=>{e=!0,n.on("dispose",()=>{e=!1}),this.onContentReady(r=>{if(!e)return;this.scanAnchors(r.get(0),({params:o,title:a})=>!!(o.has("diff")||a?.isSpecial("diff"))).forEach(o=>{const{$el:a,title:l,params:c}=o;if(a.dataset.ipeDiffMounted)return;a.dataset.ipeDiffMounted="1";let u,d;if(l?.getNamespaceId()===-1?([,d,u]=l.getMainDBKey().split("/"),u||(u="prev")):(u=c.get("diff"),d=c.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",f=>{this.ctx.emit("in-article-links/anchor-clicked",{ctx:this.ctx,anchor:a,info:o,event:f,action:"quickDiff"})}),a.insertAdjacentElement("afterend",p)})})})}}to=nm(ac),cr=lm(to,0,"PluginInArticleLinks",oc,cr),am(to,1,cr);const cm=Object.freeze(Object.defineProperty({__proto__:null,get PluginInArticleLinks(){return cr}},Symbol.toStringTag,{value:"Module"}));function io(t){const e=Object.create(null);for(const i of t.split(","))e[i]=1;return i=>i in e}const ne={},Ii=[],$t=()=>{},lc=()=>!1,ur=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&(t.charCodeAt(2)>122||t.charCodeAt(2)<97),no=t=>t.startsWith("onUpdate:"),Oe=Object.assign,ro=(t,e)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)},um=Object.prototype.hasOwnProperty,se=(t,e)=>um.call(t,e),Q=Array.isArray,Ai=t=>dr(t)==="[object Map]",cc=t=>dr(t)==="[object Set]",Y=t=>typeof t=="function",_e=t=>typeof t=="string",Ft=t=>typeof t=="symbol",me=t=>t!==null&&typeof t=="object",uc=t=>(me(t)||Y(t))&&Y(t.then)&&Y(t.catch),dc=Object.prototype.toString,dr=t=>dc.call(t),dm=t=>dr(t).slice(8,-1),fc=t=>dr(t)==="[object Object]",so=t=>_e(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,un=io(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),fr=t=>{const e=Object.create(null);return(i=>e[i]||(e[i]=t(i)))},fm=/-\w/g,Bt=fr(t=>t.replace(fm,e=>e.slice(1).toUpperCase())),hm=/\B([A-Z])/g,Jt=fr(t=>t.replace(hm,"-$1").toLowerCase()),hc=fr(t=>t.charAt(0).toUpperCase()+t.slice(1)),oo=fr(t=>t?`on${hc(t)}`:""),Ge=(t,e)=>!Object.is(t,e),hr=(t,...e)=>{for(let i=0;i<t.length;i++)t[i](...e)},pc=(t,e,i,n=!1)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:n,value:i})},ao=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let gc;const pr=()=>gc||(gc=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function lo(t){if(Q(t)){const e={};for(let i=0;i<t.length;i++){const n=t[i],r=_e(n)?ym(n):lo(n);if(r)for(const s in r)e[s]=r[s]}return e}else if(_e(t)||me(t))return t}const pm=/;(?![^(]*\))/g,gm=/:([^]+)/,mm=/\/\*[^]*?\*\//g;function ym(t){const e={};return t.replace(mm,"").split(pm).forEach(i=>{if(i){const n=i.split(gm);n.length>1&&(e[n[0].trim()]=n[1].trim())}}),e}function gt(t){let e="";if(_e(t))e=t;else if(Q(t))for(let i=0;i<t.length;i++){const n=gt(t[i]);n&&(e+=n+" ")}else if(me(t))for(const i in t)t[i]&&(e+=i+" ");return e.trim()}const bm=io("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly");function mc(t){return!!t||t===""}const yc=t=>!!(t&&t.__v_isRef===!0),ue=t=>_e(t)?t:t==null?"":Q(t)||me(t)&&(t.toString===dc||!Y(t.toString))?yc(t)?ue(t.value):JSON.stringify(t,bc,2):String(t),bc=(t,e)=>yc(e)?bc(t,e.value):Ai(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((i,[n,r],s)=>(i[co(n,s)+" =>"]=r,i),{})}:cc(e)?{[`Set(${e.size})`]:[...e.values()].map(i=>co(i))}:Ft(e)?co(e):me(e)&&!Q(e)&&!fc(e)?String(e):e,co=(t,e="")=>{var i;return Ft(t)?`Symbol(${(i=t.description)!=null?i:e})`:t};let Qe;class vm{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.parent=Qe,!e&&Qe&&(this.index=(Qe.scopes||(Qe.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=Qe;try{return Qe=this,e()}finally{Qe=i}}}on(){++this._on===1&&(this.prevScope=Qe,Qe=this)}off(){this._on>0&&--this._on===0&&(Qe=this.prevScope,this.prevScope=void 0)}stop(e){if(this._active){this._active=!1;let i,n;for(i=0,n=this.effects.length;i<n;i++)this.effects[i].stop();for(this.effects.length=0,i=0,n=this.cleanups.length;i<n;i++)this.cleanups[i]();if(this.cleanups.length=0,this.scopes){for(i=0,n=this.scopes.length;i<n;i++)this.scopes[i].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){const r=this.parent.scopes.pop();r&&r!==this&&(this.parent.scopes[this.index]=r,r.index=this.index)}this.parent=void 0}}}function wm(){return Qe}let de;const uo=new WeakSet;class vc{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,Qe&&Qe.active&&Qe.effects.push(this)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,uo.has(this)&&(uo.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||_c(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,Ec(this),xc(this);const e=de,i=mt;de=this,mt=!0;try{return this.fn()}finally{kc(this),de=e,mt=i,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)go(e);this.deps=this.depsTail=void 0,Ec(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?uo.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){po(this)&&this.run()}get dirty(){return po(this)}}let wc=0,dn,fn;function _c(t,e=!1){if(t.flags|=8,e){t.next=fn,fn=t;return}t.next=dn,dn=t}function fo(){wc++}function ho(){if(--wc>0)return;if(fn){let e=fn;for(fn=void 0;e;){const i=e.next;e.next=void 0,e.flags&=-9,e=i}}let t;for(;dn;){let e=dn;for(dn=void 0;e;){const i=e.next;if(e.next=void 0,e.flags&=-9,e.flags&1)try{e.trigger()}catch(n){t||(t=n)}e=i}}if(t)throw t}function xc(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function kc(t){let e,i=t.depsTail,n=i;for(;n;){const r=n.prevDep;n.version===-1?(n===i&&(i=r),go(n),_m(n)):e=n,n.dep.activeLink=n.prevActiveLink,n.prevActiveLink=void 0,n=r}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&&(Sc(e.dep.computed)||e.dep.version!==e.version))return!0;return!!t._dirty}function Sc(t){if(t.flags&4&&!(t.flags&16)||(t.flags&=-17,t.globalVersion===hn)||(t.globalVersion=hn,!t.isSSR&&t.flags&128&&(!t.deps&&!t._dirty||!po(t))))return;t.flags|=2;const e=t.dep,i=de,n=mt;de=t,mt=!0;try{xc(t);const r=t.fn(t._value);(e.version===0||Ge(r,t._value))&&(t.flags|=128,t._value=r,e.version++)}catch(r){throw e.version++,r}finally{de=i,mt=n,kc(t),t.flags&=-3}}function go(t,e=!1){const{dep:i,prevSub:n,nextSub:r}=t;if(n&&(n.nextSub=r,t.prevSub=void 0),r&&(r.prevSub=n,t.nextSub=void 0),i.subs===t&&(i.subs=n,!n&&i.computed)){i.computed.flags&=-5;for(let s=i.computed.deps;s;s=s.nextDep)go(s,!0)}!e&&!--i.sc&&i.map&&i.map.delete(i.key)}function _m(t){const{prevDep:e,nextDep:i}=t;e&&(e.nextDep=i,t.prevDep=void 0),i&&(i.prevDep=e,t.nextDep=void 0)}let mt=!0;const $c=[];function Et(){$c.push(mt),mt=!1}function Pt(){const t=$c.pop();mt=t===void 0?!0:t}function Ec(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const i=de;de=void 0;try{e()}finally{de=i}}}let hn=0;class xm{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 gr{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(!de||!mt||de===this.computed)return;let i=this.activeLink;if(i===void 0||i.sub!==de)i=this.activeLink=new xm(de,this),de.deps?(i.prevDep=de.depsTail,de.depsTail.nextDep=i,de.depsTail=i):de.deps=de.depsTail=i,Pc(i);else if(i.version===-1&&(i.version=this.version,i.nextDep)){const n=i.nextDep;n.prevDep=i.prevDep,i.prevDep&&(i.prevDep.nextDep=n),i.prevDep=de.depsTail,i.nextDep=void 0,de.depsTail.nextDep=i,de.depsTail=i,de.deps===i&&(de.deps=n)}return i}trigger(e){this.version++,hn++,this.notify(e)}notify(e){fo();try{for(let i=this.subs;i;i=i.prevSub)i.sub.notify()&&i.sub.dep.notify()}finally{ho()}}}function Pc(t){if(t.dep.sc++,t.sub.flags&4){const e=t.dep.computed;if(e&&!t.dep.subs){e.flags|=20;for(let n=e.deps;n;n=n.nextDep)Pc(n)}const i=t.dep.subs;i!==t&&(t.prevSub=i,i&&(i.nextSub=t)),t.dep.subs=t}}const mo=new WeakMap,di=Symbol(""),yo=Symbol(""),pn=Symbol("");function Me(t,e,i){if(mt&&de){let n=mo.get(t);n||mo.set(t,n=new Map);let r=n.get(i);r||(n.set(i,r=new gr),r.map=n,r.key=i),r.track()}}function qt(t,e,i,n,r,s){const o=mo.get(t);if(!o){hn++;return}const a=l=>{l&&l.trigger()};if(fo(),e==="clear")o.forEach(a);else{const l=Q(t),c=l&&so(i);if(l&&i==="length"){const u=Number(n);o.forEach((d,y)=>{(y==="length"||y===pn||!Ft(y)&&y>=u)&&a(d)})}else switch((i!==void 0||o.has(void 0))&&a(o.get(i)),c&&a(o.get(pn)),e){case"add":l?c&&a(o.get("length")):(a(o.get(di)),Ai(t)&&a(o.get(yo)));break;case"delete":l||(a(o.get(di)),Ai(t)&&a(o.get(yo)));break;case"set":Ai(t)&&a(o.get(di));break}}ho()}function Oi(t){const e=ie(t);return e===t?e:(Me(e,"iterate",pn),lt(t)?e:e.map(Te))}function mr(t){return Me(t=ie(t),"iterate",pn),t}const km={__proto__:null,[Symbol.iterator](){return bo(this,Symbol.iterator,Te)},concat(...t){return Oi(this).concat(...t.map(e=>Q(e)?Oi(e):e))},entries(){return bo(this,"entries",t=>(t[1]=Te(t[1]),t))},every(t,e){return Ht(this,"every",t,e,void 0,arguments)},filter(t,e){return Ht(this,"filter",t,e,i=>i.map(Te),arguments)},find(t,e){return Ht(this,"find",t,e,Te,arguments)},findIndex(t,e){return Ht(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return Ht(this,"findLast",t,e,Te,arguments)},findLastIndex(t,e){return Ht(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return Ht(this,"forEach",t,e,void 0,arguments)},includes(...t){return vo(this,"includes",t)},indexOf(...t){return vo(this,"indexOf",t)},join(t){return Oi(this).join(t)},lastIndexOf(...t){return vo(this,"lastIndexOf",t)},map(t,e){return Ht(this,"map",t,e,void 0,arguments)},pop(){return gn(this,"pop")},push(...t){return gn(this,"push",t)},reduce(t,...e){return Cc(this,"reduce",t,e)},reduceRight(t,...e){return Cc(this,"reduceRight",t,e)},shift(){return gn(this,"shift")},some(t,e){return Ht(this,"some",t,e,void 0,arguments)},splice(...t){return gn(this,"splice",t)},toReversed(){return Oi(this).toReversed()},toSorted(t){return Oi(this).toSorted(t)},toSpliced(...t){return Oi(this).toSpliced(...t)},unshift(...t){return gn(this,"unshift",t)},values(){return bo(this,"values",Te)}};function bo(t,e,i){const n=mr(t),r=n[e]();return n!==t&&!lt(t)&&(r._next=r.next,r.next=()=>{const s=r._next();return s.done||(s.value=i(s.value)),s}),r}const Sm=Array.prototype;function Ht(t,e,i,n,r,s){const o=mr(t),a=o!==t&&!lt(t),l=o[e];if(l!==Sm[e]){const d=l.apply(t,s);return a?Te(d):d}let c=i;o!==t&&(a?c=function(d,y){return i.call(this,Te(d),y,t)}:i.length>2&&(c=function(d,y){return i.call(this,d,y,t)}));const u=l.call(o,c,n);return a&&r?r(u):u}function Cc(t,e,i,n){const r=mr(t);let s=i;return r!==t&&(lt(t)?i.length>3&&(s=function(o,a,l){return i.call(this,o,a,l,t)}):s=function(o,a,l){return i.call(this,o,Te(a),l,t)}),r[e](s,...n)}function vo(t,e,i){const n=ie(t);Me(n,"iterate",pn);const r=n[e](...i);return(r===-1||r===!1)&&ko(i[0])?(i[0]=ie(i[0]),n[e](...i)):r}function gn(t,e,i=[]){Et(),fo();const n=ie(t)[e].apply(t,i);return ho(),Pt(),n}const $m=io("__proto__,__v_isRef,__isVue"),Rc=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(Ft));function Em(t){Ft(t)||(t=String(t));const e=ie(this);return Me(e,"has",t),e.hasOwnProperty(t)}class Ic{constructor(e=!1,i=!1){this._isReadonly=e,this._isShallow=i}get(e,i,n){if(i==="__v_skip")return e.__v_skip;const r=this._isReadonly,s=this._isShallow;if(i==="__v_isReactive")return!r;if(i==="__v_isReadonly")return r;if(i==="__v_isShallow")return s;if(i==="__v_raw")return n===(r?s?Mc:Nc:s?Lc:Tc).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;const o=Q(e);if(!r){let l;if(o&&(l=km[i]))return l;if(i==="hasOwnProperty")return Em}const a=Reflect.get(e,i,Ie(e)?e:n);if((Ft(i)?Rc.has(i):$m(i))||(r||Me(e,"get",i),s))return a;if(Ie(a)){const l=o&&so(i)?a:a.value;return r&&me(l)?xo(l):l}return me(a)?r?xo(a):_o(a):a}}class Ac extends Ic{constructor(e=!1){super(!1,e)}set(e,i,n,r){let s=e[i];if(!this._isShallow){const l=Zt(s);if(!lt(n)&&!Zt(n)&&(s=ie(s),n=ie(n)),!Q(e)&&Ie(s)&&!Ie(n))return l||(s.value=n),!0}const o=Q(e)&&so(i)?Number(i)<e.length:se(e,i),a=Reflect.set(e,i,n,Ie(e)?e:r);return e===ie(r)&&(o?Ge(n,s)&&qt(e,"set",i,n):qt(e,"add",i,n)),a}deleteProperty(e,i){const n=se(e,i);e[i];const r=Reflect.deleteProperty(e,i);return r&&n&&qt(e,"delete",i,void 0),r}has(e,i){const n=Reflect.has(e,i);return(!Ft(i)||!Rc.has(i))&&Me(e,"has",i),n}ownKeys(e){return Me(e,"iterate",Q(e)?"length":di),Reflect.ownKeys(e)}}class Oc extends Ic{constructor(e=!1){super(!0,e)}set(e,i){return!0}deleteProperty(e,i){return!0}}const Pm=new Ac,Cm=new Oc,Rm=new Ac(!0),Im=new Oc(!0),wo=t=>t,yr=t=>Reflect.getPrototypeOf(t);function Am(t,e,i){return function(...n){const r=this.__v_raw,s=ie(r),o=Ai(s),a=t==="entries"||t===Symbol.iterator&&o,l=t==="keys"&&o,c=r[t](...n),u=i?wo:e?_r:Te;return!e&&Me(s,"iterate",l?yo:di),{next(){const{value:d,done:y}=c.next();return y?{value:d,done:y}:{value:a?[u(d[0]),u(d[1])]:u(d),done:y}},[Symbol.iterator](){return this}}}}function br(t){return function(...e){return t==="delete"?!1:t==="clear"?void 0:this}}function Om(t,e){const i={get(r){const s=this.__v_raw,o=ie(s),a=ie(r);t||(Ge(r,a)&&Me(o,"get",r),Me(o,"get",a));const{has:l}=yr(o),c=e?wo:t?_r:Te;if(l.call(o,r))return c(s.get(r));if(l.call(o,a))return c(s.get(a));s!==o&&s.get(r)},get size(){const r=this.__v_raw;return!t&&Me(ie(r),"iterate",di),r.size},has(r){const s=this.__v_raw,o=ie(s),a=ie(r);return t||(Ge(r,a)&&Me(o,"has",r),Me(o,"has",a)),r===a?s.has(r):s.has(r)||s.has(a)},forEach(r,s){const o=this,a=o.__v_raw,l=ie(a),c=e?wo:t?_r:Te;return!t&&Me(l,"iterate",di),a.forEach((u,d)=>r.call(s,c(u),c(d),o))}};return Oe(i,t?{add:br("add"),set:br("set"),delete:br("delete"),clear:br("clear")}:{add(r){!e&&!lt(r)&&!Zt(r)&&(r=ie(r));const s=ie(this);return yr(s).has.call(s,r)||(s.add(r),qt(s,"add",r,r)),this},set(r,s){!e&&!lt(s)&&!Zt(s)&&(s=ie(s));const o=ie(this),{has:a,get:l}=yr(o);let c=a.call(o,r);c||(r=ie(r),c=a.call(o,r));const u=l.call(o,r);return o.set(r,s),c?Ge(s,u)&&qt(o,"set",r,s):qt(o,"add",r,s),this},delete(r){const s=ie(this),{has:o,get:a}=yr(s);let l=o.call(s,r);l||(r=ie(r),l=o.call(s,r)),a&&a.call(s,r);const c=s.delete(r);return l&&qt(s,"delete",r,void 0),c},clear(){const r=ie(this),s=r.size!==0,o=r.clear();return s&&qt(r,"clear",void 0,void 0),o}}),["keys","values","entries",Symbol.iterator].forEach(r=>{i[r]=Am(r,t,e)}),i}function vr(t,e){const i=Om(t,e);return(n,r,s)=>r==="__v_isReactive"?!t:r==="__v_isReadonly"?t:r==="__v_raw"?n:Reflect.get(se(i,r)&&r in n?i:n,r,s)}const Tm={get:vr(!1,!1)},Lm={get:vr(!1,!0)},Nm={get:vr(!0,!1)},Mm={get:vr(!0,!0)},Tc=new WeakMap,Lc=new WeakMap,Nc=new WeakMap,Mc=new WeakMap;function Dm(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function jm(t){return t.__v_skip||!Object.isExtensible(t)?0:Dm(dm(t))}function _o(t){return Zt(t)?t:wr(t,!1,Pm,Tm,Tc)}function Um(t){return wr(t,!1,Rm,Lm,Lc)}function xo(t){return wr(t,!0,Cm,Nm,Nc)}function v0(t){return wr(t,!0,Im,Mm,Mc)}function wr(t,e,i,n,r){if(!me(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const s=jm(t);if(s===0)return t;const o=r.get(t);if(o)return o;const a=new Proxy(t,s===2?n:i);return r.set(t,a),a}function Ti(t){return Zt(t)?Ti(t.__v_raw):!!(t&&t.__v_isReactive)}function Zt(t){return!!(t&&t.__v_isReadonly)}function lt(t){return!!(t&&t.__v_isShallow)}function ko(t){return t?!!t.__v_raw:!1}function ie(t){const e=t&&t.__v_raw;return e?ie(e):t}function Fm(t){return!se(t,"__v_skip")&&Object.isExtensible(t)&&pc(t,"__v_skip",!0),t}const Te=t=>me(t)?_o(t):t,_r=t=>me(t)?xo(t):t;function Ie(t){return t?t.__v_isRef===!0:!1}function Fe(t){return jc(t,!1)}function Dc(t){return jc(t,!0)}function jc(t,e){return Ie(t)?t:new Bm(t,e)}class Bm{constructor(e,i){this.dep=new gr,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=i?e:ie(e),this._value=i?e:Te(e),this.__v_isShallow=i}get value(){return this.dep.track(),this._value}set value(e){const i=this._rawValue,n=this.__v_isShallow||lt(e)||Zt(e);e=n?e:ie(e),Ge(e,i)&&(this._rawValue=e,this._value=n?e:Te(e),this.dep.trigger())}}function Se(t){return Ie(t)?t.value:t}const qm={get:(t,e,i)=>e==="__v_raw"?t:Se(Reflect.get(t,e,i)),set:(t,e,i,n)=>{const r=t[e];return Ie(r)&&!Ie(i)?(r.value=i,!0):Reflect.set(t,e,i,n)}};function Uc(t){return Ti(t)?t:new Proxy(t,qm)}class Hm{constructor(e){this.__v_isRef=!0,this._value=void 0;const i=this.dep=new gr,{get:n,set:r}=e(i.track.bind(i),i.trigger.bind(i));this._get=n,this._set=r}get value(){return this._value=this._get()}set value(e){this._set(e)}}function zm(t){return new Hm(t)}class Km{constructor(e,i,n){this.fn=e,this.setter=i,this._value=void 0,this.dep=new gr(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=hn-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!i,this.isSSR=n}notify(){if(this.flags|=16,!(this.flags&8)&&de!==this)return _c(this,!0),!0}get value(){const e=this.dep.track();return Sc(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}}function Wm(t,e,i=!1){let n,r;return Y(t)?n=t:(n=t.get,r=t.set),new Km(n,r,i)}const xr={},kr=new WeakMap;let fi;function Vm(t,e=!1,i=fi){if(i){let n=kr.get(i);n||kr.set(i,n=[]),n.push(t)}}function Gm(t,e,i=ne){const{immediate:n,deep:r,once:s,scheduler:o,augmentJob:a,call:l}=i,c=g=>r?g:lt(g)||r===!1||r===0?zt(g,1):zt(g);let u,d,y,p,f=!1,w=!1;if(Ie(t)?(d=()=>t.value,f=lt(t)):Ti(t)?(d=()=>c(t),f=!0):Q(t)?(w=!0,f=t.some(g=>Ti(g)||lt(g)),d=()=>t.map(g=>{if(Ie(g))return g.value;if(Ti(g))return c(g);if(Y(g))return l?l(g,2):g()})):Y(t)?e?d=l?()=>l(t,2):t:d=()=>{if(y){Et();try{y()}finally{Pt()}}const g=fi;fi=u;try{return l?l(t,3,[p]):t(p)}finally{fi=g}}:d=$t,e&&r){const g=d,b=r===!0?1/0:r;d=()=>zt(g(),b)}const x=wm(),S=()=>{u.stop(),x&&x.active&&ro(x.effects,u)};if(s&&e){const g=e;e=(...b)=>{g(...b),S()}}let I=w?new Array(t.length).fill(xr):xr;const m=g=>{if(!(!(u.flags&1)||!u.dirty&&!g))if(e){const b=u.run();if(r||f||(w?b.some((k,P)=>Ge(k,I[P])):Ge(b,I))){y&&y();const k=fi;fi=u;try{const P=[b,I===xr?void 0:w&&I[0]===xr?[]:I,p];I=b,l?l(e,3,P):e(...P)}finally{fi=k}}}else u.run()};return a&&a(m),u=new vc(d),u.scheduler=o?()=>o(m,!1):m,p=g=>Vm(g,!1,u),y=u.onStop=()=>{const g=kr.get(u);if(g){if(l)l(g,4);else for(const b of g)b();kr.delete(u)}},e?n?m(!0):I=u.run():o?o(m.bind(null,!0),!0):u.run(),S.pause=u.pause.bind(u),S.resume=u.resume.bind(u),S.stop=S,S}function zt(t,e=1/0,i){if(e<=0||!me(t)||t.__v_skip||(i=i||new Map,(i.get(t)||0)>=e))return t;if(i.set(t,e),e--,Ie(t))zt(t.value,e,i);else if(Q(t))for(let n=0;n<t.length;n++)zt(t[n],e,i);else if(cc(t)||Ai(t))t.forEach(n=>{zt(n,e,i)});else if(fc(t)){for(const n in t)zt(t[n],e,i);for(const n of Object.getOwnPropertySymbols(t))Object.prototype.propertyIsEnumerable.call(t,n)&&zt(t[n],e,i)}return t}const mn=[];let So=!1;function w0(t,...e){if(So)return;So=!0,Et();const i=mn.length?mn[mn.length-1].component:null,n=i&&i.appContext.config.warnHandler,r=Qm();if(n)Li(n,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,r.map(({vnode:s})=>`at <${Nu(i,s.type)}>`).join(`
20
+ - Documentation: ${Lt.HOME_URL}
21
+ - Bug Reports: ${Lt.GITHUB_URL}`)}function dc(){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 om(t,e){const i=Symbol.for(t);return window[i]?!1:(window[i]=!0,e(),!0)}var am=Object.create,uo=Object.defineProperty,lm=Object.getOwnPropertyDescriptor,fc=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),hc=t=>{throw TypeError(t)},cm=(t,e,i)=>e in t?uo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,um=(t,e)=>uo(t,"name",{value:e,configurable:!0}),dm=t=>[,,,am(t?.[fc("metadata")]??null)],fm=["class","method","getter","setter","accessor","field","value","get","set"],pc=t=>t!==void 0&&typeof t!="function"?hc("Function expected"):t,hm=(t,e,i,n,r)=>({kind:fm[t],name:e,metadata:n,addInitializer:s=>i._?hc("Already initialized"):r.push(pc(s||null))}),pm=(t,e)=>cm(e,fc("metadata"),t[3]),gm=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},mm=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&lm(r,i));um(r,i);for(var h=n.length-1;h>=0;h--)c=hm(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,pc(o)&&(r=o);return pm(t,r),p&&uo(r,i,p),u?l^4?s:p:r},gc,fo,mc;gc=[xe(["wiki","preferences","$"])];class vr extends(mc=je){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",I.object({"analytics._intro":I.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":I.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 n="analytics/confirm-shown",r=await i.storage.simpleKV.get(n),s=await i.preferences.get("analytics.enabled");r||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(n,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",ji(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:n,by:r})=>{r==="new-added"&&this.addEvent("plugin-store","plugin-installed",`${n}@${i.name}`)}),e.on("plugin-store/plugin-uninstalled",({registry:i,id:n})=>{this.addEvent("plugin-store","plugin-uninstalled",`${n}@${i.name}`)})}addEvent(e,i,n){if(!e)return;const r={ts:Date.now(),feature:e,subtype:i,page:n};return this._usages.push(r),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),n={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},r=JSON.stringify(n),s=`${this.analyticsApiBase}/submit`;if(navigator?.sendBeacon?.(s,r))return this.logger.debug("Beacon sent successfully",n),!0;{this.logger.debug("Beacon failed, sending via XMLHttpRequest");const{promise:a,resolve:c,reject:l}=wn();try{const u=new XMLHttpRequest;u.open("POST",s,!0),u.setRequestHeader("Content-Type","application/json"),u.send(r),u.onload=()=>{this.logger.debug("Beacon sent successfully via XMLHttpRequest",n),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()}}fo=dm(mc),vr=mm(fo,0,"PluginAnalytics",gc,vr),gm(fo,1,vr);const ym=Object.freeze(Object.defineProperty({__proto__:null,get PluginAnalytics(){return vr}},Symbol.toStringTag,{value:"Module"}));var bm=Object.create,ho=Object.defineProperty,vm=Object.getOwnPropertyDescriptor,yc=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),bc=t=>{throw TypeError(t)},wm=(t,e,i)=>e in t?ho(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,_m=(t,e)=>ho(t,"name",{value:e,configurable:!0}),xm=t=>[,,,bm(t?.[yc("metadata")]??null)],km=["class","method","getter","setter","accessor","field","value","get","set"],vc=t=>t!==void 0&&typeof t!="function"?bc("Function expected"):t,Sm=(t,e,i,n,r)=>({kind:km[t],name:e,metadata:n,addInitializer:s=>i._?bc("Already initialized"):r.push(vc(s||null))}),$m=(t,e)=>wm(e,yc("metadata"),t[3]),Em=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Pm=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&vm(r,i));_m(r,i);for(var h=n.length-1;h>=0;h--)c=Sm(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,vc(o)&&(r=o);return $m(t,r),p&&ho(r,i,p),u?l^4?s:p:r},wc,po,_c;wc=[xe(["wiki","wikiTitle","preferences","$"]),Tt(I.object({"inArticleLinks.enable":I.boolean().description("Whether to enable in-article links").default(!0),"inArticleLinks.quickDiff.enable":I.boolean().description("Whether to enable in-article links for quick diff").default(!0),"inArticleLinks.quickEdit.enable":I.boolean().description("Whether to enable in-article links for quick edit").default(!0),"inArticleLinks.quickEdit.redlinks":I.boolean().description("Whether to show quick edit button for redlinks").default(!0)}).description("In-article links preferences").extra("category","in-article-links"))];class wr extends(_c=je){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 n=e.getAttribute("href")||"";if(!this.ctx.wikiTitle.validateHrefAttr(n))return null;const r=e.href||"",s=this.ctx.wikiTitle.parseWikiLink(r);if(!s)return null;const o={$el:e,kind:e.closest('[typeof^="mw:File"]')?"mw:File":"normal",external:e.classList.contains("external")||!!n.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 n=e.querySelectorAll("a[href]");return Array.from(n).map(r=>this.parseAnchor(r)).filter(r=>r!==null&&(!i||i(r)))}onContentReady(e){const i=()=>{if(!window.mw)return;window.mw.hook("wikipage.content").add(e);const n=window.$?.("#mw-content-text");n?.length&&e(n)};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"],n=>{e=!0,n.on("dispose",()=>{e=!1}),this.onContentReady(r=>{if(!e||!r?.length)return;this.scanAnchors(r.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 m=c?.getPrefixedDBKey()||"",p=u.get("section")?.replace(/^T-/,"")||void 0,h=u.get("oldid"),x=u.has("redlink");let k;p==="new"||c?.isSpecial("newsection")?k="new":p&&/^\d+$/.test(p)&&(k=parseInt(p,10));const E=h?parseInt(h,10):void 0,y={title:m,pageId:l||void 0,section:k,revision:E,createOnly:x},b=n.quickEdit.createQuickEditButton(y,{label:""});b.classList.add(this.config.linkClassName),b.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",b)})})})}handleQuickDiff(){let e=!1;const i=n=>["prev","next","cur"].includes(n);this.ctx.inject(["quickDiff"],n=>{e=!0,n.on("dispose",()=>{e=!1}),this.onContentReady(r=>{if(!e||!r?.length)return;this.scanAnchors(r.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 m={};i(u)?(m.fromrev=parseInt(d),m.torelative=u):(m.fromrev=parseInt(d),m.torev=parseInt(u));const p=this.ctx.quickDiff.createQuickDiffButton(m,{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)})})})}}po=xm(_c),wr=Pm(po,0,"PluginInArticleLinks",wc,wr),Em(po,1,wr);const Cm=Object.freeze(Object.defineProperty({__proto__:null,get PluginInArticleLinks(){return wr}},Symbol.toStringTag,{value:"Module"}));function go(t){const e=Object.create(null);for(const i of t.split(","))e[i]=1;return i=>i in e}const le={},Fi=[],Nt=()=>{},xc=()=>!1,_r=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&(t.charCodeAt(2)>122||t.charCodeAt(2)<97),mo=t=>t.startsWith("onUpdate:"),Ue=Object.assign,yo=(t,e)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)},Im=Object.prototype.hasOwnProperty,ce=(t,e)=>Im.call(t,e),J=Array.isArray,Bi=t=>xr(t)==="[object Map]",kc=t=>xr(t)==="[object Set]",Z=t=>typeof t=="function",Ie=t=>typeof t=="string",Gt=t=>typeof t=="symbol",ke=t=>t!==null&&typeof t=="object",Sc=t=>(ke(t)||Z(t))&&Z(t.then)&&Z(t.catch),$c=Object.prototype.toString,xr=t=>$c.call(t),Rm=t=>xr(t).slice(8,-1),Ec=t=>xr(t)==="[object Object]",bo=t=>Ie(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,_n=go(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),kr=t=>{const e=Object.create(null);return(i=>e[i]||(e[i]=t(i)))},Am=/-\w/g,Qt=kr(t=>t.replace(Am,e=>e.slice(1).toUpperCase())),Tm=/\B([A-Z])/g,li=kr(t=>t.replace(Tm,"-$1").toLowerCase()),Pc=kr(t=>t.charAt(0).toUpperCase()+t.slice(1)),vo=kr(t=>t?`on${Pc(t)}`:""),it=(t,e)=>!Object.is(t,e),Sr=(t,...e)=>{for(let i=0;i<t.length;i++)t[i](...e)},Cc=(t,e,i,n=!1)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:n,value:i})},wo=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let Ic;const $r=()=>Ic||(Ic=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function _o(t){if(J(t)){const e={};for(let i=0;i<t.length;i++){const n=t[i],r=Ie(n)?Mm(n):_o(n);if(r)for(const s in r)e[s]=r[s]}return e}else if(Ie(t)||ke(t))return t}const Om=/;(?![^(]*\))/g,Lm=/:([^]+)/,Nm=/\/\*[^]*?\*\//g;function Mm(t){const e={};return t.replace(Nm,"").split(Om).forEach(i=>{if(i){const n=i.split(Lm);n.length>1&&(e[n[0].trim()]=n[1].trim())}}),e}function _t(t){let e="";if(Ie(t))e=t;else if(J(t))for(let i=0;i<t.length;i++){const n=_t(t[i]);n&&(e+=n+" ")}else if(ke(t))for(const i in t)t[i]&&(e+=i+" ");return e.trim()}const Dm=go("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly");function Rc(t){return!!t||t===""}const Ac=t=>!!(t&&t.__v_isRef===!0),ye=t=>Ie(t)?t:t==null?"":J(t)||ke(t)&&(t.toString===$c||!Z(t.toString))?Ac(t)?ye(t.value):JSON.stringify(t,Tc,2):String(t),Tc=(t,e)=>Ac(e)?Tc(t,e.value):Bi(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((i,[n,r],s)=>(i[xo(n,s)+" =>"]=r,i),{})}:kc(e)?{[`Set(${e.size})`]:[...e.values()].map(i=>xo(i))}:Gt(e)?xo(e):ke(e)&&!J(e)&&!Ec(e)?String(e):e,xo=(t,e="")=>{var i;return Gt(t)?`Symbol(${(i=t.description)!=null?i:e})`:t};let nt;class jm{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.parent=nt,!e&&nt&&(this.index=(nt.scopes||(nt.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=nt;try{return nt=this,e()}finally{nt=i}}}on(){++this._on===1&&(this.prevScope=nt,nt=this)}off(){this._on>0&&--this._on===0&&(nt=this.prevScope,this.prevScope=void 0)}stop(e){if(this._active){this._active=!1;let i,n;for(i=0,n=this.effects.length;i<n;i++)this.effects[i].stop();for(this.effects.length=0,i=0,n=this.cleanups.length;i<n;i++)this.cleanups[i]();if(this.cleanups.length=0,this.scopes){for(i=0,n=this.scopes.length;i<n;i++)this.scopes[i].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){const r=this.parent.scopes.pop();r&&r!==this&&(this.parent.scopes[this.index]=r,r.index=this.index)}this.parent=void 0}}}function Um(){return nt}let be;const ko=new WeakSet;class Oc{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,nt&&nt.active&&nt.effects.push(this)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,ko.has(this)&&(ko.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||Nc(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,Fc(this),Mc(this);const e=be,i=xt;be=this,xt=!0;try{return this.fn()}finally{Dc(this),be=e,xt=i,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)Po(e);this.deps=this.depsTail=void 0,Fc(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?ko.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){Eo(this)&&this.run()}get dirty(){return Eo(this)}}let Lc=0,xn,kn;function Nc(t,e=!1){if(t.flags|=8,e){t.next=kn,kn=t;return}t.next=xn,xn=t}function So(){Lc++}function $o(){if(--Lc>0)return;if(kn){let e=kn;for(kn=void 0;e;){const i=e.next;e.next=void 0,e.flags&=-9,e=i}}let t;for(;xn;){let e=xn;for(xn=void 0;e;){const i=e.next;if(e.next=void 0,e.flags&=-9,e.flags&1)try{e.trigger()}catch(n){t||(t=n)}e=i}}if(t)throw t}function Mc(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function Dc(t){let e,i=t.depsTail,n=i;for(;n;){const r=n.prevDep;n.version===-1?(n===i&&(i=r),Po(n),Fm(n)):e=n,n.dep.activeLink=n.prevActiveLink,n.prevActiveLink=void 0,n=r}t.deps=e,t.depsTail=i}function Eo(t){for(let e=t.deps;e;e=e.nextDep)if(e.dep.version!==e.version||e.dep.computed&&(jc(e.dep.computed)||e.dep.version!==e.version))return!0;return!!t._dirty}function jc(t){if(t.flags&4&&!(t.flags&16)||(t.flags&=-17,t.globalVersion===Sn)||(t.globalVersion=Sn,!t.isSSR&&t.flags&128&&(!t.deps&&!t._dirty||!Eo(t))))return;t.flags|=2;const e=t.dep,i=be,n=xt;be=t,xt=!0;try{Mc(t);const r=t.fn(t._value);(e.version===0||it(r,t._value))&&(t.flags|=128,t._value=r,e.version++)}catch(r){throw e.version++,r}finally{be=i,xt=n,Dc(t),t.flags&=-3}}function Po(t,e=!1){const{dep:i,prevSub:n,nextSub:r}=t;if(n&&(n.nextSub=r,t.prevSub=void 0),r&&(r.prevSub=n,t.nextSub=void 0),i.subs===t&&(i.subs=n,!n&&i.computed)){i.computed.flags&=-5;for(let s=i.computed.deps;s;s=s.nextDep)Po(s,!0)}!e&&!--i.sc&&i.map&&i.map.delete(i.key)}function Fm(t){const{prevDep:e,nextDep:i}=t;e&&(e.nextDep=i,t.prevDep=void 0),i&&(i.prevDep=e,t.nextDep=void 0)}let xt=!0;const Uc=[];function Mt(){Uc.push(xt),xt=!1}function Dt(){const t=Uc.pop();xt=t===void 0?!0:t}function Fc(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const i=be;be=void 0;try{e()}finally{be=i}}}let Sn=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 Er{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||!xt||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,Bc(i);else if(i.version===-1&&(i.version=this.version,i.nextDep)){const n=i.nextDep;n.prevDep=i.prevDep,i.prevDep&&(i.prevDep.nextDep=n),i.prevDep=be.depsTail,i.nextDep=void 0,be.depsTail.nextDep=i,be.depsTail=i,be.deps===i&&(be.deps=n)}return i}trigger(e){this.version++,Sn++,this.notify(e)}notify(e){So();try{for(let i=this.subs;i;i=i.prevSub)i.sub.notify()&&i.sub.dep.notify()}finally{$o()}}}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 n=e.deps;n;n=n.nextDep)Bc(n)}const i=t.dep.subs;i!==t&&(t.prevSub=i,i&&(i.nextSub=t)),t.dep.subs=t}}const Co=new WeakMap,_i=Symbol(""),Io=Symbol(""),$n=Symbol("");function ze(t,e,i){if(xt&&be){let n=Co.get(t);n||Co.set(t,n=new Map);let r=n.get(i);r||(n.set(i,r=new Er),r.map=n,r.key=i),r.track()}}function Yt(t,e,i,n,r,s){const o=Co.get(t);if(!o){Sn++;return}const a=c=>{c&&c.trigger()};if(So(),e==="clear")o.forEach(a);else{const c=J(t),l=c&&bo(i);if(c&&i==="length"){const u=Number(n);o.forEach((d,m)=>{(m==="length"||m===$n||!Gt(m)&&m>=u)&&a(d)})}else switch((i!==void 0||o.has(void 0))&&a(o.get(i)),l&&a(o.get($n)),e){case"add":c?l&&a(o.get("length")):(a(o.get(_i)),Bi(t)&&a(o.get(Io)));break;case"delete":c||(a(o.get(_i)),Bi(t)&&a(o.get(Io)));break;case"set":Bi(t)&&a(o.get(_i));break}}$o()}function qi(t){const e=oe(t);return e===t?e:(ze(e,"iterate",$n),mt(t)?e:e.map(kt))}function Pr(t){return ze(t=oe(t),"iterate",$n),t}function ci(t,e){return Jt(t)?xi(t)?zi(kt(e)):zi(e):kt(e)}const qm={__proto__:null,[Symbol.iterator](){return Ro(this,Symbol.iterator,t=>ci(this,t))},concat(...t){return qi(this).concat(...t.map(e=>J(e)?qi(e):e))},entries(){return Ro(this,"entries",t=>(t[1]=ci(this,t[1]),t))},every(t,e){return Xt(this,"every",t,e,void 0,arguments)},filter(t,e){return Xt(this,"filter",t,e,i=>i.map(n=>ci(this,n)),arguments)},find(t,e){return Xt(this,"find",t,e,i=>ci(this,i),arguments)},findIndex(t,e){return Xt(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return Xt(this,"findLast",t,e,i=>ci(this,i),arguments)},findLastIndex(t,e){return Xt(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return Xt(this,"forEach",t,e,void 0,arguments)},includes(...t){return Ao(this,"includes",t)},indexOf(...t){return Ao(this,"indexOf",t)},join(t){return qi(this).join(t)},lastIndexOf(...t){return Ao(this,"lastIndexOf",t)},map(t,e){return Xt(this,"map",t,e,void 0,arguments)},pop(){return En(this,"pop")},push(...t){return En(this,"push",t)},reduce(t,...e){return qc(this,"reduce",t,e)},reduceRight(t,...e){return qc(this,"reduceRight",t,e)},shift(){return En(this,"shift")},some(t,e){return Xt(this,"some",t,e,void 0,arguments)},splice(...t){return En(this,"splice",t)},toReversed(){return qi(this).toReversed()},toSorted(t){return qi(this).toSorted(t)},toSpliced(...t){return qi(this).toSpliced(...t)},unshift(...t){return En(this,"unshift",t)},values(){return Ro(this,"values",t=>ci(this,t))}};function Ro(t,e,i){const n=Pr(t),r=n[e]();return n!==t&&!mt(t)&&(r._next=r.next,r.next=()=>{const s=r._next();return s.done||(s.value=i(s.value)),s}),r}const zm=Array.prototype;function Xt(t,e,i,n,r,s){const o=Pr(t),a=o!==t&&!mt(t),c=o[e];if(c!==zm[e]){const d=c.apply(t,s);return a?kt(d):d}let l=i;o!==t&&(a?l=function(d,m){return i.call(this,ci(t,d),m,t)}:i.length>2&&(l=function(d,m){return i.call(this,d,m,t)}));const u=c.call(o,l,n);return a&&r?r(u):u}function qc(t,e,i,n){const r=Pr(t);let s=i;return r!==t&&(mt(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,ci(t,a),c,t)}),r[e](s,...n)}function Ao(t,e,i){const n=oe(t);ze(n,"iterate",$n);const r=n[e](...i);return(r===-1||r===!1)&&No(i[0])?(i[0]=oe(i[0]),n[e](...i)):r}function En(t,e,i=[]){Mt(),So();const n=oe(t)[e].apply(t,i);return $o(),Dt(),n}const Hm=go("__proto__,__v_isRef,__isVue"),zc=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(Gt));function Wm(t){Gt(t)||(t=String(t));const e=oe(this);return ze(e,"has",t),e.hasOwnProperty(t)}class Hc{constructor(e=!1,i=!1){this._isReadonly=e,this._isShallow=i}get(e,i,n){if(i==="__v_skip")return e.__v_skip;const r=this._isReadonly,s=this._isShallow;if(i==="__v_isReactive")return!r;if(i==="__v_isReadonly")return r;if(i==="__v_isShallow")return s;if(i==="__v_raw")return n===(r?s?Yc:Qc:s?Gc:Vc).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;const o=J(e);if(!r){let c;if(o&&(c=qm[i]))return c;if(i==="hasOwnProperty")return Wm}const a=Reflect.get(e,i,De(e)?e:n);if((Gt(i)?zc.has(i):Hm(i))||(r||ze(e,"get",i),s))return a;if(De(a)){const c=o&&bo(i)?a:a.value;return r&&ke(c)?Lo(c):c}return ke(a)?r?Lo(a):Oo(a):a}}class Wc extends Hc{constructor(e=!1){super(!1,e)}set(e,i,n,r){let s=e[i];const o=J(e)&&bo(i);if(!this._isShallow){const l=Jt(s);if(!mt(n)&&!Jt(n)&&(s=oe(s),n=oe(n)),!o&&De(s)&&!De(n))return l||(s.value=n),!0}const a=o?Number(i)<e.length:ce(e,i),c=Reflect.set(e,i,n,De(e)?e:r);return e===oe(r)&&(a?it(n,s)&&Yt(e,"set",i,n):Yt(e,"add",i,n)),c}deleteProperty(e,i){const n=ce(e,i);e[i];const r=Reflect.deleteProperty(e,i);return r&&n&&Yt(e,"delete",i,void 0),r}has(e,i){const n=Reflect.has(e,i);return(!Gt(i)||!zc.has(i))&&ze(e,"has",i),n}ownKeys(e){return ze(e,"iterate",J(e)?"length":_i),Reflect.ownKeys(e)}}class Kc extends Hc{constructor(e=!1){super(!0,e)}set(e,i){return!0}deleteProperty(e,i){return!0}}const Km=new Wc,Vm=new Kc,Gm=new Wc(!0),Qm=new Kc(!0),To=t=>t,Cr=t=>Reflect.getPrototypeOf(t);function Ym(t,e,i){return function(...n){const r=this.__v_raw,s=oe(r),o=Bi(s),a=t==="entries"||t===Symbol.iterator&&o,c=t==="keys"&&o,l=r[t](...n),u=i?To:e?zi:kt;return!e&&ze(s,"iterate",c?Io:_i),{next(){const{value:d,done:m}=l.next();return m?{value:d,done:m}:{value:a?[u(d[0]),u(d[1])]:u(d),done:m}},[Symbol.iterator](){return this}}}}function Ir(t){return function(...e){return t==="delete"?!1:t==="clear"?void 0:this}}function Xm(t,e){const i={get(r){const s=this.__v_raw,o=oe(s),a=oe(r);t||(it(r,a)&&ze(o,"get",r),ze(o,"get",a));const{has:c}=Cr(o),l=e?To:t?zi:kt;if(c.call(o,r))return l(s.get(r));if(c.call(o,a))return l(s.get(a));s!==o&&s.get(r)},get size(){const r=this.__v_raw;return!t&&ze(oe(r),"iterate",_i),r.size},has(r){const s=this.__v_raw,o=oe(s),a=oe(r);return t||(it(r,a)&&ze(o,"has",r),ze(o,"has",a)),r===a?s.has(r):s.has(r)||s.has(a)},forEach(r,s){const o=this,a=o.__v_raw,c=oe(a),l=e?To:t?zi:kt;return!t&&ze(c,"iterate",_i),a.forEach((u,d)=>r.call(s,l(u),l(d),o))}};return Ue(i,t?{add:Ir("add"),set:Ir("set"),delete:Ir("delete"),clear:Ir("clear")}:{add(r){!e&&!mt(r)&&!Jt(r)&&(r=oe(r));const s=oe(this);return Cr(s).has.call(s,r)||(s.add(r),Yt(s,"add",r,r)),this},set(r,s){!e&&!mt(s)&&!Jt(s)&&(s=oe(s));const o=oe(this),{has:a,get:c}=Cr(o);let l=a.call(o,r);l||(r=oe(r),l=a.call(o,r));const u=c.call(o,r);return o.set(r,s),l?it(s,u)&&Yt(o,"set",r,s):Yt(o,"add",r,s),this},delete(r){const s=oe(this),{has:o,get:a}=Cr(s);let c=o.call(s,r);c||(r=oe(r),c=o.call(s,r)),a&&a.call(s,r);const l=s.delete(r);return c&&Yt(s,"delete",r,void 0),l},clear(){const r=oe(this),s=r.size!==0,o=r.clear();return s&&Yt(r,"clear",void 0,void 0),o}}),["keys","values","entries",Symbol.iterator].forEach(r=>{i[r]=Ym(r,t,e)}),i}function Rr(t,e){const i=Xm(t,e);return(n,r,s)=>r==="__v_isReactive"?!t:r==="__v_isReadonly"?t:r==="__v_raw"?n:Reflect.get(ce(i,r)&&r in n?i:n,r,s)}const Jm={get:Rr(!1,!1)},Zm={get:Rr(!1,!0)},ey={get:Rr(!0,!1)},ty={get:Rr(!0,!0)},Vc=new WeakMap,Gc=new WeakMap,Qc=new WeakMap,Yc=new WeakMap;function iy(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:iy(Rm(t))}function Oo(t){return Jt(t)?t:Ar(t,!1,Km,Jm,Vc)}function ry(t){return Ar(t,!1,Gm,Zm,Gc)}function Lo(t){return Ar(t,!0,Vm,ey,Qc)}function M0(t){return Ar(t,!0,Qm,ty,Yc)}function Ar(t,e,i,n,r){if(!ke(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const s=ny(t);if(s===0)return t;const o=r.get(t);if(o)return o;const a=new Proxy(t,s===2?n:i);return r.set(t,a),a}function xi(t){return Jt(t)?xi(t.__v_raw):!!(t&&t.__v_isReactive)}function Jt(t){return!!(t&&t.__v_isReadonly)}function mt(t){return!!(t&&t.__v_isShallow)}function No(t){return t?!!t.__v_raw:!1}function oe(t){const e=t&&t.__v_raw;return e?oe(e):t}function sy(t){return!ce(t,"__v_skip")&&Object.isExtensible(t)&&Cc(t,"__v_skip",!0),t}const kt=t=>ke(t)?Oo(t):t,zi=t=>ke(t)?Lo(t):t;function De(t){return t?t.__v_isRef===!0:!1}function Qe(t){return Jc(t,!1)}function Xc(t){return Jc(t,!0)}function Jc(t,e){return De(t)?t:new oy(t,e)}class oy{constructor(e,i){this.dep=new Er,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=i?e:oe(e),this._value=i?e:kt(e),this.__v_isShallow=i}get value(){return this.dep.track(),this._value}set value(e){const i=this._rawValue,n=this.__v_isShallow||mt(e)||Jt(e);e=n?e:oe(e),it(e,i)&&(this._rawValue=e,this._value=n?e:kt(e),this.dep.trigger())}}function Oe(t){return De(t)?t.value:t}const ay={get:(t,e,i)=>e==="__v_raw"?t:Oe(Reflect.get(t,e,i)),set:(t,e,i,n)=>{const r=t[e];return De(r)&&!De(i)?(r.value=i,!0):Reflect.set(t,e,i,n)}};function Zc(t){return xi(t)?t:new Proxy(t,ay)}class ly{constructor(e){this.__v_isRef=!0,this._value=void 0;const i=this.dep=new Er,{get:n,set:r}=e(i.track.bind(i),i.trigger.bind(i));this._get=n,this._set=r}get value(){return this._value=this._get()}set value(e){this._set(e)}}function cy(t){return new ly(t)}class uy{constructor(e,i,n){this.fn=e,this.setter=i,this._value=void 0,this.dep=new Er(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=Sn-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!i,this.isSSR=n}notify(){if(this.flags|=16,!(this.flags&8)&&be!==this)return Nc(this,!0),!0}get value(){const e=this.dep.track();return jc(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}}function dy(t,e,i=!1){let n,r;return Z(t)?n=t:(n=t.get,r=t.set),new uy(n,r,i)}const Tr={},Or=new WeakMap;let ki;function fy(t,e=!1,i=ki){if(i){let n=Or.get(i);n||Or.set(i,n=[]),n.push(t)}}function hy(t,e,i=le){const{immediate:n,deep:r,once:s,scheduler:o,augmentJob:a,call:c}=i,l=g=>r?g:mt(g)||r===!1||r===0?Zt(g,1):Zt(g);let u,d,m,p,h=!1,x=!1;if(De(t)?(d=()=>t.value,h=mt(t)):xi(t)?(d=()=>l(t),h=!0):J(t)?(x=!0,h=t.some(g=>xi(g)||mt(g)),d=()=>t.map(g=>{if(De(g))return g.value;if(xi(g))return l(g);if(Z(g))return c?c(g,2):g()})):Z(t)?e?d=c?()=>c(t,2):t:d=()=>{if(m){Mt();try{m()}finally{Dt()}}const g=ki;ki=u;try{return c?c(t,3,[p]):t(p)}finally{ki=g}}:d=Nt,e&&r){const g=d,w=r===!0?1/0:r;d=()=>Zt(g(),w)}const k=Um(),E=()=>{u.stop(),k&&k.active&&yo(k.effects,u)};if(s&&e){const g=e;e=(...w)=>{g(...w),E()}}let y=x?new Array(t.length).fill(Tr):Tr;const b=g=>{if(!(!(u.flags&1)||!u.dirty&&!g))if(e){const w=u.run();if(r||h||(x?w.some((S,R)=>it(S,y[R])):it(w,y))){m&&m();const S=ki;ki=u;try{const R=[w,y===Tr?void 0:x&&y[0]===Tr?[]:y,p];y=w,c?c(e,3,R):e(...R)}finally{ki=S}}}else u.run()};return a&&a(b),u=new Oc(d),u.scheduler=o?()=>o(b,!1):b,p=g=>fy(g,!1,u),m=u.onStop=()=>{const g=Or.get(u);if(g){if(c)c(g,4);else for(const w of g)w();Or.delete(u)}},e?n?b(!0):y=u.run():o?o(b.bind(null,!0),!0):u.run(),E.pause=u.pause.bind(u),E.resume=u.resume.bind(u),E.stop=E,E}function Zt(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))Zt(t.value,e,i);else if(J(t))for(let n=0;n<t.length;n++)Zt(t[n],e,i);else if(kc(t)||Bi(t))t.forEach(n=>{Zt(n,e,i)});else if(Ec(t)){for(const n in t)Zt(t[n],e,i);for(const n of Object.getOwnPropertySymbols(t))Object.prototype.propertyIsEnumerable.call(t,n)&&Zt(t[n],e,i)}return t}const Pn=[];let Mo=!1;function D0(t,...e){if(Mo)return;Mo=!0,Mt();const i=Pn.length?Pn[Pn.length-1].component:null,n=i&&i.appContext.config.warnHandler,r=py();if(n)Hi(n,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,r.map(({vnode:s})=>`at <${Yu(i,s.type)}>`).join(`
22
22
  `),r]);else{const s=[`[Vue warn]: ${t}`,...e];r.length&&s.push(`
23
- `,...Ym(r))}Pt(),So=!1}function Qm(){let t=mn[mn.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 n=t.component&&t.component.parent;t=n&&n.vnode}return e}function Ym(t){const e=[];return t.forEach((i,n)=>{e.push(...n===0?[]:[`
24
- `],...Xm(i))}),e}function Xm({vnode:t,recurseCount:e}){const i=e>0?`... (${e} recursive calls)`:"",n=t.component?t.component.parent==null:!1,r=` at <${Nu(t.component,t.type,n)}`,s=">"+i;return t.props?[r,...Jm(t.props),s]:[r+s]}function Jm(t){const e=[],i=Object.keys(t);return i.slice(0,3).forEach(n=>{e.push(...Fc(n,t[n]))}),i.length>3&&e.push(" ..."),e}function Fc(t,e,i){return _e(e)?(e=JSON.stringify(e),i?e:[`${t}=${e}`]):typeof e=="number"||typeof e=="boolean"||e==null?i?e:[`${t}=${e}`]:Ie(e)?(e=Fc(t,ie(e.value),!0),i?e:[`${t}=Ref<`,e,">"]):Y(e)?[`${t}=fn${e.name?`<${e.name}>`:""}`]:(e=ie(e),i?e:[`${t}=`,e])}function Li(t,e,i,n){try{return n?t(...n):t()}catch(r){yn(r,e,i)}}function Ct(t,e,i,n){if(Y(t)){const r=Li(t,e,i,n);return r&&uc(r)&&r.catch(s=>{yn(s,e,i)}),r}if(Q(t)){const r=[];for(let s=0;s<t.length;s++)r.push(Ct(t[s],e,i,n));return r}}function yn(t,e,i,n=!0){const r=e?e.vnode:null,{errorHandler:s,throwUnhandledErrorInProduction:o}=e&&e.appContext.config||ne;if(e){let a=e.parent;const l=e.proxy,c=`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,l,c)===!1)return}a=a.parent}if(s){Et(),Li(s,null,10,[t,l,c]),Pt();return}}Zm(t,i,r,n,o)}function Zm(t,e,i,n=!0,r=!1){if(r)throw t}const Be=[];let Rt=-1;const Ni=[];let ei=null,Mi=0;const Bc=Promise.resolve();let Sr=null;function bn(t){const e=Sr||Bc;return t?e.then(this?t.bind(this):t):e}function ey(t){let e=Rt+1,i=Be.length;for(;e<i;){const n=e+i>>>1,r=Be[n],s=vn(r);s<t||s===t&&r.flags&2?e=n+1:i=n}return e}function $o(t){if(!(t.flags&1)){const e=vn(t),i=Be[Be.length-1];!i||!(t.flags&2)&&e>=vn(i)?Be.push(t):Be.splice(ey(e),0,t),t.flags|=1,qc()}}function qc(){Sr||(Sr=Bc.then(Kc))}function ty(t){Q(t)?Ni.push(...t):ei&&t.id===-1?ei.splice(Mi+1,0,t):t.flags&1||(Ni.push(t),t.flags|=1),qc()}function Hc(t,e,i=Rt+1){for(;i<Be.length;i++){const n=Be[i];if(n&&n.flags&2){if(t&&n.id!==t.uid)continue;Be.splice(i,1),i--,n.flags&4&&(n.flags&=-2),n(),n.flags&4||(n.flags&=-2)}}}function zc(t){if(Ni.length){const e=[...new Set(Ni)].sort((i,n)=>vn(i)-vn(n));if(Ni.length=0,ei){ei.push(...e);return}for(ei=e,Mi=0;Mi<ei.length;Mi++){const i=ei[Mi];i.flags&4&&(i.flags&=-2),i.flags&8||i(),i.flags&=-2}ei=null,Mi=0}}const vn=t=>t.id==null?t.flags&2?-1:1/0:t.id;function Kc(t){try{for(Rt=0;Rt<Be.length;Rt++){const e=Be[Rt];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),Li(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;Rt<Be.length;Rt++){const e=Be[Rt];e&&(e.flags&=-2)}Rt=-1,Be.length=0,zc(),Sr=null,(Be.length||Ni.length)&&Kc()}}let De=null,Wc=null;function $r(t){const e=De;return De=t,Wc=t&&t.type.__scopeId||null,e}function wn(t,e=De,i){if(!e||t._n)return t;const n=(...r)=>{n._d&&Pu(-1);const s=$r(e);let o;try{o=t(...r)}finally{$r(s),n._d&&Pu(1)}return o};return n._n=!0,n._c=!0,n._d=!0,n}function Vc(t,e){if(De===null)return t;const i=Mr(De),n=t.dirs||(t.dirs=[]);for(let r=0;r<e.length;r++){let[s,o,a,l=ne]=e[r];s&&(Y(s)&&(s={mounted:s,updated:s}),s.deep&&zt(o),n.push({dir:s,instance:i,value:o,oldValue:void 0,arg:a,modifiers:l}))}return t}function hi(t,e,i,n){const r=t.dirs,s=e&&e.dirs;for(let o=0;o<r.length;o++){const a=r[o];s&&(a.oldValue=s[o].value);let l=a.dir[n];l&&(Et(),Ct(l,i,8,[t.el,a,t,e]),Pt())}}const iy=Symbol("_vte"),ny=t=>t.__isTeleport,ry=Symbol("_leaveCb");function Eo(t,e){t.shapeFlag&6&&t.component?(t.transition=e,Eo(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 pi(t,e){return Y(t)?Oe({name:t.name},e,{setup:t}):t}function Po(t){t.ids=[t.ids[0]+t.ids[2]+++"-",0,0]}function Gc(t){const e=zo(),i=Dc(null);if(e){const r=e.refs===ne?e.refs={}:e.refs;Object.defineProperty(r,t,{enumerable:!0,get:()=>i.value,set:s=>i.value=s})}return i}const Er=new WeakMap;function _n(t,e,i,n,r=!1){if(Q(t)){t.forEach((f,w)=>_n(f,e&&(Q(e)?e[w]:e),i,n,r));return}if(Di(n)&&!r){n.shapeFlag&512&&n.type.__asyncResolved&&n.component.subTree.component&&_n(t,e,i,n.component.subTree);return}const s=n.shapeFlag&4?Mr(n.component):n.el,o=r?null:s,{i:a,r:l}=t,c=e&&e.r,u=a.refs===ne?a.refs={}:a.refs,d=a.setupState,y=ie(d),p=d===ne?lc:f=>se(y,f);if(c!=null&&c!==l){if(Qc(e),_e(c))u[c]=null,p(c)&&(d[c]=null);else if(Ie(c)){c.value=null;const f=e;f.k&&(u[f.k]=null)}}if(Y(l))Li(l,a,12,[o,u]);else{const f=_e(l),w=Ie(l);if(f||w){const x=()=>{if(t.f){const S=f?p(l)?d[l]:u[l]:l.value;if(r)Q(S)&&ro(S,s);else if(Q(S))S.includes(s)||S.push(s);else if(f)u[l]=[s],p(l)&&(d[l]=u[l]);else{const I=[s];l.value=I,t.k&&(u[t.k]=I)}}else f?(u[l]=o,p(l)&&(d[l]=o)):w&&(l.value=o,t.k&&(u[t.k]=o))};if(o){const S=()=>{x(),Er.delete(t)};S.id=-1,Er.set(t,S),tt(S,i)}else Qc(t),x()}}}function Qc(t){const e=Er.get(t);e&&(e.flags|=8,Er.delete(t))}const Yc=t=>t.nodeType===8;pr().requestIdleCallback,pr().cancelIdleCallback;function sy(t,e){if(Yc(t)&&t.data==="["){let i=1,n=t.nextSibling;for(;n;){if(n.nodeType===1){if(e(n)===!1)break}else if(Yc(n))if(n.data==="]"){if(--i===0)break}else n.data==="["&&i++;n=n.nextSibling}}else e(t)}const Di=t=>!!t.type.__asyncLoader;function oy(t){Y(t)&&(t={loader:t});const{loader:e,loadingComponent:i,errorComponent:n,delay:r=200,hydrate:s,timeout:o,suspensible:a=!0,onError:l}=t;let c=null,u,d=0;const y=()=>(d++,c=null,p()),p=()=>{let f;return c||(f=c=e().catch(w=>{if(w=w instanceof Error?w:new Error(String(w)),l)return new Promise((x,S)=>{l(w,()=>x(y()),()=>S(w),d+1)});throw w}).then(w=>f!==c&&c?c:(w&&(w.__esModule||w[Symbol.toStringTag]==="Module")&&(w=w.default),u=w,w)))};return pi({name:"AsyncComponentWrapper",__asyncLoader:p,__asyncHydrate(f,w,x){let S=!1;(w.bu||(w.bu=[])).push(()=>S=!0);const I=()=>{S||x()},m=s?()=>{const g=s(I,b=>sy(f,b));g&&(w.bum||(w.bum=[])).push(g)}:I;u?m():p().then(()=>!w.isUnmounted&&m())},get __asyncResolved(){return u},setup(){const f=je;if(Po(f),u)return()=>Pr(u,f);const w=m=>{c=null,yn(m,f,13,!n)};if(a&&f.suspense||Bi)return p().then(m=>()=>Pr(m,f)).catch(m=>(w(m),()=>n?Ce(n,{error:m}):null));const x=Fe(!1),S=Fe(),I=Fe(!!r);return r&&setTimeout(()=>{I.value=!1},r),o!=null&&setTimeout(()=>{if(!x.value&&!S.value){const m=new Error(`Async component timed out after ${o}ms.`);w(m),S.value=m}},o),p().then(()=>{x.value=!0,f.parent&&Co(f.parent.vnode)&&f.parent.update()}).catch(m=>{w(m),S.value=m}),()=>{if(x.value&&u)return Pr(u,f);if(S.value&&n)return Ce(n,{error:S.value});if(i&&!I.value)return Pr(i,f)}}})}function Pr(t,e){const{ref:i,props:n,children:r,ce:s}=e.vnode,o=Ce(t,n,r);return o.ref=i,o.ce=s,delete e.vnode.ce,o}const Co=t=>t.type.__isKeepAlive;function ay(t,e){Xc(t,"a",e)}function ly(t,e){Xc(t,"da",e)}function Xc(t,e,i=je){const n=t.__wdc||(t.__wdc=()=>{let r=i;for(;r;){if(r.isDeactivated)return;r=r.parent}return t()});if(Cr(e,n,i),i){let r=i.parent;for(;r&&r.parent;)Co(r.parent.vnode)&&cy(n,e,i,r),r=r.parent}}function cy(t,e,i,n){const r=Cr(e,t,n,!0);Io(()=>{ro(n[e],r)},i)}function Cr(t,e,i=je,n=!1){if(i){const r=i[t]||(i[t]=[]),s=e.__weh||(e.__weh=(...o)=>{Et();const a=In(i),l=Ct(e,i,t,o);return a(),Pt(),l});return n?r.unshift(s):r.push(s),s}}const Kt=t=>(e,i=je)=>{(!Bi||t==="sp")&&Cr(t,(...n)=>e(...n),i)},Jc=Kt("bm"),xn=Kt("m"),uy=Kt("bu"),dy=Kt("u"),Ro=Kt("bum"),Io=Kt("um"),fy=Kt("sp"),hy=Kt("rtg"),py=Kt("rtc");function gy(t,e=je){Cr("ec",t,e)}const my=Symbol.for("v-ndc");function Ao(t,e,i,n){let r;const s=i,o=Q(t);if(o||_e(t)){const a=o&&Ti(t);let l=!1,c=!1;a&&(l=!lt(t),c=Zt(t),t=mr(t)),r=new Array(t.length);for(let u=0,d=t.length;u<d;u++)r[u]=e(l?c?_r(Te(t[u])):Te(t[u]):t[u],u,void 0,s)}else if(typeof t=="number"){r=new Array(t);for(let a=0;a<t;a++)r[a]=e(a+1,a,void 0,s)}else if(me(t))if(t[Symbol.iterator])r=Array.from(t,(a,l)=>e(a,l,void 0,s));else{const a=Object.keys(t);r=new Array(a.length);for(let l=0,c=a.length;l<c;l++){const u=a[l];r[l]=e(t[u],u,l,s)}}else r=[];return r}function yy(t,e,i={},n,r){if(De.ce||De.parent&&Di(De.parent)&&De.parent.ce){const c=Object.keys(i).length>0;return oe(),Tr(He,null,[Ce("slot",i,n)],c?-2:64)}let s=t[e];s&&s._c&&(s._d=!1),oe();const o=s&&Zc(s(i)),a=i.key||o&&o.key,l=Tr(He,{key:(a&&!Ft(a)?a:`_${e}`)+(!o&&n?"_fb":"")},o||[],o&&t._===1?64:-2);return l.scopeId&&(l.slotScopeIds=[l.scopeId+"-s"]),s&&s._c&&(s._d=!0),l}function Zc(t){return t.some(e=>qo(e)?!(e.type===Wt||e.type===He&&!Zc(e.children)):!0)?t:null}const Oo=t=>t?Ou(t)?Mr(t):Oo(t.parent):null,kn=Oe(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=>Oo(t.parent),$root:t=>Oo(t.root),$host:t=>t.ce,$emit:t=>t.emit,$options:t=>nu(t),$forceUpdate:t=>t.f||(t.f=()=>{$o(t.update)}),$nextTick:t=>t.n||(t.n=bn.bind(t.proxy)),$watch:t=>Uy.bind(t)}),To=(t,e)=>t!==ne&&!t.__isScriptSetup&&se(t,e),by={get({_:t},e){if(e==="__v_skip")return!0;const{ctx:i,setupState:n,data:r,props:s,accessCache:o,type:a,appContext:l}=t;let c;if(e[0]!=="$"){const p=o[e];if(p!==void 0)switch(p){case 1:return n[e];case 2:return r[e];case 4:return i[e];case 3:return s[e]}else{if(To(n,e))return o[e]=1,n[e];if(r!==ne&&se(r,e))return o[e]=2,r[e];if((c=t.propsOptions[0])&&se(c,e))return o[e]=3,s[e];if(i!==ne&&se(i,e))return o[e]=4,i[e];Lo&&(o[e]=0)}}const u=kn[e];let d,y;if(u)return e==="$attrs"&&Me(t.attrs,"get",""),u(t);if((d=a.__cssModules)&&(d=d[e]))return d;if(i!==ne&&se(i,e))return o[e]=4,i[e];if(y=l.config.globalProperties,se(y,e))return y[e]},set({_:t},e,i){const{data:n,setupState:r,ctx:s}=t;return To(r,e)?(r[e]=i,!0):n!==ne&&se(n,e)?(n[e]=i,!0):se(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(s[e]=i,!0)},has({_:{data:t,setupState:e,accessCache:i,ctx:n,appContext:r,propsOptions:s,type:o}},a){let l,c;return!!(i[a]||t!==ne&&a[0]!=="$"&&se(t,a)||To(e,a)||(l=s[0])&&se(l,a)||se(n,a)||se(kn,a)||se(r.config.globalProperties,a)||(c=o.__cssModules)&&c[a])},defineProperty(t,e,i){return i.get!=null?t._.accessCache[e]=0:se(i,"value")&&this.set(t,e,i.value,null),Reflect.defineProperty(t,e,i)}};function Rr(t){return Q(t)?t.reduce((e,i)=>(e[i]=null,e),{}):t}function eu(t,e){return!t||!e?t||e:Q(t)&&Q(e)?t.concat(e):Oe({},Rr(t),Rr(e))}let Lo=!0;function vy(t){const e=nu(t),i=t.proxy,n=t.ctx;Lo=!1,e.beforeCreate&&tu(e.beforeCreate,t,"bc");const{data:r,computed:s,methods:o,watch:a,provide:l,inject:c,created:u,beforeMount:d,mounted:y,beforeUpdate:p,updated:f,activated:w,deactivated:x,beforeDestroy:S,beforeUnmount:I,destroyed:m,unmounted:g,render:b,renderTracked:k,renderTriggered:P,errorCaptured:L,serverPrefetch:C,expose:U,inheritAttrs:H,components:ze,directives:ft,filters:Gi}=e;if(c&&wy(c,n,null),o)for(const ge in o){const he=o[ge];Y(he)&&(n[ge]=he.bind(i))}if(r){const ge=r.call(i,i);me(ge)&&(t.data=_o(ge))}if(Lo=!0,s)for(const ge in s){const he=s[ge],ki=Y(he)?he.bind(i,i):Y(he.get)?he.get.bind(i,i):$t,os=!Y(he)&&Y(he.set)?he.set.bind(i):$t,Si=Ot({get:ki,set:os});Object.defineProperty(n,ge,{enumerable:!0,configurable:!0,get:()=>Si.value,set:Tt=>Si.value=Tt})}if(a)for(const ge in a)iu(a[ge],n,i,ge);if(l){const ge=Y(l)?l.call(i):l;Reflect.ownKeys(ge).forEach(he=>{au(he,ge[he])})}u&&tu(u,t,"c");function ce(ge,he){Q(he)?he.forEach(ki=>ge(ki.bind(i))):he&&ge(he.bind(i))}if(ce(Jc,d),ce(xn,y),ce(uy,p),ce(dy,f),ce(ay,w),ce(ly,x),ce(gy,L),ce(py,k),ce(hy,P),ce(Ro,I),ce(Io,g),ce(fy,C),Q(U))if(U.length){const ge=t.exposed||(t.exposed={});U.forEach(he=>{Object.defineProperty(ge,he,{get:()=>i[he],set:ki=>i[he]=ki,enumerable:!0})})}else t.exposed||(t.exposed={});b&&t.render===$t&&(t.render=b),H!=null&&(t.inheritAttrs=H),ze&&(t.components=ze),ft&&(t.directives=ft),C&&Po(t)}function wy(t,e,i=$t){Q(t)&&(t=No(t));for(const n in t){const r=t[n];let s;me(r)?"default"in r?s=$n(r.from||n,r.default,!0):s=$n(r.from||n):s=$n(r),Ie(s)?Object.defineProperty(e,n,{enumerable:!0,configurable:!0,get:()=>s.value,set:o=>s.value=o}):e[n]=s}}function tu(t,e,i){Ct(Q(t)?t.map(n=>n.bind(e.proxy)):t.bind(e.proxy),e,i)}function iu(t,e,i,n){let r=n.includes(".")?wu(i,n):()=>i[n];if(_e(t)){const s=e[t];Y(s)&&Ui(r,s)}else if(Y(t))Ui(r,t.bind(i));else if(me(t))if(Q(t))t.forEach(s=>iu(s,e,i,n));else{const s=Y(t.handler)?t.handler.bind(i):e[t.handler];Y(s)&&Ui(r,s,t)}}function nu(t){const e=t.type,{mixins:i,extends:n}=e,{mixins:r,optionsCache:s,config:{optionMergeStrategies:o}}=t.appContext,a=s.get(e);let l;return a?l=a:!r.length&&!i&&!n?l=e:(l={},r.length&&r.forEach(c=>Ir(l,c,o,!0)),Ir(l,e,o)),me(e)&&s.set(e,l),l}function Ir(t,e,i,n=!1){const{mixins:r,extends:s}=e;s&&Ir(t,s,i,!0),r&&r.forEach(o=>Ir(t,o,i,!0));for(const o in e)if(!(n&&o==="expose")){const a=_y[o]||i&&i[o];t[o]=a?a(t[o],e[o]):e[o]}return t}const _y={data:ru,props:su,emits:su,methods:Sn,computed:Sn,beforeCreate:qe,created:qe,beforeMount:qe,mounted:qe,beforeUpdate:qe,updated:qe,beforeDestroy:qe,beforeUnmount:qe,destroyed:qe,unmounted:qe,activated:qe,deactivated:qe,errorCaptured:qe,serverPrefetch:qe,components:Sn,directives:Sn,watch:ky,provide:ru,inject:xy};function ru(t,e){return e?t?function(){return Oe(Y(t)?t.call(this,this):t,Y(e)?e.call(this,this):e)}:e:t}function xy(t,e){return Sn(No(t),No(e))}function No(t){if(Q(t)){const e={};for(let i=0;i<t.length;i++)e[t[i]]=t[i];return e}return t}function qe(t,e){return t?[...new Set([].concat(t,e))]:e}function Sn(t,e){return t?Oe(Object.create(null),t,e):e}function su(t,e){return t?Q(t)&&Q(e)?[...new Set([...t,...e])]:Oe(Object.create(null),Rr(t),Rr(e??{})):e}function ky(t,e){if(!t)return e;if(!e)return t;const i=Oe(Object.create(null),t);for(const n in e)i[n]=qe(t[n],e[n]);return i}function ou(){return{app:null,config:{isNativeTag:lc,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 Sy=0;function $y(t,e){return function(n,r=null){Y(n)||(n=Oe({},n)),r!=null&&!me(r)&&(r=null);const s=ou(),o=new WeakSet,a=[];let l=!1;const c=s.app={_uid:Sy++,_component:n,_props:r,_container:null,_context:s,_instance:null,version:ab,get config(){return s.config},set config(u){},use(u,...d){return o.has(u)||(u&&Y(u.install)?(o.add(u),u.install(c,...d)):Y(u)&&(o.add(u),u(c,...d))),c},mixin(u){return s.mixins.includes(u)||s.mixins.push(u),c},component(u,d){return d?(s.components[u]=d,c):s.components[u]},directive(u,d){return d?(s.directives[u]=d,c):s.directives[u]},mount(u,d,y){if(!l){const p=c._ceVNode||Ce(n,r);return p.appContext=s,y===!0?y="svg":y===!1&&(y=void 0),t(p,u,y),l=!0,c._container=u,u.__vue_app__=c,Mr(p.component)}},onUnmount(u){a.push(u)},unmount(){l&&(Ct(a,c._instance,16),t(null,c._container),delete c._container.__vue_app__)},provide(u,d){return s.provides[u]=d,c},runWithContext(u){const d=ji;ji=c;try{return u()}finally{ji=d}}};return c}}let ji=null;function au(t,e){if(je){let i=je.provides;const n=je.parent&&je.parent.provides;n===i&&(i=je.provides=Object.create(n)),i[t]=e}}function $n(t,e,i=!1){const n=zo();if(n||ji){let r=ji?ji._context.provides:n?n.parent==null||n.ce?n.vnode.appContext&&n.vnode.appContext.provides:n.parent.provides:void 0;if(r&&t in r)return r[t];if(arguments.length>1)return i&&Y(e)?e.call(n&&n.proxy):e}}const lu={},cu=()=>Object.create(lu),uu=t=>Object.getPrototypeOf(t)===lu;function Ey(t,e,i,n=!1){const r={},s=cu();t.propsDefaults=Object.create(null),du(t,e,r,s);for(const o in t.propsOptions[0])o in r||(r[o]=void 0);i?t.props=n?r:Um(r):t.type.props?t.props=r:t.props=s,t.attrs=s}function Py(t,e,i,n){const{props:r,attrs:s,vnode:{patchFlag:o}}=t,a=ie(r),[l]=t.propsOptions;let c=!1;if((n||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(Ar(t.emitsOptions,y))continue;const p=e[y];if(l)if(se(s,y))p!==s[y]&&(s[y]=p,c=!0);else{const f=Bt(y);r[f]=Mo(l,a,f,p,t,!1)}else p!==s[y]&&(s[y]=p,c=!0)}}}else{du(t,e,r,s)&&(c=!0);let u;for(const d in a)(!e||!se(e,d)&&((u=Jt(d))===d||!se(e,u)))&&(l?i&&(i[d]!==void 0||i[u]!==void 0)&&(r[d]=Mo(l,a,d,void 0,t,!0)):delete r[d]);if(s!==a)for(const d in s)(!e||!se(e,d))&&(delete s[d],c=!0)}c&&qt(t.attrs,"set","")}function du(t,e,i,n){const[r,s]=t.propsOptions;let o=!1,a;if(e)for(let l in e){if(un(l))continue;const c=e[l];let u;r&&se(r,u=Bt(l))?!s||!s.includes(u)?i[u]=c:(a||(a={}))[u]=c:Ar(t.emitsOptions,l)||(!(l in n)||c!==n[l])&&(n[l]=c,o=!0)}if(s){const l=ie(i),c=a||ne;for(let u=0;u<s.length;u++){const d=s[u];i[d]=Mo(r,l,d,c[d],t,!se(c,d))}}return o}function Mo(t,e,i,n,r,s){const o=t[i];if(o!=null){const a=se(o,"default");if(a&&n===void 0){const l=o.default;if(o.type!==Function&&!o.skipFactory&&Y(l)){const{propsDefaults:c}=r;if(i in c)n=c[i];else{const u=In(r);n=c[i]=l.call(null,e),u()}}else n=l;r.ce&&r.ce._setProp(i,n)}o[0]&&(s&&!a?n=!1:o[1]&&(n===""||n===Jt(i))&&(n=!0))}return n}const Cy=new WeakMap;function fu(t,e,i=!1){const n=i?Cy:e.propsCache,r=n.get(t);if(r)return r;const s=t.props,o={},a=[];let l=!1;if(!Y(t)){const u=d=>{l=!0;const[y,p]=fu(d,e,!0);Oe(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&&!l)return me(t)&&n.set(t,Ii),Ii;if(Q(s))for(let u=0;u<s.length;u++){const d=Bt(s[u]);hu(d)&&(o[d]=ne)}else if(s)for(const u in s){const d=Bt(u);if(hu(d)){const y=s[u],p=o[d]=Q(y)||Y(y)?{type:y}:Oe({},y),f=p.type;let w=!1,x=!0;if(Q(f))for(let S=0;S<f.length;++S){const I=f[S],m=Y(I)&&I.name;if(m==="Boolean"){w=!0;break}else m==="String"&&(x=!1)}else w=Y(f)&&f.name==="Boolean";p[0]=w,p[1]=x,(w||se(p,"default"))&&a.push(d)}}const c=[o,a];return me(t)&&n.set(t,c),c}function hu(t){return t[0]!=="$"&&!un(t)}const Do=t=>t==="_"||t==="_ctx"||t==="$stable",jo=t=>Q(t)?t.map(It):[It(t)],Ry=(t,e,i)=>{if(e._n)return e;const n=wn((...r)=>jo(e(...r)),i);return n._c=!1,n},pu=(t,e,i)=>{const n=t._ctx;for(const r in t){if(Do(r))continue;const s=t[r];if(Y(s))e[r]=Ry(r,s,n);else if(s!=null){const o=jo(s);e[r]=()=>o}}},gu=(t,e)=>{const i=jo(e);t.slots.default=()=>i},mu=(t,e,i)=>{for(const n in e)(i||!Do(n))&&(t[n]=e[n])},Iy=(t,e,i)=>{const n=t.slots=cu();if(t.vnode.shapeFlag&32){const r=e._;r?(mu(n,e,i),i&&pc(n,"_",r,!0)):pu(e,n)}else e&&gu(t,e)},Ay=(t,e,i)=>{const{vnode:n,slots:r}=t;let s=!0,o=ne;if(n.shapeFlag&32){const a=e._;a?i&&a===1?s=!1:mu(r,e,i):(s=!e.$stable,pu(e,r)),o=e}else e&&(gu(t,e),o={default:1});if(s)for(const a in r)!Do(a)&&o[a]==null&&delete r[a]},tt=Wy;function Oy(t){return Ty(t)}function Ty(t,e){const i=pr();i.__VUE__=!0;const{insert:n,remove:r,patchProp:s,createElement:o,createText:a,createComment:l,setText:c,setElementText:u,parentNode:d,nextSibling:y,setScopeId:p=$t,insertStaticContent:f}=t,w=(v,_,E,N=null,A=null,O=null,F=void 0,j=null,M=!!_.dynamicChildren)=>{if(v===_)return;v&&!Cn(v,_)&&(N=as(v),Tt(v,A,O,!0),v=null),_.patchFlag===-2&&(M=!1,_.dynamicChildren=null);const{type:T,ref:K,shapeFlag:q}=_;switch(T){case Or:x(v,_,E,N);break;case Wt:S(v,_,E,N);break;case Bo:v==null&&I(_,E,N,F);break;case He:ze(v,_,E,N,A,O,F,j,M);break;default:q&1?b(v,_,E,N,A,O,F,j,M):q&6?ft(v,_,E,N,A,O,F,j,M):(q&64||q&128)&&T.process(v,_,E,N,A,O,F,j,M,Fn)}K!=null&&A?_n(K,v&&v.ref,O,_||v,!_):K==null&&v&&v.ref!=null&&_n(v.ref,null,O,v,!0)},x=(v,_,E,N)=>{if(v==null)n(_.el=a(_.children),E,N);else{const A=_.el=v.el;_.children!==v.children&&c(A,_.children)}},S=(v,_,E,N)=>{v==null?n(_.el=l(_.children||""),E,N):_.el=v.el},I=(v,_,E,N)=>{[v.el,v.anchor]=f(v.children,_,E,N,v.el,v.anchor)},m=({el:v,anchor:_},E,N)=>{let A;for(;v&&v!==_;)A=y(v),n(v,E,N),v=A;n(_,E,N)},g=({el:v,anchor:_})=>{let E;for(;v&&v!==_;)E=y(v),r(v),v=E;r(_)},b=(v,_,E,N,A,O,F,j,M)=>{if(_.type==="svg"?F="svg":_.type==="math"&&(F="mathml"),v==null)k(_,E,N,A,O,F,j,M);else{const T=v.el&&v.el._isVueCE?v.el:null;try{T&&T._beginPatch(),C(v,_,A,O,F,j,M)}finally{T&&T._endPatch()}}},k=(v,_,E,N,A,O,F,j)=>{let M,T;const{props:K,shapeFlag:q,transition:z,dirs:X}=v;if(M=v.el=o(v.type,O,K&&K.is,K),q&8?u(M,v.children):q&16&&L(v.children,M,null,N,A,Uo(v,O),F,j),X&&hi(v,null,N,"created"),P(M,v,v.scopeId,F,N),K){for(const pe in K)pe!=="value"&&!un(pe)&&s(M,pe,null,K[pe],O,N);"value"in K&&s(M,"value",null,K.value,O),(T=K.onVnodeBeforeMount)&&At(T,N,v)}X&&hi(v,null,N,"beforeMount");const te=Ly(A,z);te&&z.beforeEnter(M),n(M,_,E),((T=K&&K.onVnodeMounted)||te||X)&&tt(()=>{T&&At(T,N,v),te&&z.enter(M),X&&hi(v,null,N,"mounted")},A)},P=(v,_,E,N,A)=>{if(E&&p(v,E),N)for(let O=0;O<N.length;O++)p(v,N[O]);if(A){let O=A.subTree;if(_===O||Eu(O.type)&&(O.ssContent===_||O.ssFallback===_)){const F=A.vnode;P(v,F,F.scopeId,F.slotScopeIds,A.parent)}}},L=(v,_,E,N,A,O,F,j,M=0)=>{for(let T=M;T<v.length;T++){const K=v[T]=j?ii(v[T]):It(v[T]);w(null,K,_,E,N,A,O,F,j)}},C=(v,_,E,N,A,O,F)=>{const j=_.el=v.el;let{patchFlag:M,dynamicChildren:T,dirs:K}=_;M|=v.patchFlag&16;const q=v.props||ne,z=_.props||ne;let X;if(E&&gi(E,!1),(X=z.onVnodeBeforeUpdate)&&At(X,E,_,v),K&&hi(_,v,E,"beforeUpdate"),E&&gi(E,!0),(q.innerHTML&&z.innerHTML==null||q.textContent&&z.textContent==null)&&u(j,""),T?U(v.dynamicChildren,T,j,E,N,Uo(_,A),O):F||he(v,_,j,null,E,N,Uo(_,A),O,!1),M>0){if(M&16)H(j,q,z,E,A);else if(M&2&&q.class!==z.class&&s(j,"class",null,z.class,A),M&4&&s(j,"style",q.style,z.style,A),M&8){const te=_.dynamicProps;for(let pe=0;pe<te.length;pe++){const le=te[pe],Xe=q[le],Je=z[le];(Je!==Xe||le==="value")&&s(j,le,Xe,Je,A,E)}}M&1&&v.children!==_.children&&u(j,_.children)}else!F&&T==null&&H(j,q,z,E,A);((X=z.onVnodeUpdated)||K)&&tt(()=>{X&&At(X,E,_,v),K&&hi(_,v,E,"updated")},N)},U=(v,_,E,N,A,O,F)=>{for(let j=0;j<_.length;j++){const M=v[j],T=_[j],K=M.el&&(M.type===He||!Cn(M,T)||M.shapeFlag&198)?d(M.el):E;w(M,T,K,null,N,A,O,F,!0)}},H=(v,_,E,N,A)=>{if(_!==E){if(_!==ne)for(const O in _)!un(O)&&!(O in E)&&s(v,O,_[O],null,A,N);for(const O in E){if(un(O))continue;const F=E[O],j=_[O];F!==j&&O!=="value"&&s(v,O,j,F,A,N)}"value"in E&&s(v,"value",_.value,E.value,A)}},ze=(v,_,E,N,A,O,F,j,M)=>{const T=_.el=v?v.el:a(""),K=_.anchor=v?v.anchor:a("");let{patchFlag:q,dynamicChildren:z,slotScopeIds:X}=_;X&&(j=j?j.concat(X):X),v==null?(n(T,E,N),n(K,E,N),L(_.children||[],E,K,A,O,F,j,M)):q>0&&q&64&&z&&v.dynamicChildren?(U(v.dynamicChildren,z,E,A,O,F,j),(_.key!=null||A&&_===A.subTree)&&yu(v,_,!0)):he(v,_,E,K,A,O,F,j,M)},ft=(v,_,E,N,A,O,F,j,M)=>{_.slotScopeIds=j,v==null?_.shapeFlag&512?A.ctx.activate(_,E,N,F,M):Gi(_,E,N,A,O,F,M):Ee(v,_,M)},Gi=(v,_,E,N,A,O,F)=>{const j=v.component=Jy(v,N,A);if(Co(v)&&(j.ctx.renderer=Fn),Zy(j,!1,F),j.asyncDep){if(A&&A.registerDep(j,ce,F),!v.el){const M=j.subTree=Ce(Wt);S(null,M,_,E),v.placeholder=M.el}}else ce(j,v,_,E,A,O,F)},Ee=(v,_,E)=>{const N=_.component=v.component;if(zy(v,_,E))if(N.asyncDep&&!N.asyncResolved){ge(N,_,E);return}else N.next=_,N.update();else _.el=v.el,N.vnode=_},ce=(v,_,E,N,A,O,F)=>{const j=()=>{if(v.isMounted){let{next:q,bu:z,u:X,parent:te,vnode:pe}=v;{const Nt=bu(v);if(Nt){q&&(q.el=pe.el,ge(v,q,F)),Nt.asyncDep.then(()=>{v.isUnmounted||j()});return}}let le=q,Xe;gi(v,!1),q?(q.el=pe.el,ge(v,q,F)):q=pe,z&&hr(z),(Xe=q.props&&q.props.onVnodeBeforeUpdate)&&At(Xe,te,q,pe),gi(v,!0);const Je=Su(v),Lt=v.subTree;v.subTree=Je,w(Lt,Je,d(Lt.el),as(Lt),v,A,O),q.el=Je.el,le===null&&Ky(v,Je.el),X&&tt(X,A),(Xe=q.props&&q.props.onVnodeUpdated)&&tt(()=>At(Xe,te,q,pe),A)}else{let q;const{el:z,props:X}=_,{bm:te,m:pe,parent:le,root:Xe,type:Je}=v,Lt=Di(_);gi(v,!1),te&&hr(te),!Lt&&(q=X&&X.onVnodeBeforeMount)&&At(q,le,_),gi(v,!0);{Xe.ce&&Xe.ce._def.shadowRoot!==!1&&Xe.ce._injectChildStyle(Je);const Nt=v.subTree=Su(v);w(null,Nt,E,N,v,A,O),_.el=Nt.el}if(pe&&tt(pe,A),!Lt&&(q=X&&X.onVnodeMounted)){const Nt=_;tt(()=>At(q,le,Nt),A)}(_.shapeFlag&256||le&&Di(le.vnode)&&le.vnode.shapeFlag&256)&&v.a&&tt(v.a,A),v.isMounted=!0,_=E=N=null}};v.scope.on();const M=v.effect=new vc(j);v.scope.off();const T=v.update=M.run.bind(M),K=v.job=M.runIfDirty.bind(M);K.i=v,K.id=v.uid,M.scheduler=()=>$o(K),gi(v,!0),T()},ge=(v,_,E)=>{_.component=v;const N=v.vnode.props;v.vnode=_,v.next=null,Py(v,_.props,N,E),Ay(v,_.children,E),Et(),Hc(v),Pt()},he=(v,_,E,N,A,O,F,j,M=!1)=>{const T=v&&v.children,K=v?v.shapeFlag:0,q=_.children,{patchFlag:z,shapeFlag:X}=_;if(z>0){if(z&128){os(T,q,E,N,A,O,F,j,M);return}else if(z&256){ki(T,q,E,N,A,O,F,j,M);return}}X&8?(K&16&&Un(T,A,O),q!==T&&u(E,q)):K&16?X&16?os(T,q,E,N,A,O,F,j,M):Un(T,A,O,!0):(K&8&&u(E,""),X&16&&L(q,E,N,A,O,F,j,M))},ki=(v,_,E,N,A,O,F,j,M)=>{v=v||Ii,_=_||Ii;const T=v.length,K=_.length,q=Math.min(T,K);let z;for(z=0;z<q;z++){const X=_[z]=M?ii(_[z]):It(_[z]);w(v[z],X,E,null,A,O,F,j,M)}T>K?Un(v,A,O,!0,!1,q):L(_,E,N,A,O,F,j,M,q)},os=(v,_,E,N,A,O,F,j,M)=>{let T=0;const K=_.length;let q=v.length-1,z=K-1;for(;T<=q&&T<=z;){const X=v[T],te=_[T]=M?ii(_[T]):It(_[T]);if(Cn(X,te))w(X,te,E,null,A,O,F,j,M);else break;T++}for(;T<=q&&T<=z;){const X=v[q],te=_[z]=M?ii(_[z]):It(_[z]);if(Cn(X,te))w(X,te,E,null,A,O,F,j,M);else break;q--,z--}if(T>q){if(T<=z){const X=z+1,te=X<K?_[X].el:N;for(;T<=z;)w(null,_[T]=M?ii(_[T]):It(_[T]),E,te,A,O,F,j,M),T++}}else if(T>z)for(;T<=q;)Tt(v[T],A,O,!0),T++;else{const X=T,te=T,pe=new Map;for(T=te;T<=z;T++){const st=_[T]=M?ii(_[T]):It(_[T]);st.key!=null&&pe.set(st.key,T)}let le,Xe=0;const Je=z-te+1;let Lt=!1,Nt=0;const Bn=new Array(Je);for(T=0;T<Je;T++)Bn[T]=0;for(T=X;T<=q;T++){const st=v[T];if(Xe>=Je){Tt(st,A,O,!0);continue}let Mt;if(st.key!=null)Mt=pe.get(st.key);else for(le=te;le<=z;le++)if(Bn[le-te]===0&&Cn(st,_[le])){Mt=le;break}Mt===void 0?Tt(st,A,O,!0):(Bn[Mt-te]=T+1,Mt>=Nt?Nt=Mt:Lt=!0,w(st,_[Mt],E,null,A,O,F,j,M),Xe++)}const Sf=Lt?Ny(Bn):Ii;for(le=Sf.length-1,T=Je-1;T>=0;T--){const st=te+T,Mt=_[st],$f=_[st+1],Ef=st+1<K?$f.el||$f.placeholder:N;Bn[T]===0?w(null,Mt,E,Ef,A,O,F,j,M):Lt&&(le<0||T!==Sf[le]?Si(Mt,E,Ef,2):le--)}}},Si=(v,_,E,N,A=null)=>{const{el:O,type:F,transition:j,children:M,shapeFlag:T}=v;if(T&6){Si(v.component.subTree,_,E,N);return}if(T&128){v.suspense.move(_,E,N);return}if(T&64){F.move(v,_,E,Fn);return}if(F===He){n(O,_,E);for(let q=0;q<M.length;q++)Si(M[q],_,E,N);n(v.anchor,_,E);return}if(F===Bo){m(v,_,E);return}if(N!==2&&T&1&&j)if(N===0)j.beforeEnter(O),n(O,_,E),tt(()=>j.enter(O),A);else{const{leave:q,delayLeave:z,afterLeave:X}=j,te=()=>{v.ctx.isUnmounted?r(O):n(O,_,E)},pe=()=>{O._isLeaving&&O[ry](!0),q(O,()=>{te(),X&&X()})};z?z(O,te,pe):pe()}else n(O,_,E)},Tt=(v,_,E,N=!1,A=!1)=>{const{type:O,props:F,ref:j,children:M,dynamicChildren:T,shapeFlag:K,patchFlag:q,dirs:z,cacheIndex:X}=v;if(q===-2&&(A=!1),j!=null&&(Et(),_n(j,null,E,v,!0),Pt()),X!=null&&(_.renderCache[X]=void 0),K&256){_.ctx.deactivate(v);return}const te=K&1&&z,pe=!Di(v);let le;if(pe&&(le=F&&F.onVnodeBeforeUnmount)&&At(le,_,v),K&6)p0(v.component,E,N);else{if(K&128){v.suspense.unmount(E,N);return}te&&hi(v,null,_,"beforeUnmount"),K&64?v.type.remove(v,_,E,Fn,N):T&&!T.hasOnce&&(O!==He||q>0&&q&64)?Un(T,_,E,!1,!0):(O===He&&q&384||!A&&K&16)&&Un(M,_,E),N&&xf(v)}(pe&&(le=F&&F.onVnodeUnmounted)||te)&&tt(()=>{le&&At(le,_,v),te&&hi(v,null,_,"unmounted")},E)},xf=v=>{const{type:_,el:E,anchor:N,transition:A}=v;if(_===He){h0(E,N);return}if(_===Bo){g(v);return}const O=()=>{r(E),A&&!A.persisted&&A.afterLeave&&A.afterLeave()};if(v.shapeFlag&1&&A&&!A.persisted){const{leave:F,delayLeave:j}=A,M=()=>F(E,O);j?j(v.el,O,M):M()}else O()},h0=(v,_)=>{let E;for(;v!==_;)E=y(v),r(v),v=E;r(_)},p0=(v,_,E)=>{const{bum:N,scope:A,job:O,subTree:F,um:j,m:M,a:T}=v;vu(M),vu(T),N&&hr(N),A.stop(),O&&(O.flags|=8,Tt(F,v,_,E)),j&&tt(j,_),tt(()=>{v.isUnmounted=!0},_)},Un=(v,_,E,N=!1,A=!1,O=0)=>{for(let F=O;F<v.length;F++)Tt(v[F],_,E,N,A)},as=v=>{if(v.shapeFlag&6)return as(v.component.subTree);if(v.shapeFlag&128)return v.suspense.next();const _=y(v.anchor||v.el),E=_&&_[iy];return E?y(E):_};let Pa=!1;const kf=(v,_,E)=>{v==null?_._vnode&&Tt(_._vnode,null,null,!0):w(_._vnode||null,v,_,null,null,null,E),_._vnode=v,Pa||(Pa=!0,Hc(),zc(),Pa=!1)},Fn={p:w,um:Tt,m:Si,r:xf,mt:Gi,mc:L,pc:he,pbc:U,n:as,o:t};return{render:kf,hydrate:void 0,createApp:$y(kf)}}function Uo({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 gi({effect:t,job:e},i){i?(t.flags|=32,e.flags|=4):(t.flags&=-33,e.flags&=-5)}function Ly(t,e){return(!t||t&&!t.pendingBranch)&&e&&!e.persisted}function yu(t,e,i=!1){const n=t.children,r=e.children;if(Q(n)&&Q(r))for(let s=0;s<n.length;s++){const o=n[s];let a=r[s];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=r[s]=ii(r[s]),a.el=o.el),!i&&a.patchFlag!==-2&&yu(o,a)),a.type===Or&&a.patchFlag!==-1&&(a.el=o.el),a.type===Wt&&!a.el&&(a.el=o.el)}}function Ny(t){const e=t.slice(),i=[0];let n,r,s,o,a;const l=t.length;for(n=0;n<l;n++){const c=t[n];if(c!==0){if(r=i[i.length-1],t[r]<c){e[n]=r,i.push(n);continue}for(s=0,o=i.length-1;s<o;)a=s+o>>1,t[i[a]]<c?s=a+1:o=a;c<t[i[s]]&&(s>0&&(e[n]=i[s-1]),i[s]=n)}}for(s=i.length,o=i[s-1];s-- >0;)i[s]=o,o=e[o];return i}function bu(t){const e=t.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:bu(e)}function vu(t){if(t)for(let e=0;e<t.length;e++)t[e].flags|=8}const My=Symbol.for("v-scx"),Dy=()=>$n(My);function jy(t,e){return Fo(t,null,{flush:"sync"})}function Ui(t,e,i){return Fo(t,e,i)}function Fo(t,e,i=ne){const{immediate:n,deep:r,flush:s,once:o}=i,a=Oe({},i),l=e&&n||!e&&s!=="post";let c;if(Bi){if(s==="sync"){const p=Dy();c=p.__watcherHandles||(p.__watcherHandles=[])}else if(!l){const p=()=>{};return p.stop=$t,p.resume=$t,p.pause=$t,p}}const u=je;a.call=(p,f,w)=>Ct(p,u,f,w);let d=!1;s==="post"?a.scheduler=p=>{tt(p,u&&u.suspense)}:s!=="sync"&&(d=!0,a.scheduler=(p,f)=>{f?p():$o(p)}),a.augmentJob=p=>{e&&(p.flags|=4),d&&(p.flags|=2,u&&(p.id=u.uid,p.i=u))};const y=Gm(t,e,a);return Bi&&(c?c.push(y):l&&y()),y}function Uy(t,e,i){const n=this.proxy,r=_e(t)?t.includes(".")?wu(n,t):()=>n[t]:t.bind(n,n);let s;Y(e)?s=e:(s=e.handler,i=e);const o=In(this),a=Fo(r,s.bind(n),i);return o(),a}function wu(t,e){const i=e.split(".");return()=>{let n=t;for(let r=0;r<i.length&&n;r++)n=n[i[r]];return n}}function _u(t,e,i=ne){const n=zo(),r=Bt(e),s=Jt(e),o=xu(t,r),a=zm((l,c)=>{let u,d=ne,y;return jy(()=>{const p=t[r];Ge(u,p)&&(u=p,c())}),{get(){return l(),i.get?i.get(u):u},set(p){const f=i.set?i.set(p):p;if(!Ge(f,u)&&!(d!==ne&&Ge(p,d)))return;const w=n.vnode.props;w&&(e in w||r in w||s in w)&&(`onUpdate:${e}`in w||`onUpdate:${r}`in w||`onUpdate:${s}`in w)||(u=p,c()),n.emit(`update:${e}`,f),Ge(p,f)&&Ge(p,d)&&!Ge(f,y)&&c(),d=p,y=f}}});return a[Symbol.iterator]=()=>{let l=0;return{next(){return l<2?{value:l++?o||ne:a,done:!1}:{done:!0}}}},a}const xu=(t,e)=>e==="modelValue"||e==="model-value"?t.modelModifiers:t[`${e}Modifiers`]||t[`${Bt(e)}Modifiers`]||t[`${Jt(e)}Modifiers`];function Fy(t,e,...i){if(t.isUnmounted)return;const n=t.vnode.props||ne;let r=i;const s=e.startsWith("update:"),o=s&&xu(n,e.slice(7));o&&(o.trim&&(r=i.map(u=>_e(u)?u.trim():u)),o.number&&(r=i.map(ao)));let a,l=n[a=oo(e)]||n[a=oo(Bt(e))];!l&&s&&(l=n[a=oo(Jt(e))]),l&&Ct(l,t,6,r);const c=n[a+"Once"];if(c){if(!t.emitted)t.emitted={};else if(t.emitted[a])return;t.emitted[a]=!0,Ct(c,t,6,r)}}const By=new WeakMap;function ku(t,e,i=!1){const n=i?By:e.emitsCache,r=n.get(t);if(r!==void 0)return r;const s=t.emits;let o={},a=!1;if(!Y(t)){const l=c=>{const u=ku(c,e,!0);u&&(a=!0,Oe(o,u))};!i&&e.mixins.length&&e.mixins.forEach(l),t.extends&&l(t.extends),t.mixins&&t.mixins.forEach(l)}return!s&&!a?(me(t)&&n.set(t,null),null):(Q(s)?s.forEach(l=>o[l]=null):Oe(o,s),me(t)&&n.set(t,o),o)}function Ar(t,e){return!t||!ur(e)?!1:(e=e.slice(2).replace(/Once$/,""),se(t,e[0].toLowerCase()+e.slice(1))||se(t,Jt(e))||se(t,e))}function _0(){}function Su(t){const{type:e,vnode:i,proxy:n,withProxy:r,propsOptions:[s],slots:o,attrs:a,emit:l,render:c,renderCache:u,props:d,data:y,setupState:p,ctx:f,inheritAttrs:w}=t,x=$r(t);let S,I;try{if(i.shapeFlag&4){const g=r||n,b=g;S=It(c.call(b,g,u,d,p,y,f)),I=a}else{const g=e;S=It(g.length>1?g(d,{attrs:a,slots:o,emit:l}):g(d,null)),I=e.props?a:qy(a)}}catch(g){En.length=0,yn(g,t,1),S=Ce(Wt)}let m=S;if(I&&w!==!1){const g=Object.keys(I),{shapeFlag:b}=m;g.length&&b&7&&(s&&g.some(no)&&(I=Hy(I,s)),m=Fi(m,I,!1,!0))}return i.dirs&&(m=Fi(m,null,!1,!0),m.dirs=m.dirs?m.dirs.concat(i.dirs):i.dirs),i.transition&&Eo(m,i.transition),S=m,$r(x),S}const qy=t=>{let e;for(const i in t)(i==="class"||i==="style"||ur(i))&&((e||(e={}))[i]=t[i]);return e},Hy=(t,e)=>{const i={};for(const n in t)(!no(n)||!(n.slice(9)in e))&&(i[n]=t[n]);return i};function zy(t,e,i){const{props:n,children:r,component:s}=t,{props:o,children:a,patchFlag:l}=e,c=s.emitsOptions;if(e.dirs||e.transition)return!0;if(i&&l>=0){if(l&1024)return!0;if(l&16)return n?$u(n,o,c):!!o;if(l&8){const u=e.dynamicProps;for(let d=0;d<u.length;d++){const y=u[d];if(o[y]!==n[y]&&!Ar(c,y))return!0}}}else return(r||a)&&(!a||!a.$stable)?!0:n===o?!1:n?o?$u(n,o,c):!0:!!o;return!1}function $u(t,e,i){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!0;for(let r=0;r<n.length;r++){const s=n[r];if(e[s]!==t[s]&&!Ar(i,s))return!0}return!1}function Ky({vnode:t,parent:e},i){for(;e;){const n=e.subTree;if(n.suspense&&n.suspense.activeBranch===t&&(n.el=t.el),n===t)(t=e.vnode).el=i,e=e.parent;else break}}const Eu=t=>t.__isSuspense;function Wy(t,e){e&&e.pendingBranch?Q(t)?e.effects.push(...t):e.effects.push(t):ty(t)}const He=Symbol.for("v-fgt"),Or=Symbol.for("v-txt"),Wt=Symbol.for("v-cmt"),Bo=Symbol.for("v-stc"),En=[];let it=null;function oe(t=!1){En.push(it=t?null:[])}function Vy(){En.pop(),it=En[En.length-1]||null}let Pn=1;function Pu(t,e=!1){Pn+=t,t<0&&it&&e&&(it.hasOnce=!0)}function Cu(t){return t.dynamicChildren=Pn>0?it||Ii:null,Vy(),Pn>0&&it&&it.push(t),t}function fe(t,e,i,n,r,s){return Cu(J(t,e,i,n,r,s,!0))}function Tr(t,e,i,n,r){return Cu(Ce(t,e,i,n,r,!0))}function qo(t){return t?t.__v_isVNode===!0:!1}function Cn(t,e){return t.type===e.type&&t.key===e.key}const Ru=({key:t})=>t??null,Lr=({ref:t,ref_key:e,ref_for:i})=>(typeof t=="number"&&(t=""+t),t!=null?_e(t)||Ie(t)||Y(t)?{i:De,r:t,k:e,f:!!i}:t:null);function J(t,e=null,i=null,n=0,r=null,s=t===He?0:1,o=!1,a=!1){const l={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&Ru(e),ref:e&&Lr(e),scopeId:Wc,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:n,dynamicProps:r,dynamicChildren:null,appContext:null,ctx:De};return a?(Ho(l,i),s&128&&t.normalize(l)):i&&(l.shapeFlag|=_e(i)?8:16),Pn>0&&!o&&it&&(l.patchFlag>0||s&6)&&l.patchFlag!==32&&it.push(l),l}const Ce=Gy;function Gy(t,e=null,i=null,n=0,r=null,s=!1){if((!t||t===my)&&(t=Wt),qo(t)){const a=Fi(t,e,!0);return i&&Ho(a,i),Pn>0&&!s&&it&&(a.shapeFlag&6?it[it.indexOf(t)]=a:it.push(a)),a.patchFlag=-2,a}if(ob(t)&&(t=t.__vccOpts),e){e=Qy(e);let{class:a,style:l}=e;a&&!_e(a)&&(e.class=gt(a)),me(l)&&(ko(l)&&!Q(l)&&(l=Oe({},l)),e.style=lo(l))}const o=_e(t)?1:Eu(t)?128:ny(t)?64:me(t)?4:Y(t)?2:0;return J(t,e,i,n,r,o,s,!0)}function Qy(t){return t?ko(t)||uu(t)?Oe({},t):t:null}function Fi(t,e,i=!1,n=!1){const{props:r,ref:s,patchFlag:o,children:a,transition:l}=t,c=e?Iu(r||{},e):r,u={__v_isVNode:!0,__v_skip:!0,type:t.type,props:c,key:c&&Ru(c),ref:e&&e.ref?i&&s?Q(s)?s.concat(Lr(e)):[s,Lr(e)]:Lr(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!==He?o===-1?16:o|16:o,dynamicProps:t.dynamicProps,dynamicChildren:t.dynamicChildren,appContext:t.appContext,dirs:t.dirs,transition:l,component:t.component,suspense:t.suspense,ssContent:t.ssContent&&Fi(t.ssContent),ssFallback:t.ssFallback&&Fi(t.ssFallback),placeholder:t.placeholder,el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce};return l&&n&&Eo(u,l.clone(u)),u}function Rn(t=" ",e=0){return Ce(Or,null,t,e)}function ti(t="",e=!1){return e?(oe(),Tr(Wt,null,t)):Ce(Wt,null,t)}function It(t){return t==null||typeof t=="boolean"?Ce(Wt):Q(t)?Ce(He,null,t.slice()):qo(t)?ii(t):Ce(Or,null,String(t))}function ii(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:Fi(t)}function Ho(t,e){let i=0;const{shapeFlag:n}=t;if(e==null)e=null;else if(Q(e))i=16;else if(typeof e=="object")if(n&65){const r=e.default;r&&(r._c&&(r._d=!1),Ho(t,r()),r._c&&(r._d=!0));return}else{i=32;const r=e._;!r&&!uu(e)?e._ctx=De:r===3&&De&&(De.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else Y(e)?(e={default:e,_ctx:De},i=32):(e=String(e),n&64?(i=16,e=[Rn(e)]):i=8);t.children=e,t.shapeFlag|=i}function Iu(...t){const e={};for(let i=0;i<t.length;i++){const n=t[i];for(const r in n)if(r==="class")e.class!==n.class&&(e.class=gt([e.class,n.class]));else if(r==="style")e.style=lo([e.style,n.style]);else if(ur(r)){const s=e[r],o=n[r];o&&s!==o&&!(Q(s)&&s.includes(o))&&(e[r]=s?[].concat(s,o):o)}else r!==""&&(e[r]=n[r])}return e}function At(t,e,i,n=null){Ct(t,e,7,[i,n])}const Yy=ou();let Xy=0;function Jy(t,e,i){const n=t.type,r=(e?e.appContext:t.appContext)||Yy,s={uid:Xy++,vnode:t,type:n,parent:e,appContext:r,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new vm(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:e?e.provides:Object.create(r.provides),ids:e?e.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:fu(n,r),emitsOptions:ku(n,r),emit:null,emitted:null,propsDefaults:ne,inheritAttrs:n.inheritAttrs,ctx:ne,data:ne,props:ne,attrs:ne,slots:ne,refs:ne,setupState:ne,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=Fy.bind(null,s),t.ce&&t.ce(s),s}let je=null;const zo=()=>je||De;let Nr,Ko;{const t=pr(),e=(i,n)=>{let r;return(r=t[i])||(r=t[i]=[]),r.push(n),s=>{r.length>1?r.forEach(o=>o(s)):r[0](s)}};Nr=e("__VUE_INSTANCE_SETTERS__",i=>je=i),Ko=e("__VUE_SSR_SETTERS__",i=>Bi=i)}const In=t=>{const e=je;return Nr(t),t.scope.on(),()=>{t.scope.off(),Nr(e)}},Au=()=>{je&&je.scope.off(),Nr(null)};function Ou(t){return t.vnode.shapeFlag&4}let Bi=!1;function Zy(t,e=!1,i=!1){e&&Ko(e);const{props:n,children:r}=t.vnode,s=Ou(t);Ey(t,n,s,e),Iy(t,r,i||e);const o=s?eb(t,e):void 0;return e&&Ko(!1),o}function eb(t,e){const i=t.type;t.accessCache=Object.create(null),t.proxy=new Proxy(t.ctx,by);const{setup:n}=i;if(n){Et();const r=t.setupContext=n.length>1?ib(t):null,s=In(t),o=Li(n,t,0,[t.props,r]),a=uc(o);if(Pt(),s(),(a||t.sp)&&!Di(t)&&Po(t),a){if(o.then(Au,Au),e)return o.then(l=>{Tu(t,l)}).catch(l=>{yn(l,t,0)});t.asyncDep=o}else Tu(t,o)}else Lu(t)}function Tu(t,e,i){Y(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:me(e)&&(t.setupState=Uc(e)),Lu(t)}function Lu(t,e,i){const n=t.type;t.render||(t.render=n.render||$t);{const r=In(t);Et();try{vy(t)}finally{Pt(),r()}}}const tb={get(t,e){return Me(t,"get",""),t[e]}};function ib(t){const e=i=>{t.exposed=i||{}};return{attrs:new Proxy(t.attrs,tb),slots:t.slots,emit:t.emit,expose:e}}function Mr(t){return t.exposed?t.exposeProxy||(t.exposeProxy=new Proxy(Uc(Fm(t.exposed)),{get(e,i){if(i in e)return e[i];if(i in kn)return kn[i](t)},has(e,i){return i in e||i in kn}})):t.proxy}const nb=/(?:^|[-_])\w/g,rb=t=>t.replace(nb,e=>e.toUpperCase()).replace(/[-_]/g,"");function sb(t,e=!0){return Y(t)?t.displayName||t.name:t.name||e&&t.__name}function Nu(t,e,i=!1){let n=sb(e);if(!n&&e.__file){const r=e.__file.match(/([^/\\]+)\.\w+$/);r&&(n=r[1])}if(!n&&t&&t.parent){const r=s=>{for(const o in s)if(s[o]===e)return o};n=r(t.components||t.parent.type.components)||r(t.appContext.components)}return n?rb(n):i?"App":"Anonymous"}function ob(t){return Y(t)&&"__vccOpts"in t}const Ot=(t,e)=>Wm(t,e,Bi),ab="3.5.24";let Wo;const Mu=typeof window<"u"&&window.trustedTypes;if(Mu)try{Wo=Mu.createPolicy("vue",{createHTML:t=>t})}catch{}const Du=Wo?t=>Wo.createHTML(t):t=>t,lb="http://www.w3.org/2000/svg",cb="http://www.w3.org/1998/Math/MathML",Vt=typeof document<"u"?document:null,ju=Vt&&Vt.createElement("template"),ub={insert:(t,e,i)=>{e.insertBefore(t,i||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,i,n)=>{const r=e==="svg"?Vt.createElementNS(lb,t):e==="mathml"?Vt.createElementNS(cb,t):i?Vt.createElement(t,{is:i}):Vt.createElement(t);return t==="select"&&n&&n.multiple!=null&&r.setAttribute("multiple",n.multiple),r},createText:t=>Vt.createTextNode(t),createComment:t=>Vt.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>Vt.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,i,n,r,s){const o=i?i.previousSibling:e.lastChild;if(r&&(r===s||r.nextSibling))for(;e.insertBefore(r.cloneNode(!0),i),!(r===s||!(r=r.nextSibling)););else{ju.innerHTML=Du(n==="svg"?`<svg>${t}</svg>`:n==="mathml"?`<math>${t}</math>`:t);const a=ju.content;if(n==="svg"||n==="mathml"){const l=a.firstChild;for(;l.firstChild;)a.appendChild(l.firstChild);a.removeChild(l)}e.insertBefore(a,i)}return[o?o.nextSibling:e.firstChild,i?i.previousSibling:e.lastChild]}},db=Symbol("_vtc");function fb(t,e,i){const n=t[db];n&&(e=(e?[e,...n]:[...n]).join(" ")),e==null?t.removeAttribute("class"):i?t.setAttribute("class",e):t.className=e}const Uu=Symbol("_vod"),hb=Symbol("_vsh"),pb=Symbol(""),gb=/(?:^|;)\s*display\s*:/;function mb(t,e,i){const n=t.style,r=_e(i);let s=!1;if(i&&!r){if(e)if(_e(e))for(const o of e.split(";")){const a=o.slice(0,o.indexOf(":")).trim();i[a]==null&&Dr(n,a,"")}else for(const o in e)i[o]==null&&Dr(n,o,"");for(const o in i)o==="display"&&(s=!0),Dr(n,o,i[o])}else if(r){if(e!==i){const o=n[pb];o&&(i+=";"+o),n.cssText=i,s=gb.test(i)}}else e&&t.removeAttribute("style");Uu in t&&(t[Uu]=s?n.display:"",t[hb]&&(n.display="none"))}const Fu=/\s*!important$/;function Dr(t,e,i){if(Q(i))i.forEach(n=>Dr(t,e,n));else if(i==null&&(i=""),e.startsWith("--"))t.setProperty(e,i);else{const n=yb(t,e);Fu.test(i)?t.setProperty(Jt(n),i.replace(Fu,""),"important"):t[n]=i}}const Bu=["Webkit","Moz","ms"],Vo={};function yb(t,e){const i=Vo[e];if(i)return i;let n=Bt(e);if(n!=="filter"&&n in t)return Vo[e]=n;n=hc(n);for(let r=0;r<Bu.length;r++){const s=Bu[r]+n;if(s in t)return Vo[e]=s}return e}const qu="http://www.w3.org/1999/xlink";function Hu(t,e,i,n,r,s=bm(e)){n&&e.startsWith("xlink:")?i==null?t.removeAttributeNS(qu,e.slice(6,e.length)):t.setAttributeNS(qu,e,i):i==null||s&&!mc(i)?t.removeAttribute(e):t.setAttribute(e,s?"":Ft(i)?String(i):i)}function zu(t,e,i,n,r){if(e==="innerHTML"||e==="textContent"){i!=null&&(t[e]=e==="innerHTML"?Du(i):i);return}const s=t.tagName;if(e==="value"&&s!=="PROGRESS"&&!s.includes("-")){const a=s==="OPTION"?t.getAttribute("value")||"":t.value,l=i==null?t.type==="checkbox"?"on":"":String(i);(a!==l||!("_value"in t))&&(t.value=l),i==null&&t.removeAttribute(e),t._value=i;return}let o=!1;if(i===""||i==null){const a=typeof t[e];a==="boolean"?i=mc(i):i==null&&a==="string"?(i="",o=!0):a==="number"&&(i=0,o=!0)}try{t[e]=i}catch{}o&&t.removeAttribute(r||e)}function qi(t,e,i,n){t.addEventListener(e,i,n)}function bb(t,e,i,n){t.removeEventListener(e,i,n)}const Ku=Symbol("_vei");function vb(t,e,i,n,r=null){const s=t[Ku]||(t[Ku]={}),o=s[e];if(n&&o)o.value=n;else{const[a,l]=wb(e);if(n){const c=s[e]=kb(n,r);qi(t,a,c,l)}else o&&(bb(t,a,o,l),s[e]=void 0)}}const Wu=/(?:Once|Passive|Capture)$/;function wb(t){let e;if(Wu.test(t)){e={};let n;for(;n=t.match(Wu);)t=t.slice(0,t.length-n[0].length),e[n[0].toLowerCase()]=!0}return[t[2]===":"?t.slice(3):Jt(t.slice(2)),e]}let Go=0;const _b=Promise.resolve(),xb=()=>Go||(_b.then(()=>Go=0),Go=Date.now());function kb(t,e){const i=n=>{if(!n._vts)n._vts=Date.now();else if(n._vts<=i.attached)return;Ct(Sb(n,i.value),e,5,[n])};return i.value=t,i.attached=xb(),i}function Sb(t,e){if(Q(e)){const i=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{i.call(t),t._stopped=!0},e.map(n=>r=>!r._stopped&&n&&n(r))}else return e}const Vu=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>96&&t.charCodeAt(2)<123,$b=(t,e,i,n,r,s)=>{const o=r==="svg";e==="class"?fb(t,n,o):e==="style"?mb(t,i,n):ur(e)?no(e)||vb(t,e,i,n,s):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):Eb(t,e,n,o))?(zu(t,e,n),!t.tagName.includes("-")&&(e==="value"||e==="checked"||e==="selected")&&Hu(t,e,n,o,s,e!=="value")):t._isVueCE&&(/[A-Z]/.test(e)||!_e(n))?zu(t,Bt(e),n,s,e):(e==="true-value"?t._trueValue=n:e==="false-value"&&(t._falseValue=n),Hu(t,e,n,o))};function Eb(t,e,i,n){if(n)return!!(e==="innerHTML"||e==="textContent"||e in t&&Vu(e)&&Y(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 r=t.tagName;if(r==="IMG"||r==="VIDEO"||r==="CANVAS"||r==="SOURCE")return!1}return Vu(e)&&_e(i)?!1:e in t}const Gu=t=>{const e=t.props["onUpdate:modelValue"]||!1;return Q(e)?i=>hr(e,i):e};function Pb(t){t.target.composing=!0}function Qu(t){const e=t.target;e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}const Qo=Symbol("_assign");function Yu(t,e,i){return e&&(t=t.trim()),i&&(t=ao(t)),t}const Xu={created(t,{modifiers:{lazy:e,trim:i,number:n}},r){t[Qo]=Gu(r);const s=n||r.props&&r.props.type==="number";qi(t,e?"change":"input",o=>{o.target.composing||t[Qo](Yu(t.value,i,s))}),(i||s)&&qi(t,"change",()=>{t.value=Yu(t.value,i,s)}),e||(qi(t,"compositionstart",Pb),qi(t,"compositionend",Qu),qi(t,"change",Qu))},mounted(t,{value:e}){t.value=e??""},beforeUpdate(t,{value:e,oldValue:i,modifiers:{lazy:n,trim:r,number:s}},o){if(t[Qo]=Gu(o),t.composing)return;const a=(s||t.type==="number")&&!/^0\d/.test(t.value)?ao(t.value):t.value,l=e??"";a!==l&&(document.activeElement===t&&t.type!=="range"&&(n&&e===i||r&&t.value.trim()===l)||(t.value=l))}},Cb=Oe({patchProp:$b},ub);let Ju;function Rb(){return Ju||(Ju=Oy(Cb))}const Ib=((...t)=>{const e=Rb().createApp(...t),{mount:i}=e;return e.mount=n=>{const r=Ob(n);if(!r)return;const s=e._component;!Y(s)&&!s.render&&!s.template&&(s.template=r.innerHTML),r.nodeType===1&&(r.textContent="");const o=i(r,!1,Ab(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),o},e});function Ab(t){if(t instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&t instanceof MathMLElement)return"mathml"}function Ob(t){return _e(t)?document.querySelector(t):t}const Tb=1;var jr;(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(Tb).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()}))})(jr||(jr={}));const Yo=Symbol("IPEInjectKey"),Lb=(t,e)=>(e?e.provide(Yo,t):au(Yo,t),t),Xo=()=>{const t=$n(Yo);if(!t)throw new Error("InPageEdit instance is not provided");return t},Zu=(t,...e)=>{const i=Ib(...e);return Lb(t,i),i};var Nb=Object.create,Jo=Object.defineProperty,Mb=Object.getOwnPropertyDescriptor,ed=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),td=t=>{throw TypeError(t)},Db=(t,e,i)=>e in t?Jo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,jb=(t,e)=>Jo(t,"name",{value:e,configurable:!0}),Ub=t=>[,,,Nb(t?.[ed("metadata")]??null)],Fb=["class","method","getter","setter","accessor","field","value","get","set"],id=t=>t!==void 0&&typeof t!="function"?td("Function expected"):t,Bb=(t,e,i,n,r)=>({kind:Fb[t],name:e,metadata:n,addInitializer:s=>i._?td("Already initialized"):r.push(id(s||null))}),qb=(t,e)=>Db(e,ed("metadata"),t[3]),Hb=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},zb=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Mb(r,i));jb(r,i);for(var f=n.length-1;f>=0;f--)l=Bb(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,id(o)&&(r=o);return qb(t,r),p&&Jo(r,i,p),u?c^4?s:p:r},nd,Zo,rd;const sd=t=>{if(!t)return null;try{return t.split(".").reduce((e,i)=>e==null?e:e[i],globalThis)}catch{return null}},od=(t,e,i)=>{if(/^https?:\/\//i.test(t))return t;const n=o=>o.endsWith("/")?o:o+"/";if(/^https?:\/\//i.test(e)){const o=n(e);return new URL(t,o).href}const r=(()=>{try{return new URL(i).href}catch{return new URL(i,location.origin).href}})(),s=new URL(n(e),r).href;return new URL(t,s).href};nd=[be(["storage","preferences","resourceLoader","$"])];let Ur=(bt=class extends(rd=Ae){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(bt.REGISTRY_INFO_STORAGE_NAME,bt.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 Zu(e,oy(()=>Promise.resolve().then(()=>O_)))}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:n})=>{const r=h("div",{id:"ipe-plugin-store-preferences-vue"}),s=await this._createManagementApp();return s.mount(r),n(()=>{s.unmount(),this.ctx.logger.debug("Plugin Store preferences app unmounted")}),h("section",{children:r})}}),e.preferences.registerCustomConfig("plugin-store",R.object({"pluginStore.registries":R.array(R.string()).default([St.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=h("section",{id:"ipe-plugin-store-vue"});e.setContent(i);const n=await this._createManagementApp();return n.mount(i),e.on(e.Event.Close,()=>{n.unmount()}),e}async install(e,i,n="online_manifest",r="new-added"){const s=await this.getRegistryInfo(e,n);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 l=await a;return l&&this.ctx.emit("plugin-store/plugin-installed",{ctx:this.ctx,registry:s,id:i,by:r}),l}async uninstall(e,i){const n=this._installedPlugins.get(`${e}#${i}`);if(n===void 0)return!0;this._installedPlugins.delete(`${e}#${i}`);const r=await n;if(r){const s=r.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 n=await this.ctx.preferences.get("pluginStore.plugins")||[];return n.some(s=>s.registry===e&&s.id===i)||(n.push({registry:e,id:i}),await this.ctx.preferences.set("pluginStore.plugins",n)),!0}async removeFromPreferences(e,i){let n=await this.ctx.preferences.get("pluginStore.plugins")||[];return n=n.filter(r=>r.registry!==e||r.id!==i),await this.ctx.preferences.set("pluginStore.plugins",n),!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,n){const r=i.base_url,s=i.packages.find(f=>f.id===n);if(!s)return this.ctx.logger.warn(`Package ${n} not found in registry ${e}`),null;const o=s.loader,{kind:a,entry:l="index.js",styles:c=[],main_export:u=null}=o;let d=null;if(a!=="styles"){if(!l)return this.ctx.logger.warn(`Entry url missing for ${n}`,o),null;try{d=od(l,r,e)}catch(f){return this.ctx.logger.warn(`Failed to resolve entry "${l}" with base "${r}" and registry "${e}"`,f),null}}const y={"data-plugin-registry":e,"data-plugin-id":n};let p=null;switch(a){case"autoload":{p=this.ctx.plugin({inject:["resourceLoader"],name:`plugin-store-${e}-${n}`,apply:f=>{d&&f.resourceLoader.loadScript(d,{...y})}});break}case"module":{if(!d)return this.ctx.logger.warn(`Entry url missing for module kind, package ${n}`),null;const f=await import(d).then(w=>(u?w[u]:w.default)??w);if(!f)return this.ctx.logger.warn(`Main export ${u} not found in module ${d}`),null;p=this.ctx.plugin(f);break}case"umd":{let f=sd(u);if(!f){if(!d)return this.ctx.logger.warn(`Entry url missing for umd kind, package ${n}`),null;await this.ctx.resourceLoader.loadScript(d,{...y}),f=sd(u)}if(!f)return this.ctx.logger.warn(`Main export ${u} not found on globalThis after loading ${d}`),null;p=this.ctx.plugin(f);break}}if(c&&c.length>0){let f=[];try{f=c.map(w=>od(w,r,e)).filter(Boolean)}catch(w){this.ctx.logger.warn(`Failed to resolve styles for ${n}`,c,w)}p||(p=this.ctx.plugin({name:`plugin-store-${e}-${n}`,apply(){}})),p.ctx.plugin({inject:["resourceLoader"],name:`plugin-store-${e}-${n}-styles`,apply:w=>{f.forEach(x=>w.resourceLoader.loadStyle(x,{...y})),w.on("dispose",()=>{try{f.forEach(x=>w.resourceLoader.removeStyle(x))}catch{}})}})}return p}validateRegistry(e){return jr.Registry(e)}async getRegistryInfo(e,i="online_manifest",n=!1){try{let s;switch(i){case"online_manifest":{s=await this._fetchOnlineRegistryInfo(e,n),this.logger.debug("Fetched registry info from online manifest",s),this.setRegistryCache(e,s);break}default:throw new Error(`Unsupported registry source: ${i}`)}return s}catch(s){this.ctx.logger.warn("Failed to fetch registry info",s)}const r=await this.getRegistryCache(e);if(!r)throw this.ctx.emit("plugin-store/registry-not-found",{ctx:this.ctx,registryUrl:e}),new Error(`Failed to fetch registry info: ${e}`);return r}async _fetchOnlineRegistryInfo(e,i=!1){if(!i&&this._onlineRegistryQueries.has(e))return await this._onlineRegistryQueries.get(e);const r=(async()=>{const s={method:"GET"};i&&(s.cache="no-store");const a=await(await fetch(e,s)).json(),l=this.validateRegistry(a);return this.ctx.emit("plugin-store/registry-fetched",{ctx:this.ctx,registry:l}),l})();return this._onlineRegistryQueries.set(e,r),await r}async getRegistryCache(e){const i=await this.regInfoDB.get(e);if(i)try{return this.validateRegistry(i)}catch(n){this.ctx.logger.warn("Invalid cached registry",n,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(r=>this.refreshRegistryCache(r))),n={};for(const[r,s]of i.entries())s.status==="fulfilled"?n[e[r]]=s.value:n[e[r]]=null;return n}},bt.PluginStoreSchemas=jr,bt.REGISTRY_INFO_CACHE_TTL=1e3*60*60*24,bt.REGISTRY_INFO_STORAGE_NAME="plugin-store-registry",bt.REGISTRY_ETAG_STORAGE_NAME="psreg-etag",bt);Zo=Ub(rd),Ur=zb(Zo,0,"PluginPluginStore",nd,Ur),Hb(Zo,1,Ur);const Kb=Object.freeze(Object.defineProperty({__proto__:null,PluginPluginStore:Ur},Symbol.toStringTag,{value:"Module"})),nt='@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}.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}',ad={arrayAdd:"+",arrayMoveUp:"↑",arrayMoveDown:"↓",arrayRemove:"×",dictAdd:"+",dictRemove:"×",rootLabel:"root"},ye=(t,e)=>{customElements.get(t)||customElements.define(t,e)},Wb=(t,e,i)=>{if(!e.length)return;let n=t,r=null,s=null;for(let a=0;a<e.length-1;a++){const l=e[a];let c=n?.[l];c==null?(c=typeof e[a+1]=="number"?[]:{},n[l]=c):typeof c!="object"&&(c=typeof e[a+1]=="number"?[]:{},n[l]=c),r=n,s=l,n=c}const o=e[e.length-1];if(n==null||typeof n!="object"){const a=typeof o=="number"?[]:{};if(r)r[s]=a,n=a;else return}try{n[o]=i}catch{try{const a=Array.isArray(n)?n.slice():{...n};a[o]=i,r&&(r[s]=a)}catch{}}},An=t=>t.map(String).join("."),Vb=t=>t.replace(/[^a-zA-Z0-9_-]/g,"_"),ni=t=>`schema_${Vb(An(t)||"root")}`,mi=t=>An(t),ee=(t,...e)=>{const i=new Set(e);i.size&&t.setAttribute("part",Array.from(i).join(" "))},Gb=["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 ea(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}case"const":case"string":default:return e}}function ld(t){return typeof t=="function"&&!!t?.type}function cd(t){if(!t)throw new Error("schema is required");if(ld(t))return t;try{const e=Schema.from(t);if(ld(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 ct(t){return t?.meta??{}}function Qb(t){return t.length>0&&t.every(e=>e?.type==="const")}function yi(t){if(!t)return;const e=t,i=e.meta||{};if(Object.prototype.hasOwnProperty.call(i,"default"))return i.default;const n=e.type;try{const r=t();if(r!==void 0)return r}catch{}switch(n){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 r=e.list||[];return r.length?yi(r[0]):void 0}case"const":return e.value;case"date":return;case"intersect":{const r=e.list||[],s=(a,l)=>{if(Array.isArray(a)&&Array.isArray(l))return l.slice();if(a&&l&&typeof a=="object"&&typeof l=="object"){const c={...a};for(const u of Object.keys(l))c[u]=u in c?s(c[u],l[u]):l[u];return c}return l??a};let o={};for(const a of r)o=s(o,yi(a));return o}default:return}}class yt extends HTMLElement{constructor(){super(),this._path=[],this._i18n=ad,this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=nt,this.$root.appendChild(e)}makeFieldContainer(e,i){const n=document.createElement("div");if(n.className=`field schema-form-item schema-type-${e}`,n.setAttribute("data-path",An(this._path)),ee(n,"field",`field-${e}`),this._label){const r=document.createElement("label");r.className="label",r.textContent=this._label,ee(r,"field-label"),n.appendChild(r)}if(i&&i!==this._label){const r=document.createElement("div");r.className="helper",r.textContent=i,ee(r,"field-helper"),n.appendChild(r)}return n}set schema(e){this._schema=cd(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 ud extends yt{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>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("string",e.description),n=document.createElement("input");this.$input=n,n.className="input",ee(n,"field-input","field-input-text"),n.type="text",n.name=mi(this._path),n.id=ni(this._path),e?.pattern?.source&&(n.pattern=e.pattern.source),e?.max!=null&&(n.maxLength=e.max),n.value=this._value??"",n.oninput=()=>this.emitChange(ea("string",n.value));const r=i.querySelector("label.label");r&&(r.htmlFor=n.id),i.appendChild(n),this.$root.appendChild(i)}}ye("schema-form-string",ud);class dd extends yt{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>${nt}</style>`;const e=this._schema?.type??"number",i=ct(this._schema),n=this.makeFieldContainer("number",i.description),r=document.createElement("input");this.$input=r,r.className="input",ee(r,"field-input","field-input-number"),r.name=mi(this._path),r.id=ni(this._path),i?.min!=null&&(r.min=String(i.min)),i?.max!=null&&(r.max=String(i.max)),i?.step!=null&&(r.step=String(i.step)),e==="percent"&&!r.step&&(r.step="0.01"),r.value=this._value??"",r.oninput=()=>this.emitChange(ea(e,r.value));const s=n.querySelector("label.label");s&&(s.htmlFor=r.id),i.role==="slider"?r.type="range":r.type="number",n.appendChild(r),this.$root.appendChild(n)}}ye("schema-form-number",dd);class fd extends yt{render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("boolean",e.description),n=document.createElement("label");n.className="checkbox",ee(n,"field-checkbox");const r=document.createElement("input");r.type="checkbox",r.checked=!!this._value,r.name=mi(this._path),r.id=ni(this._path),ee(r,"field-input","field-input-checkbox");const s=document.createElement("span");s.textContent=e.description??this._label??"",ee(s,"field-checkbox-text"),r.onchange=()=>this.emitChange(r.checked);const o=i.querySelector("label.label");o&&(o.htmlFor=r.id),n.append(r,s),i.appendChild(n),this.$root.appendChild(i)}}ye("schema-form-boolean",fd);function Fr(t){return String(t).padStart(2,"0")}function On(t){return`${t.getFullYear()}-${Fr(t.getMonth()+1)}-${Fr(t.getDate())}`}function ta(t){return`${Fr(t.getHours())}:${Fr(t.getMinutes())}`}function Br(t){return`${On(t)}T${ta(t)}`}class hd extends yt{render(){if(this.$input&&this.$root.contains(this.$input)){const o=!!this.$root.querySelector("label.label");if(!(this._label&&!o)){const a=ct(this._schema).role||"date";if(document.activeElement!==this.$input)if(this._value instanceof Date)a==="date"?this.$input.value=On(this._value):a==="time"?this.$input.value=ta(this._value):a==="datetime"&&(this.$input.value=Br(this._value));else if(typeof this._value=="string"&&a!=="time"){const l=new Date(this._value);isNaN(+l)||(a==="date"?this.$input.value=On(l):a==="datetime"&&(this.$input.value=Br(l)))}else this._value||(this.$input.value="");return}}this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("date",e.description),n=document.createElement("input");this.$input=n,n.className="input",ee(n,"field-input","field-input-date");const r=e.role||"date";if(r==="datetime"?n.type="datetime-local":r==="time"?n.type="time":n.type="date",n.name=mi(this._path),n.id=ni(this._path),this._value instanceof Date)r==="date"?n.value=On(this._value):r==="time"?n.value=ta(this._value):r==="datetime"&&(n.value=Br(this._value));else if(typeof this._value=="string"&&r!=="time"){const o=new Date(this._value);isNaN(+o)||(r==="date"?n.value=On(o):r==="datetime"&&(n.value=Br(o)))}n.oninput=()=>{e.role;let o;if(!n.value)o=void 0;else{const a=new Date(n.value);o=Number.isNaN(+a)?void 0:a}this.emitChange(o)};const s=i.querySelector("label.label");s&&(s.htmlFor=n.id),i.appendChild(n),this.$root.appendChild(i)}}ye("schema-form-date",hd);class ia extends yt{render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(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),ee(o,"field-const-value"),this.$root.appendChild(o);return}}const n=this.makeFieldContainer("const",e.description),r=document.createElement("section");r.className="const content",r.textContent=String(i),r.id=ni(this._path),ee(r,"field-const-value");const s=n.querySelector("label.label");s&&(s.htmlFor=r.id),n.appendChild(r),this.$root.appendChild(n)}}ye("schema-form-const",ia);class pd extends yt{render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("intersect",e.description);i.classList.remove("field");const n=document.createElement("div");n.classList.add("group"),ee(n,"field-group");const r=this._schema.list||[],s=r.length>0&&r.every(a=>a?.type==="object"),o=(a,l)=>{if(Array.isArray(a)&&Array.isArray(l))return l.slice();if(a&&l&&typeof a=="object"&&typeof l=="object"){const c={...a};for(const u of Object.keys(l))c[u]=u in c?o(c[u],l[u]):l[u];return c}return l??a};if(s){const a=this._value&&typeof this._value=="object"?this._value:{};r.forEach((l,c)=>{const u=l?.meta?.description??"",d=ri(l,this._path,a,u,this._i18n);d.addEventListener("change",y=>{y.stopPropagation();const p=o(this._value??{},y.detail.value);this.emitChange(p)}),n.appendChild(d)})}else{const a=r[r.length-1],l=ri(a,this._path,this._value,this._label,this._i18n);l.addEventListener("change",c=>{c.stopPropagation(),this.emitChange(c.detail.value)}),n.appendChild(l)}i.appendChild(n),this.$root.appendChild(i)}}ye("schema-form-intersect",pd);function Yb(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 ri(t,e,i,n,r){const s=Yb(t),o=document.createElement(s);return o.schema=t,o.path=e,o.label=n,r&&(o.i18n=r),o.setValue?.(i),o.setAttribute("exportparts",Gb),o}class gd extends yt{render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("union",e.description),n=this._schema.list||[];if(Qb(n)){const r=document.createElement("select");r.className="input",ee(r,"field-input","field-input-select"),r.name=mi(this._path),r.id=ni(this._path),n.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),r.appendChild(a)}),r.onchange=()=>this.emitChange(ea("string",r.value));const s=i.querySelector("label.label");s&&(s.htmlFor=r.id),i.appendChild(r)}else{const r=document.createElement("div");r.className="toolbar",ee(r,"field-toolbar");const s=document.createElement("select");s.className="input",ee(s,"field-input","field-input-select","field-toolbar-select"),s.name=mi(this._path)+".__type",s.id=ni(this._path)+"__type";let o=0;n.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=n[o],d=yi(u);this.emitChange(d),c()};const a=i.querySelector("label.label");a&&(a.htmlFor=s.id),r.appendChild(s),i.appendChild(r);const l=document.createElement("div");l.className="group",ee(l,"field-group");const c=()=>{l.innerHTML="";const u=n[o],d=ri(u,this._path,this._value,this._label);d instanceof ia||(d.addEventListener("change",y=>{y.stopPropagation(),this.emitChange(y.detail.value)}),l.appendChild(d))};c(),i.appendChild(l)}this.$root.appendChild(i)}}ye("schema-form-union",gd);class md extends yt{render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("tuple",e.description),n=document.createElement("div");n.className="group",ee(n,"field-group");const r=Array.isArray(this._value)?this._value:[];(this._schema.list||[]).forEach((s,o)=>{const a=ri(s,[...this._path,o],r[o],`${this._label??""}[${o}]`);a.addEventListener("change",l=>{l.stopPropagation();const c=Array.isArray(this._value)?this._value.slice():[];c[o]=l.detail.value,this.emitChange(c)}),n.appendChild(a)}),i.appendChild(n),this.$root.appendChild(i)}}ye("schema-form-tuple",md);class yd extends yt{render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("object",e.description),n=document.createElement("div");n.className="group",ee(n,"field-group");const r=this._schema.dict||{};Object.keys(r).forEach(s=>{if(r[s]?.meta?.hidden)return;const o=(this._value??{})[s],a=ri(r[s],[...this._path,s],o,s);a.addEventListener("change",l=>{l.stopPropagation();const c={...this._value??{}};c[s]=l.detail.value,this.emitChange(c)}),n.appendChild(a)}),i.appendChild(n),this.$root.appendChild(i)}}ye("schema-form-object",yd);const rs=class rs extends yt{constructor(){super(...arguments),this._itemIds=[]}generateItemId(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return"i"+rs._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(n=>{const r=n.dataset.uid;r&&(i[r]=n.getBoundingClientRect())}),i}playFLIP(e,i){Array.from(e.querySelectorAll(".row")).forEach(n=>{const r=n.dataset.uid;if(!r)return;const s=i[r];if(!s)return;const o=n.getBoundingClientRect(),a=s.left-o.left,l=s.top-o.top;(a||l)&&(n.style.transition="none",n.style.transform=`translate(${a}px, ${l}px)`,requestAnimationFrame(()=>{n.style.transition="transform .25s ease",n.style.transform=""}))})}render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("array",e.description),n=document.createElement("div");n.className="group",ee(n,"field-group");const r=this._schema.inner,s=()=>Array.isArray(this._value)?this._value:[];this.ensureItemIds(s().length);const o=(c,u)=>{n.innerHTML="",s().forEach((d,y)=>{const p=[...this._path,y],f=document.createElement("div");f.className="row schema-collection-row",ee(f,"field-row","collection-row");const w=this._itemIds[y];f.dataset.uid=w,f.setAttribute("data-path",An(p));const x=ri(r,p,d,`${this._label??""}[${y}]`);x.addEventListener("change",b=>{b.stopPropagation();const k=s().slice();k[y]=b.detail.value,this._value=k,this.emitChange(k)});const S=document.createElement("div");S.className="actions",ee(S,"field-actions");const I=document.createElement("button");I.type="button",I.className="btn",ee(I,"field-button","field-button-secondary"),I.textContent=this._i18n.arrayMoveUp??"↑",I.onclick=()=>{if(y<=0)return;const b=this.capturePositions(n),k=s().slice();[k[y-1],k[y]]=[k[y],k[y-1]],[this._itemIds[y-1],this._itemIds[y]]=[this._itemIds[y],this._itemIds[y-1]],this._value=k,o(b),this.emitChange(k)};const m=document.createElement("button");m.type="button",m.className="btn",ee(m,"field-button","field-button-secondary"),m.textContent=this._i18n.arrayMoveDown??"↓",m.onclick=()=>{const b=s();if(y>=b.length-1)return;const k=this.capturePositions(n),P=b.slice();[P[y+1],P[y]]=[P[y],P[y+1]],[this._itemIds[y+1],this._itemIds[y]]=[this._itemIds[y],this._itemIds[y+1]],this._value=P,o(k),this.emitChange(P)};const g=document.createElement("button");g.type="button",g.className="btn danger",ee(g,"field-button","field-button-danger"),g.textContent=this._i18n.arrayRemove??"×",g.onclick=()=>{f.classList.add("leaving");const b=250;let k=!1;const P=()=>{if(k)return;k=!0,clearTimeout(L);const C=s().filter((H,ze)=>ze!==y);this._itemIds.splice(y,1);const U=this.capturePositions(n);this._value=C,o(U),this.emitChange(C)};f.addEventListener("transitionend",P,{once:!0});const L=setTimeout(P,b+80)},S.append(I,m,g),f.appendChild(x),f.appendChild(S),n.appendChild(f),u&&u===w&&(f.classList.add("enter"),requestAnimationFrame(()=>{f.classList.add("enter-active")}),requestAnimationFrame(()=>{f.classList.remove("enter")}))}),c&&this.playFLIP(n,c)};o();const a=document.createElement("button");a.type="button",a.className="btn primary",ee(a,"field-button","field-button-primary"),a.textContent=this._i18n.arrayAdd??"+",a.onclick=()=>{const c=this.capturePositions(n),u=s().slice(),d=yi(r);u.push(d);const y=this.generateItemId();this._itemIds.push(y),this._value=u,o(c,y),this.emitChange(u)};const l=document.createElement("div");l.className="actions",ee(l,"field-actions"),l.appendChild(a),i.appendChild(n),i.appendChild(l),this.$root.appendChild(i)}};rs._idCounter=0;let qr=rs;ye("schema-form-array",qr);class bd extends yt{render(){this.$root.innerHTML=`<style>${nt}</style>`;const e=ct(this._schema),i=this.makeFieldContainer("dict",e.description),n=document.createElement("div");n.className="group",ee(n,"field-group");const r=this._schema.inner,s=this._value??{},o=y=>`d_${y}`,a=()=>{const y={};return n.querySelectorAll(".kv").forEach(p=>{const f=p.dataset.uid;f&&(y[f]=p.getBoundingClientRect())}),y},l=y=>{n.querySelectorAll(".kv").forEach(p=>{const f=p.dataset.uid;if(!f)return;const w=y[f];if(!w)return;const x=p.getBoundingClientRect(),S=w.left-x.left,I=w.top-x.top;(S||I)&&(p.style.transition="none",p.style.transform=`translate(${S}px, ${I}px)`,requestAnimationFrame(()=>{p.style.transition="transform .25s ease",p.style.transform=""}))})},c=(y,p)=>{n.innerHTML="",Object.keys(s).forEach(f=>{const w=[...this._path,f],x=document.createElement("div");x.className="kv schema-collection-row",ee(x,"field-row","collection-row"),x.dataset.uid=o(f),x.setAttribute("data-path",An(w));const S=document.createElement("input");S.className="input",ee(S,"field-input","field-input-text"),S.value=f,S.name=mi(w)+".__key",S.id=ni(w)+"__key";const I=ri(r,w,s[f],`${this._label??""}[${f}]`),m=document.createElement("button");m.type="button",m.className="btn danger",ee(m,"field-button","field-button-danger"),m.textContent=this._i18n.dictRemove??"×",m.onclick=()=>{const g=a();delete s[f];const b={...this._value??{}};delete b[f],this._value=b,c(g),this.emitChange(b)},S.onchange=()=>{const g=S.value.trim();if(!g||g===f||s[g]!==void 0)return;const b=a();s[g]=s[f],delete s[f];const k={...this._value??{}};k[g]=k[f],delete k[f],this._value=k,c(b),this.emitChange(k)},I.addEventListener("change",g=>{g.stopPropagation();const b={...this._value??{}};b[f]=g.detail.value,this._value=b,this.emitChange(b)}),x.append(S,I,m),n.appendChild(x),p===f&&(x.classList.add("enter"),requestAnimationFrame(()=>x.classList.add("enter-active")),requestAnimationFrame(()=>x.classList.remove("enter")))}),y&&l(y)};c();const u=document.createElement("button");u.type="button",u.className="btn primary",ee(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 f=a();s[p]=yi(r);const w={...this._value??{},[p]:s[p]};this._value=w,c(f,p),this.emitChange(w)};const d=document.createElement("div");d.className="actions",ee(d,"field-actions"),d.appendChild(u),i.appendChild(n),i.appendChild(d),this.$root.appendChild(i)}}ye("schema-form-dict",bd);class vd extends HTMLElement{constructor(){super(),this._i18n={...ad},this._i18nCommitted=!1,this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=nt,this.$root.appendChild(e);const i=document.createElement("div");i.className="wrapper",ee(i,"wrapper");const n=document.createElement("form");n.className="form",ee(n,"form"),i.appendChild(n),this.$root.appendChild(i),this.addEventListener("change",r=>{if(!r?.detail)return;const{path:s,value:o}=r.detail;Array.isArray(s)&&s.length===0?this._state=o:Wb(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=cd(e);try{this._state=this._schema(null,{autofix:!0})}catch{this._state=yi(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 n=i.validate?this._schema(e??null,{autofix:i.autofix}):e;this._state=n,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=yi(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=ri(this._schema,[],this._state,this._i18n.rootLabel,this._i18n);e.appendChild(i)}}ye("schema-form",vd);function Xb(){ye("schema-form",vd),ye("schema-form-string",ud),ye("schema-form-number",dd),ye("schema-form-boolean",fd),ye("schema-form-date",hd),ye("schema-form-const",ia),ye("schema-form-union",gd),ye("schema-form-tuple",md),ye("schema-form-object",yd),ye("schema-form-array",qr),ye("schema-form-dict",bd),ye("schema-form-intersect",pd)}const Jb=pi({__name:"SchemasteryFormVue",props:eu({schema:{},value:{},validateOnChange:{type:Boolean,default:!1}},{schema:{required:!0},schemaModifiers:{},value:{required:!1,default:{}},valueModifiers:{}}),emits:eu(["change"],["update:schema","update:value"]),setup(t,{expose:e,emit:i}){const n=_u(t,"schema"),r=_u(t,"value"),s=i,o=Gc("elRef");let a=!1,l=!1;const c=u=>{if(l)return;const d=o.value,y=t.validateOnChange?d.getData({validate:!0}):u.detail.state;a=!0,r.value=y,bn(()=>{a=!1}),s("change",u.detail)};return Jc(()=>{Xb()}),xn(()=>{const u=o.value;n.value&&(u.schema=n.value),r.value!==void 0&&u.setData(r.value,{validate:!1,autofix:!0}),u.addEventListener("form-change",c)}),Ro(()=>{o.value?.removeEventListener("form-change",c)}),Ui(n,u=>{a||o.value&&u&&o.value.schema!==u&&(l=!0,o.value.schema=u,bn(()=>{l=!1}))},{deep:!0,immediate:!0}),Ui(r,u=>{if(a||!o.value||u===void 0)return;const d=o.value.getData({validate:!1});JSON.stringify(d)!==JSON.stringify(u)&&(l=!0,o.value.setData(u,{validate:!1}),bn(()=>{l=!1}))},{deep:!0,immediate:!0}),e({setData(u,d){const y=o.value;y.setData(u,{validate:!!d?.validate}),d?.emit&&(r.value=y.getData({validate:!!d?.validate}))},getData(u){return o.value.getData(u)},setSchema(u,d=!0){o.value.schema=u,d&&(n.value=u)},refresh(){o.value.refresh()},reset(){o.value.reset()},el:o}),(u,d)=>(oe(),fe("schema-form",Iu({ref_key:"elRef",ref:o},u.$attrs),null,16))}});function bi(t,e=new WeakMap){if(Ie(t))return bi(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 r=new Map;return e.set(t,r),Array.from(t.entries()).forEach(([s,o])=>{r.set(s,bi(o,e))}),r}if(t instanceof Set){const r=new Set;return e.set(t,r),Array.from(t).forEach(s=>{r.add(bi(s,e))}),r}if(Array.isArray(t)){const r=[];e.set(t,r);for(const s of t)r.push(bi(s,e));return r}const i=ie(t),n={};e.set(t,n);for(const r of Object.keys(i))n[r]=bi(i[r],e);for(const r of Object.getOwnPropertySymbols(i))n[r]=bi(i[r],e);return n}const na=()=>{},Zb={id:"preferences-ui-app"},ev={class:"tabbar"},tv={class:"tabbar-tabs"},iv=["onClick","data-value"],nv={class:"tabbar-content"},rv={key:0},sv={style:{"max-height":"20em",overflow:"auto"}},ov=pi({__name:"PreferencesApp",setup(t,{expose:e}){const i=Xo(),n=!1,r=Dc([]),s=Fe([]),o=Fe(""),a=Ot(()=>s.value.find(f=>f.name===o.value)||null),l=Ot(()=>{const f=r.value.filter(w=>w.category===o.value).map(w=>w.schema);return f.length===0?null:R.intersect(f)}),c=Ot(()=>a.value&&typeof a.value.autoGenerateForm=="boolean"?a.value.autoGenerateForm:!0),u=Fe({});e({getValue(){return bi(u)},mergeValue(f){u.value={...u.value,...f}},selectTab(f){o.value=f}}),xn(async()=>{i.inject(["preferences"],async f=>{const w=await f.preferences.getAll();u.value=w,s.value=f.preferences.getConfigCategories(),r.value=f.preferences.getConfigRegistries(),o.value=s.value[0].name})});const d=(f,w)=>{f.preventDefault(),o.value=w;const x=f.currentTarget;x&&x.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},y=Gc("customRenderContainerRef"),p=Fe([]);return Io(()=>{p.value.forEach(f=>f()),p.value=[]}),Ui(a,async f=>{p.value.forEach(x=>x()),p.value=[],await bn();const w=y.value;if(w&&(w.innerText="",f&&typeof f.customRenderer=="function")){let x=na;const S=g=>{x=g},I=g=>{p.value.push(g)},m=await f.customRenderer({ctx:i,onMounted:S,onUnmount:I});m&&(w.appendChild(m),x?.(w))}},{immediate:!0,deep:!1}),(f,w)=>(oe(),fe("div",Zb,[J("div",ev,[J("div",tv,[(oe(!0),fe(He,null,Ao(s.value,x=>(oe(),fe("a",{class:gt(["tab",{active:o.value===x.name}]),key:x.name,onClick:S=>d(S,x.name),"data-value":x.name},ue(x.label),11,iv))),128))]),J("div",nv,[a.value&&a.value.customRenderer?(oe(),fe("div",{class:"custom-render-container",ref_key:"customRenderContainerRef",ref:y,key:o.value})):ti("",!0),c.value&&l.value?(oe(),Tr(Se(Jb),{class:"auto-schema-form",key:o.value,"data-category":o.value,schema:l.value,value:u.value,"onUpdate:value":w[0]||(w[0]=x=>u.value={...u.value,...x}),"validate-on-change":!1,i18n:{rootLabel:""}},null,8,["data-category","schema","value"])):ti("",!0)])]),Se(n)?(oe(),fe("details",rv,[J("pre",sv,ue(u.value),1)])):ti("",!0)]))}}),Hr=(t,e)=>{const i=t.__vccOpts||t;for(const[n,r]of e)i[n]=r;return i},av=Hr(ov,[["__scopeId","data-v-7f07706b"]]);var lv=Object.create,ra=Object.defineProperty,cv=Object.getOwnPropertyDescriptor,wd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),_d=t=>{throw TypeError(t)},uv=(t,e,i)=>e in t?ra(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,dv=(t,e)=>ra(t,"name",{value:e,configurable:!0}),fv=t=>[,,,lv(t?.[wd("metadata")]??null)],hv=["class","method","getter","setter","accessor","field","value","get","set"],xd=t=>t!==void 0&&typeof t!="function"?_d("Function expected"):t,pv=(t,e,i,n,r)=>({kind:hv[t],name:e,metadata:n,addInitializer:s=>i._?_d("Already initialized"):r.push(xd(s||null))}),gv=(t,e)=>uv(e,wd("metadata"),t[3]),mv=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},yv=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&cv(r,i));dv(r,i);for(var f=n.length-1;f>=0;f--)l=pv(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,xd(o)&&(r=o);return gv(t,r),p&&ra(r,i,p),u?c^4?s:p:r},kd,sa,Sd;kd=[be(["preferences","modal","$","$$"])];class zr extends(Sd=Ae){constructor(e){super(e,{},"preferences-ui"),this.ctx=e,this._modal=null,this._form=null,e.set("preferencesUI",this);const i=e.$,n=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:n`prefs.about.label`,description:n`prefs.about.description`,index:99,customRenderer:()=>h("section",{className:"theme-ipe-prose",children:[h("h2",{children:"✏️ InPageEdit NEXT"}),h("p",{children:n`prefs.about.intro`}),h("h3",{children:n`prefs.about.portals.header`}),h("ul",{children:[h("li",{children:h("a",{href:this.ctx.Endpoints.HOME_URL,target:"_blank",children:n`prefs.about.portals.officialwebsite`})}),h("li",{children:h("a",{href:`${this.ctx.Endpoints.UPDATE_LOGS_URL}#${this.ctx.version.split("-")[0]}`,target:"_blank",children:n`prefs.about.portals.updatelogs`})})]}),h("h3",{children:n`prefs.about.joinus.header`}),h("ul",{children:[h("li",{children:[h("strong",{children:n`prefs.about.joinus.github`}),":"," ",h("a",{href:this.ctx.Endpoints.GITHUB_URL,target:"_blank",children:`${this.ctx.Endpoints.GITHUB_OWNER}/${this.ctx.Endpoints.GITHUB_REPO}`})]}),h("li",{children:[h("strong",{children:n`prefs.about.joinus.qqgroup`}),": ",this.ctx.Endpoints.QQ_GROUP_ID]})]}),h("hr",{}),h("p",{style:{textAlign:"center"},children:n`prefs.about.copyright`}),h("hr",{})]})}),e.inject(["toolbox"],r=>{r.toolbox.addButton({id:"preferences",icon:h("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:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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(()=>z_).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:h(ai,{children:h(ui,{})})});i.get$window().classList.add("dialog");const n=h("div",{id:"ipe-preferences-app",style:{minHeight:"calc(85dvh - var(--ipe-modal-spacing) * 2)"}});i.setContent(n),this.ctx.emit("preferences-ui/modal-shown",{ctx:this.ctx,modal:i});const r=this.createPreferencesUIApp(),s=r.mount(n);return this._form=s,this.ctx.emit("preferences-ui/vue-app-mounted",{ctx:this.ctx,app:r,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:h("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"),r.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 Zu(this.ctx,av)}}sa=fv(Sd),zr=yv(sa,0,"PluginPreferencesUI",kd,zr),mv(sa,1,zr);const bv=Object.freeze(Object.defineProperty({__proto__:null,get PluginPreferencesUI(){return zr}},Symbol.toStringTag,{value:"Module"})),vv=Symbol("@@apply"),wv=Symbol("@@ctor");function $d(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[vv]=i,i[wv]=t;const n=t?.constructor?.name;return n&&(i[Symbol.toStringTag]=n),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 Kr={mbox:"_mbox_5x43w_1",title:"_title_5x43w_12",content:"_content_5x43w_19",close:"_close_5x43w_27"},oa=t=>{const{type:e="default",title:i,content:n,closeable:r=!0,titleProps:s,contentProps:o,children:a,...l}=t;let c=i;typeof i>"u"&&e!=="default"&&(c=e[0].toUpperCase()+e.slice(1).toLowerCase());const u=async()=>{if(!d)return Promise.resolve();const{promise:y,resolve:p}=Promise.withResolvers();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=h("div",{className:`theme-ipe ipe-mbox mbox-type-${e||"default"} ${Kr.mbox}`,...l,children:[c&&h("div",{className:`ipe-mbox-title ${Kr.title}`,...s,children:c}),h("div",{className:`ipe-mbox-content ${Kr.content}`,...o,children:a||n}),r&&h("a",{onClick:u,className:`ipe-mbox-close ${Kr.close}`,children:"×"})]});return d.close=u,d},vi=t=>{const{label:e,id:i,name:n,value:r,placeholder:s,disabled:o,required:a,labelProps:l,inputProps:c,children:u,...d}=t;return h("div",{className:"theme-ipe ipe-input-box",...d,children:[h("label",{htmlFor:i,style:{display:"block"},...l,children:[e,a&&h(ai,{children:[" ",h("span",{className:"required",children:"*"})]})]}),u??h("input",{id:i,name:n,value:r,disabled:o,placeholder:s,required:a,style:{width:"100%"},...c})]})},_v=t=>{const{id:e,name:i,value:n,label:r,inputProps:s,labelProps:o,children:a,...l}=t;return h("label",{className:"theme-ipe ipe-radio-box",...l,children:[h("input",{type:"radio",id:e,name:i,value:n,...s}),h("span",{className:"ipe-checkbox-box"}),h("span",{...o,children:r||a})]})},wi=t=>{const{id:e,name:i,label:n,checked:r,inputProps:s,labelProps:o,children:a,...l}=t;return h("label",{className:"theme-ipe ipe-checkbox",...l,children:[h("input",{type:"checkbox",id:e,name:i,checked:r,...s}),h("span",{className:"ipe-checkbox-box"}),h("span",{...o,children:n||a})]})},xv=(t=0)=>new Promise(e=>setTimeout(e,t)),Ed=t=>h("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:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),h("path",{d:"M13.5 6.5l4 4"}),h("path",{d:"M19 16l-2 3h4l-2 3"})]});var kv=Object.create,aa=Object.defineProperty,Sv=Object.getOwnPropertyDescriptor,Pd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Cd=t=>{throw TypeError(t)},$v=(t,e,i)=>e in t?aa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ev=(t,e)=>aa(t,"name",{value:e,configurable:!0}),Pv=t=>[,,,kv(t?.[Pd("metadata")]??null)],Cv=["class","method","getter","setter","accessor","field","value","get","set"],Rd=t=>t!==void 0&&typeof t!="function"?Cd("Function expected"):t,Rv=(t,e,i,n,r)=>({kind:Cv[t],name:e,metadata:n,addInitializer:s=>i._?Cd("Already initialized"):r.push(Rd(s||null))}),Iv=(t,e)=>$v(e,Pd("metadata"),t[3]),Av=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Ov=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Sv(r,i));Ev(r,i);for(var f=n.length-1;f>=0;f--)l=Rv(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,Rd(o)&&(r=o);return Iv(t,r),p&&aa(r,i,p),u?c^4?s:p:r},Id,la,Ad;Id=[be(["api","wikiPage","wikiTitle","currentPage","wiki","modal","preferences","$"]),Ut(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(pt.preferences).description("Follow MW preferences"),R.const(pt.nochange).description("Keep the current watchlist status"),R.const(pt.watch).description("Add the page to watchlist"),R.const(pt.unwatch).description("Remove the page from watchlist")]).description("Watchlist options").default(pt.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 Wr=(xi=class extends(Ad=Ae){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",$d(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),b=this.ctx.currentPage.wikiTitle;e={...e,title:b?.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 n=await this.ctx.preferences.get("quickEdit.outSideClose"),r=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(),l={...this.DEFAULT_OPTIONS,editSummary:s,editMinor:o,...e};l.editSummary||(l.editSummary=await this.ctx.preferences.get("quickEdit.editSummary")||""),this.ctx.emit("quick-edit/init-options",{ctx:this.ctx,options:l});const c=this.ctx.modal.createObject({className:"ipe-quickEdit",sizeClass:"large",center:!1,outSideClose:n}).init();c.setTitle(h(ai,{children:["Loading: ",h("u",{children:l.title})]})),c.setContent(h("section",{className:"ipe-quickEdit-loading",style:{height:"70vh",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:h(ui,{})})),c.addButton({side:"right",type:"button",className:"is-danger is-ghost",label:i`Cancel`,method(){c.close()}}),c.show(),this.ctx.emit("quick-edit/show-modal",{ctx:this.ctx,modal:c,options:l});let u;try{if(u=await this.getWikiPageFromPayload(l),u.pageInfo.special)throw new Error(i`Special page is not editable.`)}catch(g){c.off(c.Event.Close),c.close(),this.ctx.modal.notify("error",{content:g instanceof Error?g.message:String(g)});return}const d=l.section==="new"?"":u.revisions[0]?.content||"",y=u.revisions[0]?.revid,p=y&&y!==u.lastrevid,f=l.section==="new",w=u.pageid===0;c.setTitle(h(ai,{children:[f?i`New Section`:i`Quick ${w?"Create":"Edit"}`,": ",h("u",{children:u.pageInfo.title}),p?` (${i`Revision`} ${y})`:""]}));const x=[];w&&x.push(h(oa,{title:i`Attention`,type:"important",children:h("p",{children:i`This page does not exist.`})})),p&&x.push(h(oa,{title:i`Attention`,type:"warning",children:h("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:l,modal:c,wikiPage:u,editNotices:x});const S=h("form",{className:"ipe-quickEdit__form",children:[h("div",{className:"ipe-quickEdit__notices",children:x}),h("div",{className:"ipe-quickEdit__content",style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[l.section==="new"&&h(ai,{children:h(vi,{label:i`Section title`,id:"summary",name:"summary",value:"",inputProps:{placeholder:i`Topic for new section, this will be the h2 heading`}})}),h("textarea",{className:`ipe-quickEdit__textarea ${a.className}`,style:{fontFamily:a.fontFamily},name:"text",id:"wpTextbox1",children:d})]}),h("div",{class:"ipe-quickEdit__options",style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[!f&&h(vi,{label:i`Summary`,id:"summary",name:"summary",value:l.editSummary}),h("div",{className:"ipe-input-box",children:[h("label",{htmlFor:"watchlist",style:{display:"block"},children:i`Watchlist`}),h("div",{style:{display:"flex",gap:"1rem",whiteSpace:"nowrap",overflowX:"auto"},children:[pt.preferences,pt.nochange,pt.watch,pt.unwatch].map(g=>h(_v,{name:"watchlist",value:g,inputProps:{checked:r===g,onChange:b=>{b.target&&b.target.closest("label")?.scrollIntoView({behavior:"smooth",inline:"center"})}},children:i`watchlist.${g}`},g))})]}),h("div",{style:{display:"flex",gap:"1rem"},children:[h(wi,{name:"minor",id:"minor",checked:l.editMinor,children:i`Minor edit`}),h(wi,{name:"reloadAfterSave",id:"reloadAfterSave",checked:l.reloadAfterSave,children:i`Reload after save`})]})]}),!1]});c.setContent(S);let I=!1;c.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(S);c.setLoadingState(!0);try{await this.handleSubmit({wikiPage:u,text:g.get("text"),summary:g.get("summary"),minor:g.get("minor")==="on",section:l.section,watchlist:r,createonly:u.pageid===0&&!I,recreate:u.pageid===0&&I}),c.setOptions({beforeClose:na}),c.close(),this.ctx.modal.notify("success",{title:i`Submission Successful`,content:i`Your changes have been saved.`}),g.get("reloadAfterSave")&&(await xv(500),location.reload())}catch(b){if(c.setLoadingState(!1),Yt.is(b)&&(b.code==="pagedeleted"||b.code==="editconflict"||b.code==="articleexists")){I=!0,this.ctx.modal.notify("warning",{title:i`Submission Error`,content:h("div",{children:[h("p",{children:h("strong",{children:b.message})}),h("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:b instanceof Error?b.message:String(b)})}}},0),c.setOptions({beforeClose:()=>{const g=u.revisions[0]?.content||"";return(S.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"}},k=>(k&&(c.setOptions({beforeClose:na}),c.close()),!0)),!1)}}),this.ctx.emit("quick-edit/wiki-page",{ctx:this.ctx,options:l,modal:c,wikiPage:u});const m=g=>S.querySelector("textarea")?.value===d?!0:(g.preventDefault(),i`You have unsaved changes. Are you sure you want to leave?`);window.addEventListener("beforeunload",m),c.on(c.Event.Close,()=>{window.removeEventListener("beforeunload",m)})}async handleSubmit(e){const{wikiPage:i,...n}=e;return this.ctx.emit("quick-edit/submit",{ctx:this.ctx,wikiPage:i,...n}),i.edit({...n})}async getEditFontOptions(){const e=await this.ctx.preferences.get("quickEdit.editFont");return xi.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,n=this.ctx.currentPage.wikiTitle,r=n&&n.getNamespaceId()>=0;e.toolbox.addButton({id:"quick-edit",group:"group1",index:0,icon:h("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:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1"}),h("path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z"}),h("path",{d:"M16 5l3 3"})]}),buttonProps:{disabled:!r},tooltip:()=>r?i`Quick Edit`:i`Not editable`,onClick:()=>{const s=new URLSearchParams(window.location.search).get("oldid");this.showModal({title:n?.getPrefixedText(),revision:s?Number(s):void 0})}})}removeToolbox(e){e.toolbox.removeButton("quick-edit")}createQuickEditButton(e,i){const{$:n}=this.ctx,r=i?.icon??h(Ed,{className:"ipe-icon"}),s=i?.label??n`Quick Edit`;return h("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:[r,s]})}},xi.BUILT_IN_FONT_OPTIONS=["preferences","monospace","sans-serif","serif"],xi);la=Pv(Ad),Wr=Ov(la,0,"PluginQuickEdit",Id,Wr),Av(la,1,Wr);const Tv=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickEdit:Wr},Symbol.toStringTag,{value:"Module"})),Tn={twinSwapInput:"_twinSwapInput_1gdgl_9",inputWrapper:"_inputWrapper_1gdgl_23",inputLeft:"_inputLeft_1gdgl_27",inputRight:"_inputRight_1gdgl_30",swapButton:"_swapButton_1gdgl_46"},Od=t=>{const{inputs:e,enableSwap:i=!0,...n}=t,r=e?.length===2?e:[e?.[0]??{},e?.[1]??{}],s=[null,null];let o=0,a=null,l=null;const c=()=>s.some(f=>f&&f.disabled),u=()=>{if(!s[0]||!s[1]||c())return;const f=s[0],w=s[1],x=f.value,S=w.value;f.value=S,w.value=x,f.dispatchEvent(new Event("change")),w.dispatchEvent(new Event("change")),o++,l&&(l.style.transform=`rotateY(${o*-180}deg)`,l.style.transition="transform 200ms ease")},d=f=>{if(!a)return;const w=f??!a.disabled;a.disabled=!w,w&&s.forEach(x=>{x&&(x.disabled=!1)})},y=h("button",{type:"button","aria-label":"Swap values",onClick:u,disabled:c()||!i,ref:f=>a=f,children:h("svg",{ref:f=>l=f,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:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 10h-16l5.5 -6"}),h("path",{d:"M4 14h16l-5.5 6"})]})}),p=h("div",{className:`twin-swap-input ${Tn.twinSwapInput}`,...n,children:[r.map((f,w)=>{const{label:x,id:S,name:I,value:m,disabled:g,required:b,inputProps:k}=f,P=w===0,L=S||I;return h("div",{className:`${Tn.inputWrapper} ${P?Tn.inputLeft:Tn.inputRight}`,children:[x&&h("label",{htmlFor:L,children:x}),h("input",{ref:C=>s[w]=C,type:"text",id:L,name:I,value:m,disabled:g,required:b,...k})]})}),h("div",{className:Tn.swapButton,children:y})]});return p.swap=u,p.toggleEnableSwap=d,p};var Lv=Object.create,ca=Object.defineProperty,Nv=Object.getOwnPropertyDescriptor,Td=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ld=t=>{throw TypeError(t)},Mv=(t,e,i)=>e in t?ca(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Dv=(t,e)=>ca(t,"name",{value:e,configurable:!0}),jv=t=>[,,,Lv(t?.[Td("metadata")]??null)],Uv=["class","method","getter","setter","accessor","field","value","get","set"],Nd=t=>t!==void 0&&typeof t!="function"?Ld("Function expected"):t,Fv=(t,e,i,n,r)=>({kind:Uv[t],name:e,metadata:n,addInitializer:s=>i._?Ld("Already initialized"):r.push(Nd(s||null))}),Bv=(t,e)=>Mv(e,Td("metadata"),t[3]),qv=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Hv=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Nv(r,i));Dv(r,i);for(var f=n.length-1;f>=0;f--)l=Fv(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,Nd(o)&&(r=o);return Bv(t,r),p&&ca(r,i,p),u?c^4?s:p:r},Md,ua,Dd;Md=[Ut(R.object({"quickMove.reason":R.string().default("[IPE-NEXT] Quick move")}).description("Quick move options").extra("category","editor")),be(["modal","wiki","$"])];class Vr extends(Dd=Ae){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.$,n=window.mw?.config.get("wgPageName")||"",r=window.mw?.config.get("wgIsProbablyEditable");e.toolbox.addButton({id:"quick-move",icon:h("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:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3"}),h("path",{d:"M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3"}),h("path",{d:"M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7"}),h("path",{d:"M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1"}),h("path",{d:"M17 12h.01"}),h("path",{d:"M13 12h.01"})]}),tooltip:()=>i`Quick Move`,group:"group1",index:1,onClick:()=>{this.showModal(r?{lockFromField:!0,from:n}:{})}})}async showModal(e){const{$:i}=this.ctx,n=await this.ctx.preferences.get("quickMove.reason"),r=this.ctx.modal.createObject({title:i`Quick Move`,content:h(ui,{}),className:"quick-move compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let s=null;return r.setContent(h("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),l={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(!l.from||!l.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:r,payload:l}),r.setLoadingState(!0),this.movePage(l).then(()=>{location.reload()}).catch(c=>{r.setLoadingState(!1),this.ctx.modal.notify("error",{title:i`Failed to move`,content:c instanceof Error?c.message:String(c)})})},children:[h(Od,{inputs:[{label:i`Move from`,name:"from",value:e?.from,required:!0},{label:i`Move to`,name:"to",value:e?.to,required:!0}]}),h("div",{children:h(wi,{name:"movetalk",id:"movetalk",checked:e?.movetalk,children:i`Move talk page`})}),h("div",{children:h(wi,{name:"movesubpages",id:"movesubpages",checked:e?.movesubpages,children:i`Move subpages (up to 100)`})}),this.ctx.wiki.hasRight("suppressredirect")&&h("div",{children:h(wi,{name:"noredirect",id:"noredirect",checked:e?.noredirect,children:i`Move without leaving a redirect`})}),h(vi,{label:i`Reason`,id:"reason",name:"reason",value:e?.reason??n??""})]})),r.setButtons([{label:i`Move`,className:"is-primary is-ghost",method:()=>{s?.dispatchEvent(new Event("submit"))}}]),r.show()}async movePage(e){const{from:i,to:n,reason:r="",...s}=e;if(!i||!n)throw new Error("From and to titles are required.");if(i===n)throw new Error("From and to titles cannot be the same.");return(await this.ctx.wikiPage.newFromTitle(i)).moveTo(n,r,s)}}ua=jv(Dd),Vr=Hv(ua,0,"PluginQuickMove",Md,Vr),qv(ua,1,Vr);const zv=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickMove(){return Vr}},Symbol.toStringTag,{value:"Module"}));var Kv=Object.create,da=Object.defineProperty,Wv=Object.getOwnPropertyDescriptor,jd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ud=t=>{throw TypeError(t)},Vv=(t,e,i)=>e in t?da(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Gv=(t,e)=>da(t,"name",{value:e,configurable:!0}),Qv=t=>[,,,Kv(t?.[jd("metadata")]??null)],Yv=["class","method","getter","setter","accessor","field","value","get","set"],Fd=t=>t!==void 0&&typeof t!="function"?Ud("Function expected"):t,Xv=(t,e,i,n,r)=>({kind:Yv[t],name:e,metadata:n,addInitializer:s=>i._?Ud("Already initialized"):r.push(Fd(s||null))}),Jv=(t,e)=>Vv(e,jd("metadata"),t[3]),Zv=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},ew=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Wv(r,i));Gv(r,i);for(var f=n.length-1;f>=0;f--)l=Xv(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,Fd(o)&&(r=o);return Jv(t,r),p&&da(r,i,p),u?c^4?s:p:r},Bd,fa,qd;Bd=[be(["api","wikiPage","modal","preferences","$"]),Ut(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 Gr extends(qd=Ae){constructor(e){super(e,{},"quickPreview"),this.ctx=e,this._contentTypeCache=new Map,this._objectUrls=new WeakMap,this.ctx.set("quickPreview",$d(this,"previewWikitext"))}start(){this.ctx.on("quick-edit/wiki-page",this.injectQuickEdit.bind(this))}stop(){}previewWikitext(e,i,n,r,s){const{$:o}=this.ctx;return n||(n=this.ctx.wikiPage.newBlankPage({title:"API"})),(!r||r.isDestroyed)&&(r=this.ctx.modal.createObject({className:"in-page-edit ipe-quickPreview",sizeClass:"large",center:!1,...s}).init()),r.show(),r.setTitle(o`Preview - Loading...`),r.setContent(h(ui,{})),r.bringToFront(),this.ctx.emit("quick-preview/show-modal",{ctx:this.ctx,text:e,modal:r,wikiPage:n}),n.preview(e,i).then(a=>{const{data:{parse:l}}=a;r.setTitle(o(l.title)`Preview - {{ $1 }}`);let c=null;r.setContent(h("section",{children:h("div",{ref:u=>c=u,className:"mw-parser-output",innerHTML:l.text})})),window.mw?.hook&&typeof jQuery=="function"&&window.mw.hook("wikipage.content").fire(jQuery(c)),this.ctx.emit("quick-preview/loaded",{ctx:this.ctx,modal:r,wikiPage:n,text:e,parseData:l})}).catch(a=>{r.setTitle(o`Preview - Failed`),r.setContent(h(ai,{children:[h("p",{children:o`Failed to preview`}),h("p",{children:a instanceof Error?a.message:String(a)})]}))}),r}async injectQuickEdit({options:e,modal:i,wikiPage:n}){const{$:r}=this.ctx;let s;i.addButton({label:r`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,n,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 n=fetch(e,{method:"HEAD"}).then(r=>r.headers.get("content-type")||"").catch(()=>(this._contentTypeCache.delete(e),""));return this._contentTypeCache.set(e,n),n}async getPreviewType(e){if(!e)return"unknown";let i,n;if(e instanceof File)i=e.type,n=e.name.split(".").pop()?.toLowerCase()||"";else{const r=new URL(e,location.origin);r.protocol==="data:"||r.protocol==="blob:"||r.protocol.startsWith("http")?i=await this.fetchContentType(r.href):i="",n=r.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":n==="md"?"markdown":i.startsWith("text/")?"text":["jpg","jpeg","png","gif","bmp","tiff","ico","webp"].includes(n)?"image":["mp4","webm","ogg","flv","avi","mov","wmv","mkv"].includes(n)?"video":["mp3","wav","ogg","flac","aac","m4a","wma"].includes(n)?"audio":["html","htm"].includes(n)?"html":["json","yml","yaml","toml","py"].includes(n)?"text":["pdf"].includes(n)?"pdf":"unknown"}async previewFile(e,i){const n=await this.getPreviewElement(e,i);return n?this.ctx.modal.dialog({className:"in-page-edit ipe-quickPreview",sizeClass:"mediumToLarge",center:!0,title:i??(e instanceof File?e.name:e),content:h("section",{className:"ipe-quickPreview__content",children:n})}):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 n=await this.getPreviewType(e),r=e instanceof File?this.getObjectUrl(e):e;switch(n){case"image":return h("img",{src:r,alt:i??(e instanceof File?e.name:e)});case"video":return h("video",{src:r,controls:!0,"aria-label":i});case"audio":return h("audio",{src:r,controls:!0,"aria-label":i});case"pdf":return h("embed",{type:"application/pdf",src:r,"aria-label":i})}return null}previewWikiPage(e){throw new Error("Not implemented")}}fa=Qv(qd),Gr=ew(fa,0,"PluginQuickPreview",Bd,Gr),Zv(fa,1,Gr);const tw=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickPreview(){return Gr}},Symbol.toStringTag,{value:"Module"})),iw=t=>{let{user:e,target:i,ctx:n}=t;const r=n.getUrl.bind(n);return h("span",{className:"mw-userlinks",children:[h("a",{href:r(`User:${e}`),className:"mw-userlink",target:i,children:e})," ",h("span",{className:"mw-usertoollinks",children:["(",h("a",{href:r(`User_talk:${e}`),className:"mw-usertoollinks-talk",target:i,children:"talk"})," | ",h("a",{href:r(`Special:Contributions/${e}`),className:"mw-usertoollinks-contribs",target:i,children:"contribs"})," | ",h("a",{href:r(`Special:Block/${e}`),className:"mw-usertoollinks-block",target:i,children:"block"}),")"]})]})};var Qr=(t=>(t.update="ipe:diff-table/update",t.edit="ipe:diff-table/edit",t))(Qr||{});const nw=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"medium"}).format,Hd=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 h("td",{colSpan:2,className:e,children:h("div",{className:"mw-diff-title--title",children:t.type==="from"?"Original content":t.type==="to"?"Your content":""})});const i=n=>{n.preventDefault(),n.target.dispatchEvent(new CustomEvent("ipe:diff-table/edit",{detail:{revid:t.revid},bubbles:!0}))};return h("td",{colSpan:2,className:e,children:[h("div",{className:"mw-diff-title--title",children:[t.pagetitle||t.timestamp,t.revid?` (rev#${t.revid})`:""]}),h("div",{className:"mw-diff-title--actions",children:h("a",{href:t.ctx.getUrl("",{action:"edit",oldid:t.revid}),onClick:i,children:[h(Ed,{style:"width: 1em; height: 1em"}),"Quick edit"]})}),h("div",{className:"mw-diff-title--user",children:t.username&&h(iw,{ctx:t.ctx,user:t.username,target:"_blank"})}),h("div",{className:"mw-diff-title--timestamp",children:t.timestamp&&nw(new Date(t.timestamp))}),h("div",{className:"mw-diff-title--comment",children:t.parsedcomment&&h(ai,{children:["(",h("i",{innerHTML:t.parsedcomment}),")"]})})]})},rw=t=>{const e=t.data;if(!e.prev&&!e.next)return null;const i=(n,r,s)=>{n.preventDefault(),n.target.dispatchEvent(new CustomEvent("ipe:diff-table/update",{detail:{fromrev:r,torev:s},bubbles:!0}))};return h("tr",{className:"mw-diff-title--navigation",children:[h("td",{colSpan:2,children:e.prev?h("a",{href:t.ctx.getUrl("",{diff:e.prev,oldid:e.fromrevid}),onClick:n=>i(n,e.prev,e.fromrevid),children:"← Previous"}):h("i",{children:"Oldest version"})}),h("td",{colSpan:2,children:e.next?h("a",{href:t.ctx.getUrl("",{diff:e.next,oldid:e.torevid}),onClick:n=>i(n,e.torevid,e.next),children:"Next →"}):h("i",{children:"Newest version"})})]})},sw=t=>{const{data:e,...i}=t,n=h("table",{className:"theme-ipe diff diff-type-table","data-mw":"interface",...i,children:[h("colgroup",{children:[h("col",{className:"diff-marker"}),h("col",{className:"diff-content"}),h("col",{className:"diff-marker"}),h("col",{className:"diff-content"})]}),h("tbody",{children:[h("tr",{children:[h(Hd,{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}),h(Hd,{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})]}),h(rw,{data:e,ctx:t.ctx}),h("div",{id:"diffbody"}),h("tr",{className:"diff-size",style:{textAlign:"center"},children:[h("td",{colSpan:2,className:"diff-size-old",children:e.fromsize!==void 0&&`${e.fromsize} bytes`}),h("td",{colSpan:2,className:"diff-size-new",children:e.tosize!==void 0&&`${e.tosize} bytes`})]})]})]});return n.querySelector("#diffbody").outerHTML=e.body||h("tr",{children:h("td",{colSpan:4,children:h("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"5rem"},children:h("i",{children:"No changes"})})})}).outerHTML,n},ow=t=>h("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:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("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"}),h("path",{d:"M12 10l0 4"}),h("path",{d:"M10 12l4 0"}),h("path",{d:"M10 17l4 0"})]});var aw=Object.create,ha=Object.defineProperty,lw=Object.getOwnPropertyDescriptor,zd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Kd=t=>{throw TypeError(t)},cw=(t,e,i)=>e in t?ha(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,uw=(t,e)=>ha(t,"name",{value:e,configurable:!0}),dw=t=>[,,,aw(t?.[zd("metadata")]??null)],fw=["class","method","getter","setter","accessor","field","value","get","set"],Wd=t=>t!==void 0&&typeof t!="function"?Kd("Function expected"):t,hw=(t,e,i,n,r)=>({kind:fw[t],name:e,metadata:n,addInitializer:s=>i._?Kd("Already initialized"):r.push(Wd(s||null))}),pw=(t,e)=>cw(e,zd("metadata"),t[3]),gw=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},yw=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&lw(r,i));uw(r,i);for(var f=n.length-1;f>=0;f--)l=hw(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,Wd(o)&&(r=o);return pw(t,r),p&&ha(r,i,p),u?c^4?s:p:r},Vd,pa,Gd;Vd=[be(["wiki","getUrl","preferences","$"]),Ut(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 Yr extends(Gd=Ae){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=Es("#mw-history-compare");if(!i)return;Sh(".mw-history-compareselectedversions-button",i).forEach(r=>{r.after(h("button",{className:"cdx-button",onClick:s=>{s.preventDefault();const o=new FormData(i),a=Number(o.get("oldid"))||0,l=Number(o.get("diff"))||0;if(!o.get("title")||!a||!l)return this.logger.warn("Missing title or revision IDs");this.comparePages({fromrev:a,torev:l})},children:e`Quick Diff`}))})}async injectQuickEdit({modal:e,wikiPage:i,options:n}){if(i.pageid===0||n.section==="new")return;const{$:r}=this.ctx;let s;e.addButton({label:r`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||"",l=e.get$content().querySelector('textarea[name="text"]')?.value||"";return a===l?this.ctx.modal.notify("info",{title:r`Quick Diff`,content:r`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:l,topst:!0},s,{backdrop:!1,draggable:!0}),s)}},2),e.on(e.Event.Close,()=>{s?.destroy(),s=void 0})}comparePages(e,i,n){const{$:r}=this.ctx;return!i||i.isDestroyed?i=this.ctx.modal.createObject({title:r`Loading diff...`,content:"",className:"quick-diff",center:!1,...n}).init():i.removeButton("*"),this.ctx.emit("quick-diff/init-options",{ctx:this.ctx,options:e}),i.setContent(h("section",{style:{height:"70vh",display:"flex",justifyContent:"center",alignItems:"center"},children:h(ui,{})})),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})`:""}`:r`Differences`);let a;i.setContent(h("section",{style:{minHeight:"70vh"},children:h(sw,{ref:l=>a=l,data:o,ctx:this.ctx})})),a.addEventListener(Qr.update,l=>{l.stopPropagation(),this.comparePages({fromrev:l.detail.fromrev,torev:l.detail.torev},i,n)},{once:!0}),this.ctx.inject(["quickEdit"],l=>{const c=u=>{u.stopPropagation(),l.quickEdit({revision:u.detail.revid})};a.addEventListener(Qr.edit,c),i.on(i.Event.Close,()=>{a.removeEventListener(Qr.edit,c)})}),o.fromrevid&&o.torevid&&i.addButton({label:r`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(h(oa,{title:r`Failed to load diff`,type:"error",children:h("pre",{children:s instanceof Error?s.message:String(s)})}))}),i.show()}createQuickDiffButton(e,i){const{$:n}=this.ctx,r=i?.icon??h(ow,{className:"ipe-icon"}),s=i?.label??n`Quick Diff`;return h("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:[r,s]})}}pa=dw(Gd),Yr=yw(pa,0,"PluginQuickDiff",Vd,Yr),gw(pa,1,Yr);const bw=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickDiff(){return Yr}},Symbol.toStringTag,{value:"Module"})),ss=class ss extends Ae{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")||"",n=window.mw?.config.get("wgIsProbablyEditable");this.ctx.inject(["toolbox"],r=>{this.ctx=r,r.toolbox.addButton({id:"quick-redirect",icon:h("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:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 21v-4a3 3 0 0 1 3 -3h5"}),h("path",{d:"M9 17l3 -3l-3 -3"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("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(n?{to:i}:{})}}),this.addDisposeHandler(s=>{s.toolbox.removeButton("quick-redirect")})})}stop(){}async showModal(e){const{$:i}=this.ctx,n=await this.ctx.preferences.get("quickRedirect.reason");e||(e={}),this.ctx.emit("quick-redirect/init-options",{ctx:this.ctx,options:e});const r=this.ctx.modal.createObject({title:i`Quick Redirect`,content:h(ui,{}),className:"quick-redirect compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let s=null;return r.setContent(h("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),l={from:a.get("from")?.toString().trim(),to:a.get("to")?.toString().trim(),reason:a.get("reason")||"",overwrite:a.get("overwrite")==="on"};if(!l.from||!l.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:l}),r.setLoadingState(!0),this.redirectPage(l).then(c=>{r.close(),this.ctx.modal.notify("success",{title:i`Redirect successful`,content:i`The redirect has been created.`})}).catch(c=>{r.setLoadingState(!1),this.ctx.modal.notify("error",{title:i`Failed to redirect`,content:c instanceof Error?c.message:String(c)})})},children:[h(Od,{inputs:[{label:i`Redirect from`,name:"from",value:e?.from,required:!0},{label:i`Redirect to`,name:"to",value:e?.to,required:!0}]}),h(vi,{label:i`Reason`,id:"reason",name:"reason",value:e?.reason??n??""}),h("div",{children:h(wi,{name:"overwrite",id:"overwrite",checked:e?.overwrite,children:i`Force create redirect even if the from page already exists`})})]})),r.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:r}),r.show()}async redirectPage(e){const{from:i,to:n,reason:r="",overwrite:s=!1}=e,o=await this.ctx.wikiPage.newBlankPage({title:i}),a=`#REDIRECT [[:${n}]]`;return o.edit({text:a,summary:r},{createonly:!s})}};ss.inject=["api","wikiPage","modal","$"],ss.PreferencesSchema=R.object({"quickRedirect.reason":R.string().default("[IPE-NEXT] Quick redirect")}).description("Quick redirect options").extra("category","editor");let ga=ss;const vw=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickRedirect:ga},Symbol.toStringTag,{value:"Module"})),Qd=t=>h("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:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 9l5 -5l5 5"}),h("path",{d:"M12 4l0 12"})]});var ww=Object.create,ma=Object.defineProperty,_w=Object.getOwnPropertyDescriptor,Yd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Xd=t=>{throw TypeError(t)},xw=(t,e,i)=>e in t?ma(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,kw=(t,e)=>ma(t,"name",{value:e,configurable:!0}),Sw=t=>[,,,ww(t?.[Yd("metadata")]??null)],$w=["class","method","getter","setter","accessor","field","value","get","set"],Jd=t=>t!==void 0&&typeof t!="function"?Xd("Function expected"):t,Ew=(t,e,i,n,r)=>({kind:$w[t],name:e,metadata:n,addInitializer:s=>i._?Xd("Already initialized"):r.push(Jd(s||null))}),Pw=(t,e)=>xw(e,Yd("metadata"),t[3]),Cw=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Rw=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&_w(r,i));kw(r,i);for(var f=n.length-1;f>=0;f--)l=Ew(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,Jd(o)&&(r=o);return Pw(t,r),p&&ma(r,i,p),u?c^4?s:p:r},Zd,ya,ef;const Iw=({$:t})=>h("div",{className:"ipe-quickUpload__preview-placeholder is-na",children:h("span",{children:[h("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:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M19 7h-4l-.001 -4.001z"})]}),h("p",{children:t`No preview available`})]})});Zd=[Ut(R.object({"quickUpload.summary":R.string().description("Default summary of the quick upload").default("[IPE-NEXT] Quick upload")})),be(["modal","$","wikiTitle","wikiFile","quickPreview","preferences"])];class Xr extends(ef=Ae){constructor(e){super(e,{},"quick-upload"),this.ctx=e}async start(){this.injectQuickEdit(),this.injectToolbox(),this.ctx.set("quickUpload",this)}async stop(){}injectQuickEdit(){}injectToolbox(){const{$:e}=this.ctx;this.ctx.inject(["toolbox"],i=>{i.toolbox.addButton({id:"quick-upload",group:"group2",index:2,icon:h(Qd,{}),tooltip:()=>e`Quick Upload`,onClick:n=>{n.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 n=0;for(;e>=1024&&n<i.length-1;)e/=1024,n++;return`${new Intl.NumberFormat(void 0,{maximumFractionDigits:2}).format(e)} ${i[n]}`}getDefaultPreviewPlaceholder(){const{$:e}=this.ctx;return h("div",{className:"ipe-quickUpload__preview-placeholder",children:h("span",{children:[h(Qd,{}),h("p",{children:e`Drag & drop a file here`})]})})}isFileAccepted(e,i){if(!i)return!0;const n=i.split(",").map(o=>o.trim()).filter(Boolean);if(!n.length)return!0;const r=e.type||"",s=e.name||"";return n.some(o=>{if(o.startsWith("."))return s.toLowerCase().endsWith(o.toLowerCase());if(o.endsWith("/*")){const a=o.slice(0,-1);return r.startsWith(a)}return r===o})}async showModal(){const{$:e}=this.ctx,i=this.ctx.modal.show({className:"ipe-quickUpload compact-buttons",sizeClass:"smallToMedium",center:!1,title:e`Quick Upload`,content:e`Quick Upload`,outSideClose:!1});let n=!1;const r=()=>{d.reset(),s(),u=!1},s=async f=>{if(y.innerHTML="",!f){y.appendChild(this.getDefaultPreviewPlaceholder());return}u||(d.querySelector('input[name="filename"]').value=f.name);const w=await this.ctx.quickPreview.getPreviewElement(f)||h(Iw,{$:e});y.appendChild(h("div",{className:"ipe-quickUpload__preview-content",children:w})),y.appendChild(h("section",{className:"ipe-quickUpload__preview-info",children:h("ul",{children:[h("li",{children:h("strong",{children:f.name})}),h("li",{children:h("i",{children:f.type})}),h("li",{children:this.formatFileSize(f.size)})]})}))},o=async f=>{if(f.preventDefault(),n)return!1;const w=new FormData(d),x=Object.fromEntries(w.entries());n=!0,i.setLoadingState(!0),this.ctx.emit("analytics/event",{feature:"quick-upload",page:x.filename?.toString()||void 0});try{const S=await this.ctx.wikiFile.upload(x);if(this.logger.debug(S),S.data?.upload?.result==="Success")return this.ctx.modal.notify("success",{title:e`Upload successful`,content:h("div",{children:[h("p",{children:h("strong",{children:e`File has been uploaded successfully.`})}),h("p",{children:h("a",{href:this.ctx.wikiFile.getFileUrl(`File:${S.data.upload.filename}`),target:"_blank",rel:"noopener noreferrer",children:S.data.upload.filename})})]}),closeAfter:10*1e3}),r(),!0;throw S}catch(S){if(this.ctx.logger.error(S),S?.data?.upload){const m=S.data.upload;if(m.result==="Success")return!0;if(Array.isArray(m.warnings?.duplicate)&&m.warnings.duplicate.length>0)return this.ctx.modal.dialog({title:e`File duplicated`,content:h("div",{children:[e`This file is a duplicate of the following file:`,h("ol",{children:m.warnings.duplicate.map(g=>h("li",{children:h("a",{href:this.ctx.wikiFile.getFileUrl(`File:${g}`),target:"_blank",rel:"noopener noreferrer",children:g})},g))})]})}),!1;if(m.warnings?.exists)return this.ctx.modal.dialog({title:e`File already exists`,content:e`There is a file with the same name already exists.`}),!1}let I=[];if(S instanceof Error){I.push(S.message);let m=S;for(;m.cause&&(m=m.cause,m instanceof Error);)I.push(m.message)}else I.push(e`Upload failed with unknown error.`);return this.ctx.modal.dialog({title:e`Upload failed`,content:h("div",{style:{whiteSpace:"pre-wrap"},children:I.join(`
26
- `)})}),!1}finally{i.setLoadingState(!1),n=!1}},a=f=>{f.preventDefault(),f.stopPropagation(),f.currentTarget?.classList.remove("is-dragover");const x=d.querySelector('input[type="file"]');if(!x)return;const S=Array.from(f.dataTransfer?.files||[]);if(!S.length)return;const I=x.accept||"",m=S.find(b=>this.isFileAccepted(b,I))||null;if(!m)return;const g=new DataTransfer;g.items.add(m),x.files=g.files,x.dispatchEvent(new Event("change",{bubbles:!0}))},l=f=>{f.preventDefault(),f.stopPropagation();const w=f.currentTarget;f.dataTransfer&&(f.dataTransfer.dropEffect="copy"),w?.classList.add("is-dragover")},c=f=>{f.preventDefault(),f.stopPropagation(),f.currentTarget?.classList.remove("is-dragover")};let u=!1;const d=h("form",{onSubmit:o,className:"ipe-quickUpload__form",children:[h(vi,{label:e`File name`,name:"filename",id:"filename",placeholder:"Example.jpg",required:!0,inputProps:{onInput:()=>{u=!0}}}),h(vi,{label:e`File`,name:"file",id:"file",required:!0,children:h("input",{required:!0,type:"file",name:"file",id:"file",accept:"image/*,video/*,audio/*,application/pdf",onChange:f=>{const w=f.target?.files?.[0];w?.size&&s(w)}})}),h(vi,{label:e`Summary`,id:"summary",name:"comment",placeholder:"Upload file from ...",value:await this.ctx.preferences.get("quickUpload.summary")||""}),h("div",{className:"ipe-input-box",children:[h("label",{htmlFor:"text",children:e`File description`}),h("textarea",{name:"text",id:"text",placeholder:`This file is for...
27
- [[Category:XXX]]`})]}),h(wi,{name:"ignorewarnings",label:e`Ignore warnings and upload anyway`})]}),y=h("div",{className:"ipe-quickUpload__preview",onClick:f=>{const w=f.target;w&&w.closest("img, .ipe-quickUpload__preview-placeholder")&&(f.preventDefault(),d.querySelector('input[type="file"]').click())},children:this.getDefaultPreviewPlaceholder()}),p=h("section",{className:"ipe-quickUpload__container",onDrop:a,onDragOver:l,onDragLeave:c,children:[y,d]});return i.setContent(p),i.setButtons([{label:e`Cancel`,className:"is-danger is-text",method:f=>{i.close()}},{label:e`Upload`,className:"is-primary is-text",method:f=>{d.requestSubmit()}}]),i}}ya=Sw(ef),Xr=Rw(ya,0,"PluginQuickUpload",Zd,Xr),Cw(ya,1,Xr);const Aw=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickUpload(){return Xr}},Symbol.toStringTag,{value:"Module"}));class Ow extends Ae{constructor(e){super(e,{},"quick-usage"),this.ctx=e,e.set("quickUsage",this)}async start(){Promise.resolve().then(()=>t0).then(({PluginTemplatesUsed:e})=>this.ctx.plugin(e)),Promise.resolve().then(()=>f0).then(({PluginImagesUsed:e})=>this.ctx.plugin(e)),this.ctx.inject(["quickUpload","$"],e=>{e.on("quick-edit/wiki-page",({modal:i})=>{const{$:n}=e;this.getWrapperForQuickEdit(i).appendChild(h("a",{href:"#ipe:quick-upload",onClick:s=>{s.preventDefault(),e.quickUpload.showModal(),e.emit("analytics/event",{feature:"quick-usage",subtype:"quick-upload"})},children:n`Quick Upload`}))})})}getWrapperForQuickEdit(e){const i=e.get$content().querySelector(".ipe-quickEdit__usages")||h("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 Tw=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickUsage:Ow},Symbol.toStringTag,{value:"Module"}));var Lw=Object.create,ba=Object.defineProperty,Nw=Object.getOwnPropertyDescriptor,tf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),nf=t=>{throw TypeError(t)},Mw=(t,e,i)=>e in t?ba(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Dw=(t,e)=>ba(t,"name",{value:e,configurable:!0}),jw=t=>[,,,Lw(t?.[tf("metadata")]??null)],Uw=["class","method","getter","setter","accessor","field","value","get","set"],rf=t=>t!==void 0&&typeof t!="function"?nf("Function expected"):t,Fw=(t,e,i,n,r)=>({kind:Uw[t],name:e,metadata:n,addInitializer:s=>i._?nf("Already initialized"):r.push(rf(s||null))}),Bw=(t,e)=>Mw(e,tf("metadata"),t[3]),qw=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Hw=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&Nw(r,i));Dw(r,i);for(var f=n.length-1;f>=0;f--)l=Fw(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,rf(o)&&(r=o);return Bw(t,r),p&&ba(r,i,p),u?c^4?s:p:r},sf,va,of;sf=[Ut(R.object({toolboxAlwaysShow:R.boolean().description("Make the toolbox opened by default").default(!1)}).description("Toolbox preferences")),be(["preferences"])];class Jr extends(of=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,n)=>{const r=this.orderKey(i),s=this.orderKey(n),o=r??0,a=s??0;if(o<a)return-1;if(o>a)return 1;const l=this.seqMap.get(i.id)??0,c=this.seqMap.get(n.id)??0;return r===null&&s===null?l!==c?l-c:0:r===null&&s!==null?-1:r!==null&&s===null?1:l!==c?l-c: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 n=.15,r=e/(i-1),s=n*Math.sqrt(r);return Math.round(s*1e3)/1e3}updateButtonDelays(){this.container.querySelectorAll(".btn-group").forEach(i=>{const n=i.querySelectorAll(".btn-tip-group"),r=n.length;n.forEach((s,o)=>{const a=this.calculateButtonDelay(o,r);s.style.setProperty("--transition-delay",`${a}s`),s.style.setProperty("--max-transition-delay","0.15s")})})}createToolbox(){return h("div",{id:"ipe-edit-toolbox",children:[h("ul",{className:"btn-group group1",style:{display:"flex",flexDirection:"column"}}),h("ul",{className:"btn-group group2",style:{display:"flex",flexDirection:"row"}}),h("button",{className:"ipe-toolbox-btn",id:"toolbox-toggler",onClick:()=>{this.toggle()},children:h("svg",{xmlns:"http://www.w3.org/2000/svg",width:"448",height:"512",viewBox:"0 0 448 512",children:[h("rect",{width:"448",height:"512",fill:"none"}),h("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(n=>n.group==="group1").length,i=this.buttons.filter(n=>n.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(r=>r.id===e.id),n=(()=>{if(i!==-1){const r=this.buttons[i];return!e.group||e.group==="auto"?r.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 r=this.buttons[i],s=typeof e.index=="number"&&!Number.isNaN(e.index)?e.index:r.index,o={...r,...e,group:n,index:s};this.buttons.splice(i,1,o)}else{const r=typeof e.index=="number"&&!Number.isNaN(e.index)?e.index:void 0,s={...e,group:n,index:r};this.buttons.push(s)}this.ctx.emit("toolbox/button-added",{ctx:this.ctx,payload:e}),this.renderAll()}removeButton(e){const i=this.buttons.findIndex(n=>n.id===e);if(i!==-1){const n=this.buttons[i];this.buttons.splice(i,1),this.ctx.emit("toolbox/button-removed",{ctx:this.ctx,payload:n}),this.renderAll()}}renderButton(e){let{id:i,icon:n,index:r,tooltip:s,itemProps:o,buttonProps:a,onClick:l}=e;const c=this.normalizeButtonId(i);return h("li",{class:"btn-tip-group",id:c,"data-id":i,"data-index":r,...o,children:[h("div",{class:"btn-tip",children:Il(s)}),h("button",{id:`${c}-btn`,"data-id":e.id,class:"ipe-toolbox-btn",onClick:d=>{l?.(d),this.ctx.emit("toolbox/button-clicked",{ctx:this.ctx,event:d,payload:e})},...a,children:Il(n)})]})}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),n=this.container.querySelector(".btn-group.group1"),r=this.container.querySelector(".btn-group.group2");n.innerHTML="",r.innerHTML="",e.forEach(s=>{n.appendChild(this.renderButton(s))}),i.forEach(s=>{r.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,n=typeof e=="boolean"?e:!i;this.container.classList.toggle("is-persistent",n),this.container.classList.remove("is-hovered"),this.ctx.preferences.set("toolboxAlwaysShow",n),this.ctx.emit("toolbox/toggle",{ctx:this.ctx,opened:this.isOpened})}}va=jw(of),Jr=Hw(va,0,"PluginToolbox",sf,Jr),qw(va,1,Jr);const zw=Object.freeze(Object.defineProperty({__proto__:null,get PluginToolbox(){return Jr}},Symbol.toStringTag,{value:"Module"})),Zr=pi({__name:"UIBaseButton",props:{variant:{default:"neutral"},active:{type:Boolean,default:!1}},setup(t){const e=t,i=Ot(()=>({"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(n,r)=>(oe(),fe("button",{class:gt(["ipeps-button",i.value])},[yy(n.$slots,"default")],2))}}),Kw={id:"ipe-registry-manager"},Ww={class:"ipeps-header"},Vw={class:"ipeps-header-title"},Gw={class:"ipeps-input-wrapper"},Qw=["placeholder","disabled"],Yw={key:0,class:"ipeps-list"},Xw={class:"registry-info"},Jw={class:"item-name"},Zw={class:"item-desc"},e_={class:"homepage"},t_=["href"],i_={class:"url"},n_={class:"item-meta"},r_={class:"ipeps-actions"},s_={key:1,class:"ipeps-empty"},o_={class:"text"},a_={class:"description"},l_=Hr(pi({__name:"RegistryManager",setup(t){const e=Xo(),i=e.$,n=e.$$,r=Fe([]),s=Fe(""),o=Fe(!1),a=f=>{try{return new URL(f).hostname}catch{return f}};async function l(){const f=await e.preferences.get("pluginStore.registries")||[],w=await Promise.allSettled(f.map(async x=>{const S=await e.store.getRegistryInfo(x);return{registryUrl:x,label:a(x),...S}}));r.value=w.filter(x=>x.status==="fulfilled").map(x=>x.value)}async function c(){const f=s.value.trim();if(f){if(r.value.some(w=>w.registryUrl===f)){e.modal.notify("info",{content:"Registry already exists."});return}o.value=!0;try{const w=await e.store.getRegistryInfo(f,"online_manifest",!0);if(!w)throw new Error("Invalid registry or unreachable");const x=await e.preferences.get("pluginStore.registries")||[];x.push(f),await e.preferences.set("pluginStore.registries",x),r.value.push({registryUrl:f,label:a(f),...w}),s.value="",e.modal.notify("success",{content:"Registry added."})}catch(w){e.modal.notify("error",{content:w instanceof Error?w.message:String(w)})}finally{o.value=!1}}}async function u(f){const x=(await e.preferences.get("pluginStore.registries")||[]).filter(S=>S!==f);await e.preferences.set("pluginStore.registries",x),r.value=r.value.filter(S=>S.registryUrl!==f)}async function d(f){const x=(await e.preferences.get("pluginStore.plugins")||[]).filter(S=>S.registry===f);if(x.length===0){e.modal.confirm({title:n`plugin-store.remove-registry.title`,content:n`plugin-store.remove-registry.tip-content`+`
28
- ${f}`,cancelBtn:{label:i`Cancel`,className:"is-ghost"},okBtn:{label:i`Remove`,className:"is-danger"}},async S=>{S&&(await u(f),e.modal.notify("success",{content:n`plugin-store.remove-registry.remove-success`}))});return}e.modal.dialog({title:n`plugin-store.remove-registry.title`,content:sn("div",{class:"theme-ipe-prose"},[sn("p",{},n({count:x.length})`plugin-store.remove-registry.confirm-content`),sn("ul",{},x.map(S=>sn("li",{},S.id)))]),buttons:[{label:n`plugin-store.remove-registry.buttons.remove-only`,className:"is-danger is-ghost",method:async(S,I)=>{await u(f),e.modal.notify("success",{content:n`plugin-store.remove-registry.remove-success`}),I.close()}},{label:n`plugin-store.remove-registry.buttons.remove-and-uninstall`,className:"is-danger",method:async(S,I)=>{await u(f);for(const m of x)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:n({$1:x.length})`plugin-store.remove-registry.remove-with-plugins-success`}),I.close()}}]},()=>{})}function y(f){const w=f.changes["pluginStore.registries"];Array.isArray(w)&&l()}function p(){const f=St.PLUGIN_REGISTRY_URL;s.value=f,c()}return xn(()=>{l(),e.on("preferences/changed",y)}),(f,w)=>(oe(),fe("div",Kw,[J("div",Ww,[J("div",Vw,ue(Se(i)`Registries`),1),J("div",Gw,[Vc(J("input",{class:"ipeps-input with-icon","onUpdate:modelValue":w[0]||(w[0]=x=>s.value=x),type:"url",placeholder:Se(i)`Add registry URL`+" (https://...)",disabled:o.value},null,8,Qw),[[Xu,s.value,void 0,{trim:!0}]]),w[1]||(w[1]=J("div",{class:"ipeps-input-icon"},"📦",-1))]),Ce(Zr,{onClick:c,disabled:o.value||!s.value,variant:"primary"},{default:wn(()=>[Rn(ue(o.value?Se(i)`Adding...`:Se(i)`Add`),1)]),_:1},8,["disabled"])]),r.value.length?(oe(),fe("div",Yw,[(oe(!0),fe(He,null,Ao(r.value,x=>(oe(),fe("div",{class:"ipeps-item",key:x.registryUrl},[J("div",Xw,[J("div",Jw,ue(x.label),1),J("div",Zw,[J("div",e_,[x.homepage?(oe(),fe("a",{key:0,href:x.homepage,target:"_blank"},ue(x.homepage),9,t_)):ti("",!0)]),J("div",i_,ue(x.registryUrl),1)]),J("div",n_,ue(x.packages.length)+" packages",1)]),J("div",r_,[Ce(Zr,{onClick:S=>d(x.registryUrl),variant:"danger"},{default:wn(()=>[Rn(ue(Se(i)`Remove`),1)]),_:1},8,["onClick"])])]))),128))])):(oe(),fe("div",s_,[w[2]||(w[2]=J("div",{class:"icon"},"🗂️",-1)),J("div",o_,ue(Se(i)`No registries configured`),1),J("div",a_,[Ce(Zr,{onClick:p,variant:"primary",style:{padding:"0.25rem 0.5rem"}},{default:wn(()=>[Rn(ue(Se(i)`Setup default registry`),1)]),_:1})])]))]))}}),[["__scopeId","data-v-0245c97d"]]),c_={id:"ipe-plugin-install-manager"},u_={class:"ipeps-header"},d_={class:"ipeps-header-title"},f_={class:"ipeps-input-wrapper"},h_=["placeholder","disabled"],p_=["disabled"],g_={key:0,class:"ipeps-loading"},m_={class:"loading-text"},y_={key:1,class:"ipeps-list"},b_={class:"plugin-info"},v_={class:"plugin-header"},w_={class:"item-name"},__={class:"ipeps-tags"},x_=["href","title"],k_=["title"],S_={class:"plugin-meta"},$_={key:0,class:"version"},E_={key:1,class:"author"},P_={key:2,class:"license"},C_={key:2,class:"ipeps-empty"},R_={class:"plugin-empty-text"},I_=Hr(pi({__name:"PluginInstallManager",setup(t){const e=Xo(),i=e.$,n=e.$$,r=Fe([]),s=Fe([]),o=Fe(""),a=Fe(!1),l=(C,U)=>`${C}
29
- ${U}`,c=Ot(()=>new Set(s.value.map(C=>l(C.registry,C.id)))),u=C=>c.value.has(C),d=C=>{try{return new URL(C).hostname}catch{return C}},y=Fe(!1),p=Ot(()=>r.value.length>0),f=Ot(()=>r.value.flatMap(C=>(C.packages||[]).map(U=>({...U,_key:l(C.registryUrl,U.id),registry:C.registryUrl,registryHomepage:C.homepage,registryLabel:d(C.registryUrl),isBroken:!1,isRegistryMissing:!1})))),w=Ot(()=>{const C=o.value.trim().toLowerCase(),U=f.value,H=new Set(U.map(Ee=>Ee._key)),ze=new Set(r.value.map(Ee=>Ee.registryUrl)),ft=s.value.filter(Ee=>!H.has(l(Ee.registry,Ee.id))).map(Ee=>{const ce=r.value.find(ge=>ge.registryUrl===Ee.registry);return{id:Ee.id,name:void 0,description:void 0,version:void 0,author:void 0,license:void 0,_key:l(Ee.registry,Ee.id),registry:Ee.registry,registryHomepage:ce?.homepage,registryLabel:d(Ee.registry),isBroken:!0,isRegistryMissing:!ze.has(Ee.registry)}}),Gi=Ee=>C?Ee.filter(ce=>ce.name&&ce.name.toLowerCase().includes(C)||ce.id&&ce.id.toLowerCase().includes(C)||ce.description&&ce.description.toLowerCase().includes(C)||ce.author&&ce.author.toLowerCase().includes(C)||ce.registry&&ce.registry.toLowerCase().includes(C)):Ee;return[...Gi(ft),...Gi(U)]}),x=Ot(()=>w.value),S=C=>C.description?C.description:C.isBroken?C.isRegistryMissing?n`plugin-store.broken.registry-unavailable`:n`plugin-store.broken.plugin-removed`:"",I=async(C,U)=>{e.store.installAndSetPreference(C,U)},m=async(C,U)=>{e.store.uninstallAndRemovePreference(C,U)},g=(C,U)=>u(l(C,U))?m(C,U):I(C,U),b=C=>g(C.registry,C.id),k=async()=>{if(a.value)return;if(r.value.length===0){e.modal.notify("info",{content:"No registry configured. Please add a registry first."});return}a.value=!0;const C=await e.store.refreshAllRegistryCaches(),U=Object.entries(C).filter(([ze,ft])=>ft!==null);r.value=U.map(([ze,ft])=>({...ft,registryUrl:ze}));const H=Object.entries(C).filter(([ze,ft])=>ft===null).map(([ze])=>ze);a.value=!1,U.length===0?e.modal.notify("error",{content:"All registries failed to refresh"}):(e.modal.notify("success",{content:`${U.length} ${U.length===1?"registry":"registries"} refreshed successfully.`}),H.length>0&&e.modal.notify("warning",{content:`${H.length} ${H.length===1?"registry":"registries"} failed to refresh:
30
- ${H.join(`
31
- `)}`}))},P=async()=>{y.value=!1;const C=await e.store.ctx.preferences.get("pluginStore.registries")||[],U=await Promise.allSettled(C.map(async H=>({...await e.store.getRegistryInfo(H),registryUrl:H})));r.value=U.filter(H=>H.status==="fulfilled").map(H=>H.value),s.value=await e.preferences.get("pluginStore.plugins")||[],y.value=!0};function L(C){const U=C.changes["pluginStore.registries"],H=C.changes["pluginStore.plugins"];Array.isArray(H)&&(s.value=H),Array.isArray(U)&&P()}return xn(()=>{P(),e.on("preferences/changed",L)}),Ro(()=>{}),(C,U)=>(oe(),fe("div",c_,[J("div",u_,[J("div",d_,ue(Se(i)`Plugins`),1),J("div",f_,[Vc(J("input",{class:"ipeps-input with-icon","onUpdate:modelValue":U[0]||(U[0]=H=>o.value=H),type:"text",placeholder:Se(i)`Search plugins...`,disabled:!f.value.length},null,8,h_),[[Xu,o.value,void 0,{trim:!0}]]),U[1]||(U[1]=J("div",{class:"ipeps-input-icon"},"🔍",-1))]),J("button",{class:gt(["ipeps-button",{refreshing:a.value}]),onClick:k,disabled:a.value||!p.value,variant:"primary"},ue(a.value?Se(i)`Refreshing...`:Se(i)`Refresh`),11,p_)]),!p.value&&!y.value?(oe(),fe("div",g_,[U[2]||(U[2]=J("div",{class:"loading-spinner"},null,-1)),J("div",m_,ue(Se(i)`Loading...`),1)])):x.value.length?(oe(),fe("div",y_,[(oe(!0),fe(He,null,Ao(x.value,H=>(oe(),fe("div",{class:gt(["ipeps-item",{installed:u(H._key),broken:H.isBroken}]),key:H._key},[J("div",b_,[J("div",v_,[J("div",w_,ue(H.name||H.id),1),u(H._key)||H.isBroken?(oe(),fe("span",{key:0,class:gt(["ipeps-badge",{"is-installed":u(H._key),"is-broken":H.isBroken}])},ue(H.isBroken?Se(n)`plugin-store.tags.broken`:Se(n)`plugin-store.tags.installed`),3)):ti("",!0)]),J("div",__,[H.registryHomepage&&!H.isRegistryMissing?(oe(),fe("a",{key:0,class:"ipeps-tag registry-tag",href:H.registryHomepage,target:"_blank",title:H.registryLabel},ue(H.registryLabel),9,x_)):(oe(),fe("span",{key:1,class:gt(["ipeps-tag registry-tag",{broken:H.isRegistryMissing}]),title:H.registryLabel},ue(H.registryLabel),11,k_)),J("div",{class:gt(["plugin-id ipeps-tag",{broken:H.isBroken&&!H.isRegistryMissing}])},ue(H.id),3)]),J("div",{class:gt(["plugin-desc",{"broken-desc":H.isBroken}])},ue(S(H)),3),J("div",S_,[H.version?(oe(),fe("span",$_,"v"+ue(H.version),1)):ti("",!0),H.author?(oe(),fe("span",E_,"👤 "+ue(H.author),1)):ti("",!0),H.license?(oe(),fe("span",P_,"📜 "+ue(H.license),1)):ti("",!0)])]),Ce(Zr,{active:u(H._key),variant:u(H._key)?"danger":"primary",onClick:ze=>b(H)},{default:wn(()=>[Rn(ue(u(H._key)?Se(i)`Remove`:Se(i)`Install`),1)]),_:2},1032,["active","variant","onClick"])],2))),128))])):(oe(),fe("div",C_,[U[3]||(U[3]=J("div",{class:"plugin-empty-icon"},"📦",-1)),J("div",R_,ue(Se(i)`No matching plugins found`),1)]))]))}}),[["__scopeId","data-v-d3aab2b1"]]),A_={id:"ipe-plugin-store-app"},O_=Object.freeze(Object.defineProperty({__proto__:null,default:Hr(pi({__name:"PluginStoreApp",setup(t){return(e,i)=>(oe(),fe("div",A_,[Ce(I_),i[0]||(i[0]=J("div",{class:"divider-wrapper"},[J("hr",{class:"divider"})],-1)),Ce(l_)]))}}),[["__scopeId","data-v-1b3d0d80"]])},Symbol.toStringTag,{value:"Module"})),T_=window?.location?.origin,Ln=({type:t,tag:e,href:i,target:n,children:r,...s})=>(e=e||(i?"a":"button"),typeof n>"u"&&i&&i.startsWith("http")&&!i.startsWith(T_)&&(n="_blank"),sn(e,{className:`theme-ipe ipe-action-button ipe-modal-btn is-${t||"default"}`,href:e==="a"?i:void 0,target:e==="a"?n:void 0,"data-href":e!=="a"?i:void 0,...s},r));var L_=Object.create,wa=Object.defineProperty,N_=Object.getOwnPropertyDescriptor,af=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),lf=t=>{throw TypeError(t)},M_=(t,e,i)=>e in t?wa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,D_=(t,e)=>wa(t,"name",{value:e,configurable:!0}),j_=t=>[,,,L_(t?.[af("metadata")]??null)],U_=["class","method","getter","setter","accessor","field","value","get","set"],cf=t=>t!==void 0&&typeof t!="function"?lf("Function expected"):t,F_=(t,e,i,n,r)=>({kind:U_[t],name:e,metadata:n,addInitializer:s=>i._?lf("Already initialized"):r.push(cf(s||null))}),B_=(t,e)=>M_(e,af("metadata"),t[3]),q_=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},H_=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&N_(r,i));D_(r,i);for(var f=n.length-1;f>=0;f--)l=F_(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,cf(o)&&(r=o);return B_(t,r),p&&wa(r,i,p),u?c^4?s:p:r},uf,_a,df;uf=[be(["preferences","wiki","wikiPage","wikiTitle","modal","preferencesUI","$"])];class es extends(df=Ae){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 n=this.getUserPrefsPageTitle();return h("div",{className:"theme-ipe-prose",children:[n&&h("section",{children:[h("h3",{children:i`Backup your preferences via user page`}),h("p",{children:h("a",{href:n?.getURL().toString(),target:"_blank",children:[n?.getPrefixedText()," →"]})}),h("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[h(Ln,{type:"primary",onClick:r=>{r.preventDefault();const s=r.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:h("p",{children:["Your preferences have been exported to"," ",h("a",{href:a.getURL().toString(),target:"_blank",children:a.getPrefixedText()}),"."]})})}).finally(()=>{s.disabled=!1,o?.setLoadingState(!1)})},children:[h("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:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M19 22v-6"}),h("path",{d:"M22 19l-3 -3l-3 3"})]})," ",i`Backup`]}),h(Ln,{onClick:r=>{r.preventDefault();const s=e.preferencesUI.getCurrentModal(),o=r.target;o.disabled=!0,s?.setLoadingState(!0),this.importFromUserPage().then(a=>{this.notifyImportSuccess(a)}).finally(()=>{o.disabled=!1,s?.setLoadingState(!1)})},children:[h("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:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("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"}),h("path",{d:"M19 16v6"}),h("path",{d:"M22 19l-3 3l-3 -3"})]})," ",i`Restore`]})]})]}),h("section",{children:[h("h3",{children:i`Import and export preferences`}),h("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[h(Ln,{onClick:r=>{r.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 l=()=>{a||s?.setLoadingState(!1),window.removeEventListener("focus",l)};window.addEventListener("focus",l,{once:!0}),o.addEventListener("change",async c=>{a=!0;try{const u=c.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`}),h(Ln,{onClick:r=>{r.preventDefault();const s=h("input",{type:"url",style:{width:"100%"}}),o=e.preferencesUI.getCurrentModal();e.modal.confirm({title:i`Import from URL`,content:h("div",{className:"ipe-input-box",children:[h("label",{htmlFor:"url-input",children:i`Enter the URL of the preferences JSON file:`}),s]})},async a=>{const l=s.value.trim();if(!(!a||!l))try{o?.setLoadingState(!0);const c=await this.importFromUrl(l);this.notifyImportSuccess(c)}catch(c){e.modal.notify("error",{title:"Import failed",content:c instanceof Error?c.message:String(c)})}finally{o?.setLoadingState(!1)}})},children:i`Import from URL`}),h(Ln,{onClick:async r=>{r.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:h("div",{children:[h("label",{htmlFor:"data",children:i`Your InPageEdit preferences:`}),h("textarea",{name:"data",id:"data",rows:10,value:o,readOnly:!0,style:{width:"100%"}})]}),buttons:[{label:"Copy",method:(a,l)=>{navigator.clipboard.writeText(o),e.modal.notify("success",{content:i`Copied to clipboard`}),l.close()}},{label:i`Download`,method:(a,l)=>{const c=document.createElement("a");c.href=`data:text/json;charset=utf-8,${encodeURIComponent(o)}`,c.download=`ipe-prefs-${new Date().toISOString()}.json`,c.click(),l.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"}),n=await this.importFromUrl(i.toString());return this.logger.info("Loaded preferences from user page:",e),n}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 n=await e.preferences.getExportableRecord(),r=JSON.stringify(n,null,2);try{return await this.ctx.wikiPage.newBlankPage({title:i.toString(),ns:2}).edit({text:r,summary:"Update InPageEdit preferences",watchlist:pt.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 n=await i.blob();return await this.importFromFile(n)}async importFromFile(e){const i=await e.text(),n=JSON.parse(i);return await this.ctx.preferences.setMany(n)}notifyImportSuccess(e){const{$:i}=this.ctx,n=Object.keys(e??{}),r=n.length;return this.ctx.modal.notify("success",{title:i`Preferences Imported`,content:h("section",{children:[h("p",{children:i({count:r})`Successfully imported {{ count }} {{ count > 1 ? "settings" : "setting" }}:`}),h("ol",{style:{listStyle:"auto",paddingLeft:"1em"},children:n.map(s=>h("li",{children:s},s))})]})})}}_a=j_(df),es=H_(_a,0,"PluginPrefSync",uf,es),q_(_a,1,es);const z_=Object.freeze(Object.defineProperty({__proto__:null,get PluginPrefSync(){return es}},Symbol.toStringTag,{value:"Module"}));var K_=Object.create,xa=Object.defineProperty,W_=Object.getOwnPropertyDescriptor,ff=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),hf=t=>{throw TypeError(t)},V_=(t,e,i)=>e in t?xa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,G_=(t,e)=>xa(t,"name",{value:e,configurable:!0}),Q_=t=>[,,,K_(t?.[ff("metadata")]??null)],Y_=["class","method","getter","setter","accessor","field","value","get","set"],pf=t=>t!==void 0&&typeof t!="function"?hf("Function expected"):t,X_=(t,e,i,n,r)=>({kind:Y_[t],name:e,metadata:n,addInitializer:s=>i._?hf("Already initialized"):r.push(pf(s||null))}),J_=(t,e)=>V_(e,ff("metadata"),t[3]),Z_=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},e0=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&W_(r,i));G_(r,i);for(var f=n.length-1;f>=0;f--)l=X_(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,pf(o)&&(r=o);return J_(t,r),p&&xa(r,i,p),u?c^4?s:p:r},gf,ka,mf;gf=[be(["modal","$"])];class ts extends(mf=Ae){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:n,modal:r}=e;if(!n||!n.pageid)return;const s=this.ctx.quickUsage.getWrapperForQuickEdit(r),o=h("a",{href:`#ipe://quick-usage/templates?title=${n.title}`,onClick:async a=>{a.preventDefault();const l=await this.showModal({wikiPage:n});l&&r.on(r.Event.Close,()=>{l.destroy()})},children:i`Templates Used`});s.appendChild(o)}async showModal(e={}){const{$:i}=this.ctx,n=e.wikiPage||await this.ctx.wikiPage.WikiPage.newFromAnyKind(e);if(!n||!n.pageid)return;const r=this.ctx.modal.show({title:i`Templates Used`,content:h("section",{className:"ipe-quickUsage__templates",children:h("ol",{children:n.templates.map(s=>{const o=this.ctx.wikiTitle.newTitle(s.title,s.ns),a=this.ctx.quickEdit.createQuickEditButton({title:o.toString()},{label:""});return h("li",{children:[h("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"}),r}}ka=Q_(mf),ts=e0(ka,0,"PluginTemplatesUsed",gf,ts),Z_(ka,1,ts);const t0=Object.freeze(Object.defineProperty({__proto__:null,get PluginTemplatesUsed(){return ts}},Symbol.toStringTag,{value:"Module"}));var i0=Object.create,Sa=Object.defineProperty,n0=Object.getOwnPropertyDescriptor,yf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),bf=t=>{throw TypeError(t)},r0=(t,e,i)=>e in t?Sa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,s0=(t,e)=>Sa(t,"name",{value:e,configurable:!0}),o0=t=>[,,,i0(t?.[yf("metadata")]??null)],a0=["class","method","getter","setter","accessor","field","value","get","set"],vf=t=>t!==void 0&&typeof t!="function"?bf("Function expected"):t,l0=(t,e,i,n,r)=>({kind:a0[t],name:e,metadata:n,addInitializer:s=>i._?bf("Already initialized"):r.push(vf(s||null))}),c0=(t,e)=>r0(e,yf("metadata"),t[3]),u0=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},d0=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,d=0,y=t[d]||(t[d]=[]),p=c&&(r=r.prototype,c<5&&(c>3||!u)&&n0(r,i));s0(r,i);for(var f=n.length-1;f>=0;f--)l=l0(c,i,a={},t[3],y),o=(0,n[f])(r,l),a._=1,vf(o)&&(r=o);return c0(t,r),p&&Sa(r,i,p),u?c^4?s:p:r},wf,$a,_f;wf=[be(["modal","$"])];class is extends(_f=Ae){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:n,modal:r}=e;if(!n||!n.pageid)return;const s=this.ctx.quickUsage.getWrapperForQuickEdit(r),o=h("a",{href:`#ipe://quick-usage/images?title=${n.title}`,onClick:async a=>{a.preventDefault();const l=await this.showModal({wikiPage:n});l&&r.on(r.Event.Close,()=>{l.destroy()})},children:i`Images Used`});s.appendChild(o)}async showModal(e={}){const{$:i}=this.ctx,n=e.wikiPage||await this.ctx.wikiPage.WikiPage.newFromAnyKind(e);if(!n||!n.pageid)return;const r=this.ctx.modal.show({title:i`Images Used`,content:h("section",{className:"ipe-quickUsage__images",children:h("ol",{children:n.images.map(s=>{const o=this.ctx.wikiFile.getFileUrl(s.title);return h("li",{children:[h("a",{href:this.ctx.wiki.getUrl(s.title),target:"_blank",rel:"noopener noreferrer",children:s.title})," ","(",h("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"}),r}}$a=o0(_f),is=d0($a,0,"PluginImagesUsed",wf,is),u0($a,1,is);const f0=Object.freeze(Object.defineProperty({__proto__:null,get PluginImagesUsed(){return is}},Symbol.toStringTag,{value:"Module"}));W.BasePlugin=Ae,W.CordisSymbols=D,W.EffectScope=ys,W.Endpoints=St,W.ForkScope=Ba,W.InPageEdit=Ri,W.Inject=be,W.Lifecycle=Ua,W.Logger=za,W.LoggerLevel=vs,W.MainScope=bs,W.RegisterPreferences=Ut,W.Schema=R,W.ScopeStatus=Fa,W.Service=ht,W.createLogger=Va,Object.defineProperty(W,Symbol.toStringTag,{value:"Module"})}));
23
+ `,...gy(r))}Dt(),Mo=!1}function py(){let t=Pn[Pn.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 n=t.component&&t.component.parent;t=n&&n.vnode}return e}function gy(t){const e=[];return t.forEach((i,n)=>{e.push(...n===0?[]:[`
24
+ `],...my(i))}),e}function my({vnode:t,recurseCount:e}){const i=e>0?`... (${e} recursive calls)`:"",n=t.component?t.component.parent==null:!1,r=` at <${Yu(t.component,t.type,n)}`,s=">"+i;return t.props?[r,...yy(t.props),s]:[r+s]}function yy(t){const e=[],i=Object.keys(t);return i.slice(0,3).forEach(n=>{e.push(...eu(n,t[n]))}),i.length>3&&e.push(" ..."),e}function eu(t,e,i){return Ie(e)?(e=JSON.stringify(e),i?e:[`${t}=${e}`]):typeof e=="number"||typeof e=="boolean"||e==null?i?e:[`${t}=${e}`]:De(e)?(e=eu(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 Hi(t,e,i,n){try{return n?t(...n):t()}catch(r){Cn(r,e,i)}}function jt(t,e,i,n){if(Z(t)){const r=Hi(t,e,i,n);return r&&Sc(r)&&r.catch(s=>{Cn(s,e,i)}),r}if(J(t)){const r=[];for(let s=0;s<t.length;s++)r.push(jt(t[s],e,i,n));return r}}function Cn(t,e,i,n=!0){const r=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(),Hi(s,null,10,[t,c,l]),Dt();return}}by(t,i,r,n,o)}function by(t,e,i,n=!0,r=!1){if(r)throw t}const Ye=[];let Ut=-1;const Wi=[];let ui=null,Ki=0;const tu=Promise.resolve();let Lr=null;function In(t){const e=Lr||tu;return t?e.then(this?t.bind(this):t):e}function vy(t){let e=Ut+1,i=Ye.length;for(;e<i;){const n=e+i>>>1,r=Ye[n],s=Rn(r);s<t||s===t&&r.flags&2?e=n+1:i=n}return e}function Do(t){if(!(t.flags&1)){const e=Rn(t),i=Ye[Ye.length-1];!i||!(t.flags&2)&&e>=Rn(i)?Ye.push(t):Ye.splice(vy(e),0,t),t.flags|=1,iu()}}function iu(){Lr||(Lr=tu.then(su))}function wy(t){J(t)?Wi.push(...t):ui&&t.id===-1?ui.splice(Ki+1,0,t):t.flags&1||(Wi.push(t),t.flags|=1),iu()}function nu(t,e,i=Ut+1){for(;i<Ye.length;i++){const n=Ye[i];if(n&&n.flags&2){if(t&&n.id!==t.uid)continue;Ye.splice(i,1),i--,n.flags&4&&(n.flags&=-2),n(),n.flags&4||(n.flags&=-2)}}}function ru(t){if(Wi.length){const e=[...new Set(Wi)].sort((i,n)=>Rn(i)-Rn(n));if(Wi.length=0,ui){ui.push(...e);return}for(ui=e,Ki=0;Ki<ui.length;Ki++){const i=ui[Ki];i.flags&4&&(i.flags&=-2),i.flags&8||i(),i.flags&=-2}ui=null,Ki=0}}const Rn=t=>t.id==null?t.flags&2?-1:1/0:t.id;function su(t){try{for(Ut=0;Ut<Ye.length;Ut++){const e=Ye[Ut];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),Hi(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(),Lr=null,(Ye.length||Wi.length)&&su()}}let He=null,ou=null;function Nr(t){const e=He;return He=t,ou=t&&t.type.__scopeId||null,e}function An(t,e=He,i){if(!e||t._n)return t;const n=(...r)=>{n._d&&qu(-1);const s=Nr(e);let o;try{o=t(...r)}finally{Nr(s),n._d&&qu(1)}return o};return n._n=!0,n._c=!0,n._d=!0,n}function au(t,e){if(He===null)return t;const i=Kr(He),n=t.dirs||(t.dirs=[]);for(let r=0;r<e.length;r++){let[s,o,a,c=le]=e[r];s&&(Z(s)&&(s={mounted:s,updated:s}),s.deep&&Zt(o),n.push({dir:s,instance:i,value:o,oldValue:void 0,arg:a,modifiers:c}))}return t}function Si(t,e,i,n){const r=t.dirs,s=e&&e.dirs;for(let o=0;o<r.length;o++){const a=r[o];s&&(a.oldValue=s[o].value);let c=a.dir[n];c&&(Mt(),jt(c,i,8,[t.el,a,t,e]),Dt())}}function lu(t,e){if(Ke){let i=Ke.provides;const n=Ke.parent&&Ke.parent.provides;n===i&&(i=Ke.provides=Object.create(n)),i[t]=e}}function Tn(t,e,i=!1){const n=ia();if(n||Qi){let r=Qi?Qi._context.provides:n?n.parent==null||n.ce?n.vnode.appContext&&n.vnode.appContext.provides:n.parent.provides:void 0;if(r&&t in r)return r[t];if(arguments.length>1)return i&&Z(e)?e.call(n&&n.proxy):e}}const _y=Symbol.for("v-scx"),xy=()=>Tn(_y);function ky(t,e){return jo(t,null,{flush:"sync"})}function Vi(t,e,i){return jo(t,e,i)}function jo(t,e,i=le){const{immediate:n,deep:r,flush:s,once:o}=i,a=Ue({},i),c=e&&n||!e&&s!=="post";let l;if(Xi){if(s==="sync"){const p=xy();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,x)=>jt(p,u,h,x);let d=!1;s==="post"?a.scheduler=p=>{lt(p,u&&u.suspense)}:s!=="sync"&&(d=!0,a.scheduler=(p,h)=>{h?p():Do(p)}),a.augmentJob=p=>{e&&(p.flags|=4),d&&(p.flags|=2,u&&(p.id=u.uid,p.i=u))};const m=hy(t,e,a);return Xi&&(l?l.push(m):c&&m()),m}function Sy(t,e,i){const n=this.proxy,r=Ie(t)?t.includes(".")?cu(n,t):()=>n[t]:t.bind(n,n);let s;Z(e)?s=e:(s=e.handler,i=e);const o=Bn(this),a=jo(r,s.bind(n),i);return o(),a}function cu(t,e){const i=e.split(".");return()=>{let n=t;for(let r=0;r<i.length&&n;r++)n=n[i[r]];return n}}const $y=Symbol("_vte"),Ey=t=>t.__isTeleport,Py=Symbol("_leaveCb");function Uo(t,e){t.shapeFlag&6&&t.component?(t.transition=e,Uo(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)?Ue({name:t.name},e,{setup:t}):t}function Fo(t){t.ids=[t.ids[0]+t.ids[2]+++"-",0,0]}function uu(t){const e=ia(),i=Xc(null);if(e){const r=e.refs===le?e.refs={}:e.refs;Object.defineProperty(r,t,{enumerable:!0,get:()=>i.value,set:s=>i.value=s})}return i}const Mr=new WeakMap;function On(t,e,i,n,r=!1){if(J(t)){t.forEach((h,x)=>On(h,e&&(J(e)?e[x]:e),i,n,r));return}if(Gi(n)&&!r){n.shapeFlag&512&&n.type.__asyncResolved&&n.component.subTree.component&&On(t,e,i,n.component.subTree);return}const s=n.shapeFlag&4?Kr(n.component):n.el,o=r?null:s,{i:a,r:c}=t,l=e&&e.r,u=a.refs===le?a.refs={}:a.refs,d=a.setupState,m=oe(d),p=d===le?xc:h=>ce(m,h);if(l!=null&&l!==c){if(du(e),Ie(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))Hi(c,a,12,[o,u]);else{const h=Ie(c),x=De(c);if(h||x){const k=()=>{if(t.f){const E=h?p(c)?d[c]:u[c]:c.value;if(r)J(E)&&yo(E,s);else if(J(E))E.includes(s)||E.push(s);else if(h)u[c]=[s],p(c)&&(d[c]=u[c]);else{const y=[s];c.value=y,t.k&&(u[t.k]=y)}}else h?(u[c]=o,p(c)&&(d[c]=o)):x&&(c.value=o,t.k&&(u[t.k]=o))};if(o){const E=()=>{k(),Mr.delete(t)};E.id=-1,Mr.set(t,E),lt(E,i)}else du(t),k()}}}function du(t){const e=Mr.get(t);e&&(e.flags|=8,Mr.delete(t))}const fu=t=>t.nodeType===8;$r().requestIdleCallback,$r().cancelIdleCallback;function Cy(t,e){if(fu(t)&&t.data==="["){let i=1,n=t.nextSibling;for(;n;){if(n.nodeType===1){if(e(n)===!1)break}else if(fu(n))if(n.data==="]"){if(--i===0)break}else n.data==="["&&i++;n=n.nextSibling}}else e(t)}const Gi=t=>!!t.type.__asyncLoader;function Iy(t){Z(t)&&(t={loader:t});const{loader:e,loadingComponent:i,errorComponent:n,delay:r=200,hydrate:s,timeout:o,suspensible:a=!0,onError:c}=t;let l=null,u,d=0;const m=()=>(d++,l=null,p()),p=()=>{let h;return l||(h=l=e().catch(x=>{if(x=x instanceof Error?x:new Error(String(x)),c)return new Promise((k,E)=>{c(x,()=>k(m()),()=>E(x),d+1)});throw x}).then(x=>h!==l&&l?l:(x&&(x.__esModule||x[Symbol.toStringTag]==="Module")&&(x=x.default),u=x,x)))};return $i({name:"AsyncComponentWrapper",__asyncLoader:p,__asyncHydrate(h,x,k){let E=!1;(x.bu||(x.bu=[])).push(()=>E=!0);const y=()=>{E||k()},b=s?()=>{const g=s(y,w=>Cy(h,w));g&&(x.bum||(x.bum=[])).push(g)}:y;u?b():p().then(()=>!x.isUnmounted&&b())},get __asyncResolved(){return u},setup(){const h=Ke;if(Fo(h),u)return()=>Dr(u,h);const x=b=>{l=null,Cn(b,h,13,!n)};if(a&&h.suspense||Xi)return p().then(b=>()=>Dr(b,h)).catch(b=>(x(b),()=>n?Ne(n,{error:b}):null));const k=Qe(!1),E=Qe(),y=Qe(!!r);return r&&setTimeout(()=>{y.value=!1},r),o!=null&&setTimeout(()=>{if(!k.value&&!E.value){const b=new Error(`Async component timed out after ${o}ms.`);x(b),E.value=b}},o),p().then(()=>{k.value=!0,h.parent&&Bo(h.parent.vnode)&&h.parent.update()}).catch(b=>{x(b),E.value=b}),()=>{if(k.value&&u)return Dr(u,h);if(E.value&&n)return Ne(n,{error:E.value});if(i&&!y.value)return Dr(i,h)}}})}function Dr(t,e){const{ref:i,props:n,children:r,ce:s}=e.vnode,o=Ne(t,n,r);return o.ref=i,o.ce=s,delete e.vnode.ce,o}const Bo=t=>t.type.__isKeepAlive;function Ry(t,e){hu(t,"a",e)}function Ay(t,e){hu(t,"da",e)}function hu(t,e,i=Ke){const n=t.__wdc||(t.__wdc=()=>{let r=i;for(;r;){if(r.isDeactivated)return;r=r.parent}return t()});if(jr(e,n,i),i){let r=i.parent;for(;r&&r.parent;)Bo(r.parent.vnode)&&Ty(n,e,i,r),r=r.parent}}function Ty(t,e,i,n){const r=jr(e,t,n,!0);zo(()=>{yo(n[e],r)},i)}function jr(t,e,i=Ke,n=!1){if(i){const r=i[t]||(i[t]=[]),s=e.__weh||(e.__weh=(...o)=>{Mt();const a=Bn(i),c=jt(e,i,t,o);return a(),Dt(),c});return n?r.unshift(s):r.push(s),s}}const ei=t=>(e,i=Ke)=>{(!Xi||t==="sp")&&jr(t,(...n)=>e(...n),i)},pu=ei("bm"),Ln=ei("m"),Oy=ei("bu"),Ly=ei("u"),qo=ei("bum"),zo=ei("um"),Ny=ei("sp"),My=ei("rtg"),Dy=ei("rtc");function jy(t,e=Ke){jr("ec",t,e)}const Uy=Symbol.for("v-ndc");function Ho(t,e,i,n){let r;const s=i,o=J(t);if(o||Ie(t)){const a=o&&xi(t);let c=!1,l=!1;a&&(c=!mt(t),l=Jt(t),t=Pr(t)),r=new Array(t.length);for(let u=0,d=t.length;u<d;u++)r[u]=e(c?l?zi(kt(t[u])):kt(t[u]):t[u],u,void 0,s)}else if(typeof t=="number"){r=new Array(t);for(let a=0;a<t;a++)r[a]=e(a+1,a,void 0,s)}else if(ke(t))if(t[Symbol.iterator])r=Array.from(t,(a,c)=>e(a,c,void 0,s));else{const a=Object.keys(t);r=new Array(a.length);for(let c=0,l=a.length;c<l;c++){const u=a[c];r[c]=e(t[u],u,c,s)}}else r=[];return r}function Fy(t,e,i={},n,r){if(He.ce||He.parent&&Gi(He.parent)&&He.parent.ce){const l=Object.keys(i).length>0;return ue(),zr(We,null,[Ne("slot",i,n)],l?-2:64)}let s=t[e];s&&s._c&&(s._d=!1),ue();const o=s&&gu(s(i)),a=i.key||o&&o.key,c=zr(We,{key:(a&&!Gt(a)?a:`_${e}`)+(!o&&n?"_fb":"")},o||[],o&&t._===1?64:-2);return c.scopeId&&(c.slotScopeIds=[c.scopeId+"-s"]),s&&s._c&&(s._d=!0),c}function gu(t){return t.some(e=>ea(e)?!(e.type===ti||e.type===We&&!gu(e.children)):!0)?t:null}const Wo=t=>t?Vu(t)?Kr(t):Wo(t.parent):null,Nn=Ue(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=>Wo(t.parent),$root:t=>Wo(t.root),$host:t=>t.ce,$emit:t=>t.emit,$options:t=>vu(t),$forceUpdate:t=>t.f||(t.f=()=>{Do(t.update)}),$nextTick:t=>t.n||(t.n=In.bind(t.proxy)),$watch:t=>Sy.bind(t)}),Ko=(t,e)=>t!==le&&!t.__isScriptSetup&&ce(t,e),By={get({_:t},e){if(e==="__v_skip")return!0;const{ctx:i,setupState:n,data:r,props:s,accessCache:o,type:a,appContext:c}=t;if(e[0]!=="$"){const m=o[e];if(m!==void 0)switch(m){case 1:return n[e];case 2:return r[e];case 4:return i[e];case 3:return s[e]}else{if(Ko(n,e))return o[e]=1,n[e];if(r!==le&&ce(r,e))return o[e]=2,r[e];if(ce(s,e))return o[e]=3,s[e];if(i!==le&&ce(i,e))return o[e]=4,i[e];Vo&&(o[e]=0)}}const l=Nn[e];let u,d;if(l)return e==="$attrs"&&ze(t.attrs,"get",""),l(t);if((u=a.__cssModules)&&(u=u[e]))return u;if(i!==le&&ce(i,e))return o[e]=4,i[e];if(d=c.config.globalProperties,ce(d,e))return d[e]},set({_:t},e,i){const{data:n,setupState:r,ctx:s}=t;return Ko(r,e)?(r[e]=i,!0):n!==le&&ce(n,e)?(n[e]=i,!0):ce(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(s[e]=i,!0)},has({_:{data:t,setupState:e,accessCache:i,ctx:n,appContext:r,props:s,type:o}},a){let c;return!!(i[a]||t!==le&&a[0]!=="$"&&ce(t,a)||Ko(e,a)||ce(s,a)||ce(n,a)||ce(Nn,a)||ce(r.config.globalProperties,a)||(c=o.__cssModules)&&c[a])},defineProperty(t,e,i){return i.get!=null?t._.accessCache[e]=0:ce(i,"value")&&this.set(t,e,i.value,null),Reflect.defineProperty(t,e,i)}};function Ur(t){return J(t)?t.reduce((e,i)=>(e[i]=null,e),{}):t}function mu(t,e){return!t||!e?t||e:J(t)&&J(e)?t.concat(e):Ue({},Ur(t),Ur(e))}let Vo=!0;function qy(t){const e=vu(t),i=t.proxy,n=t.ctx;Vo=!1,e.beforeCreate&&yu(e.beforeCreate,t,"bc");const{data:r,computed:s,methods:o,watch:a,provide:c,inject:l,created:u,beforeMount:d,mounted:m,beforeUpdate:p,updated:h,activated:x,deactivated:k,beforeDestroy:E,beforeUnmount:y,destroyed:b,unmounted:g,render:w,renderTracked:S,renderTriggered:R,errorCaptured:B,serverPrefetch:N,expose:Y,inheritAttrs:K,components:Fe,directives:fe,filters:Ae}=e;if(l&&zy(l,n,null),o)for(const me in o){const ge=o[me];Z(ge)&&(n[me]=ge.bind(i))}if(r){const me=r.call(i,i);ke(me)&&(t.data=Oo(me))}if(Vo=!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,on=!Z(ge)&&Z(ge.set)?ge.set.bind(i):Nt,ri=qt({get:ni,set:on});Object.defineProperty(n,me,{enumerable:!0,configurable:!0,get:()=>ri.value,set:Et=>ri.value=Et})}if(a)for(const me in a)bu(a[me],n,i,me);if(c){const me=Z(c)?c.call(i):c;Reflect.ownKeys(me).forEach(ge=>{lu(ge,me[ge])})}u&&yu(u,t,"c");function ae(me,ge){J(ge)?ge.forEach(ni=>me(ni.bind(i))):ge&&me(ge.bind(i))}if(ae(pu,d),ae(Ln,m),ae(Oy,p),ae(Ly,h),ae(Ry,x),ae(Ay,k),ae(jy,B),ae(Dy,S),ae(My,R),ae(qo,y),ae(zo,g),ae(Ny,N),J(Y))if(Y.length){const me=t.exposed||(t.exposed={});Y.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),Fe&&(t.components=Fe),fe&&(t.directives=fe),N&&Fo(t)}function zy(t,e,i=Nt){J(t)&&(t=Go(t));for(const n in t){const r=t[n];let s;ke(r)?"default"in r?s=Tn(r.from||n,r.default,!0):s=Tn(r.from||n):s=Tn(r),De(s)?Object.defineProperty(e,n,{enumerable:!0,configurable:!0,get:()=>s.value,set:o=>s.value=o}):e[n]=s}}function yu(t,e,i){jt(J(t)?t.map(n=>n.bind(e.proxy)):t.bind(e.proxy),e,i)}function bu(t,e,i,n){let r=n.includes(".")?cu(i,n):()=>i[n];if(Ie(t)){const s=e[t];Z(s)&&Vi(r,s)}else if(Z(t))Vi(r,t.bind(i));else if(ke(t))if(J(t))t.forEach(s=>bu(s,e,i,n));else{const s=Z(t.handler)?t.handler.bind(i):e[t.handler];Z(s)&&Vi(r,s,t)}}function vu(t){const e=t.type,{mixins:i,extends:n}=e,{mixins:r,optionsCache:s,config:{optionMergeStrategies:o}}=t.appContext,a=s.get(e);let c;return a?c=a:!r.length&&!i&&!n?c=e:(c={},r.length&&r.forEach(l=>Fr(c,l,o,!0)),Fr(c,e,o)),ke(e)&&s.set(e,c),c}function Fr(t,e,i,n=!1){const{mixins:r,extends:s}=e;s&&Fr(t,s,i,!0),r&&r.forEach(o=>Fr(t,o,i,!0));for(const o in e)if(!(n&&o==="expose")){const a=Hy[o]||i&&i[o];t[o]=a?a(t[o],e[o]):e[o]}return t}const Hy={data:wu,props:_u,emits:_u,methods:Mn,computed:Mn,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:Mn,directives:Mn,watch:Ky,provide:wu,inject:Wy};function wu(t,e){return e?t?function(){return Ue(Z(t)?t.call(this,this):t,Z(e)?e.call(this,this):e)}:e:t}function Wy(t,e){return Mn(Go(t),Go(e))}function Go(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 Mn(t,e){return t?Ue(Object.create(null),t,e):e}function _u(t,e){return t?J(t)&&J(e)?[...new Set([...t,...e])]:Ue(Object.create(null),Ur(t),Ur(e??{})):e}function Ky(t,e){if(!t)return e;if(!e)return t;const i=Ue(Object.create(null),t);for(const n in e)i[n]=Xe(t[n],e[n]);return i}function xu(){return{app:null,config:{isNativeTag:xc,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 Vy=0;function Gy(t,e){return function(n,r=null){Z(n)||(n=Ue({},n)),r!=null&&!ke(r)&&(r=null);const s=xu(),o=new WeakSet,a=[];let c=!1;const l=s.app={_uid:Vy++,_component:n,_props:r,_container:null,_context:s,_instance:null,version:Eb,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,m){if(!c){const p=l._ceVNode||Ne(n,r);return p.appContext=s,m===!0?m="svg":m===!1&&(m=void 0),t(p,u,m),c=!0,l._container=u,u.__vue_app__=l,Kr(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=Qi;Qi=l;try{return u()}finally{Qi=d}}};return l}}let Qi=null;function ku(t,e,i=le){const n=ia(),r=Qt(e),s=li(e),o=Su(t,r),a=cy((c,l)=>{let u,d=le,m;return ky(()=>{const p=t[r];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 x=n.vnode.props;x&&(e in x||r in x||s in x)&&(`onUpdate:${e}`in x||`onUpdate:${r}`in x||`onUpdate:${s}`in x)||(u=p,l()),n.emit(`update:${e}`,h),it(p,h)&&it(p,d)&&!it(h,m)&&l(),d=p,m=h}}});return a[Symbol.iterator]=()=>{let c=0;return{next(){return c<2?{value:c++?o||le:a,done:!1}:{done:!0}}}},a}const Su=(t,e)=>e==="modelValue"||e==="model-value"?t.modelModifiers:t[`${e}Modifiers`]||t[`${Qt(e)}Modifiers`]||t[`${li(e)}Modifiers`];function Qy(t,e,...i){if(t.isUnmounted)return;const n=t.vnode.props||le;let r=i;const s=e.startsWith("update:"),o=s&&Su(n,e.slice(7));o&&(o.trim&&(r=i.map(u=>Ie(u)?u.trim():u)),o.number&&(r=i.map(wo)));let a,c=n[a=vo(e)]||n[a=vo(Qt(e))];!c&&s&&(c=n[a=vo(li(e))]),c&&jt(c,t,6,r);const l=n[a+"Once"];if(l){if(!t.emitted)t.emitted={};else if(t.emitted[a])return;t.emitted[a]=!0,jt(l,t,6,r)}}const Yy=new WeakMap;function $u(t,e,i=!1){const n=i?Yy:e.emitsCache,r=n.get(t);if(r!==void 0)return r;const s=t.emits;let o={},a=!1;if(!Z(t)){const c=l=>{const u=$u(l,e,!0);u&&(a=!0,Ue(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)&&n.set(t,null),null):(J(s)?s.forEach(c=>o[c]=null):Ue(o,s),ke(t)&&n.set(t,o),o)}function Br(t,e){return!t||!_r(e)?!1:(e=e.slice(2).replace(/Once$/,""),ce(t,e[0].toLowerCase()+e.slice(1))||ce(t,li(e))||ce(t,e))}function j0(){}function Eu(t){const{type:e,vnode:i,proxy:n,withProxy:r,propsOptions:[s],slots:o,attrs:a,emit:c,render:l,renderCache:u,props:d,data:m,setupState:p,ctx:h,inheritAttrs:x}=t,k=Nr(t);let E,y;try{if(i.shapeFlag&4){const g=r||n,w=g;E=Ft(l.call(w,g,u,d,p,m,h)),y=a}else{const g=e;E=Ft(g.length>1?g(d,{attrs:a,slots:o,emit:c}):g(d,null)),y=e.props?a:Xy(a)}}catch(g){Dn.length=0,Cn(g,t,1),E=Ne(ti)}let b=E;if(y&&x!==!1){const g=Object.keys(y),{shapeFlag:w}=b;g.length&&w&7&&(s&&g.some(mo)&&(y=Jy(y,s)),b=Yi(b,y,!1,!0))}return i.dirs&&(b=Yi(b,null,!1,!0),b.dirs=b.dirs?b.dirs.concat(i.dirs):i.dirs),i.transition&&Uo(b,i.transition),E=b,Nr(k),E}const Xy=t=>{let e;for(const i in t)(i==="class"||i==="style"||_r(i))&&((e||(e={}))[i]=t[i]);return e},Jy=(t,e)=>{const i={};for(const n in t)(!mo(n)||!(n.slice(9)in e))&&(i[n]=t[n]);return i};function Zy(t,e,i){const{props:n,children:r,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 n?Pu(n,o,l):!!o;if(c&8){const u=e.dynamicProps;for(let d=0;d<u.length;d++){const m=u[d];if(o[m]!==n[m]&&!Br(l,m))return!0}}}else return(r||a)&&(!a||!a.$stable)?!0:n===o?!1:n?o?Pu(n,o,l):!0:!!o;return!1}function Pu(t,e,i){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!0;for(let r=0;r<n.length;r++){const s=n[r];if(e[s]!==t[s]&&!Br(i,s))return!0}return!1}function eb({vnode:t,parent:e},i){for(;e;){const n=e.subTree;if(n.suspense&&n.suspense.activeBranch===t&&(n.el=t.el),n===t)(t=e.vnode).el=i,e=e.parent;else break}}const Cu={},Iu=()=>Object.create(Cu),Ru=t=>Object.getPrototypeOf(t)===Cu;function tb(t,e,i,n=!1){const r={},s=Iu();t.propsDefaults=Object.create(null),Au(t,e,r,s);for(const o in t.propsOptions[0])o in r||(r[o]=void 0);i?t.props=n?r:ry(r):t.type.props?t.props=r:t.props=s,t.attrs=s}function ib(t,e,i,n){const{props:r,attrs:s,vnode:{patchFlag:o}}=t,a=oe(r),[c]=t.propsOptions;let l=!1;if((n||o>0)&&!(o&16)){if(o&8){const u=t.vnode.dynamicProps;for(let d=0;d<u.length;d++){let m=u[d];if(Br(t.emitsOptions,m))continue;const p=e[m];if(c)if(ce(s,m))p!==s[m]&&(s[m]=p,l=!0);else{const h=Qt(m);r[h]=Qo(c,a,h,p,t,!1)}else p!==s[m]&&(s[m]=p,l=!0)}}}else{Au(t,e,r,s)&&(l=!0);let u;for(const d in a)(!e||!ce(e,d)&&((u=li(d))===d||!ce(e,u)))&&(c?i&&(i[d]!==void 0||i[u]!==void 0)&&(r[d]=Qo(c,a,d,void 0,t,!0)):delete r[d]);if(s!==a)for(const d in s)(!e||!ce(e,d))&&(delete s[d],l=!0)}l&&Yt(t.attrs,"set","")}function Au(t,e,i,n){const[r,s]=t.propsOptions;let o=!1,a;if(e)for(let c in e){if(_n(c))continue;const l=e[c];let u;r&&ce(r,u=Qt(c))?!s||!s.includes(u)?i[u]=l:(a||(a={}))[u]=l:Br(t.emitsOptions,c)||(!(c in n)||l!==n[c])&&(n[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]=Qo(r,c,d,l[d],t,!ce(l,d))}}return o}function Qo(t,e,i,n,r,s){const o=t[i];if(o!=null){const a=ce(o,"default");if(a&&n===void 0){const c=o.default;if(o.type!==Function&&!o.skipFactory&&Z(c)){const{propsDefaults:l}=r;if(i in l)n=l[i];else{const u=Bn(r);n=l[i]=c.call(null,e),u()}}else n=c;r.ce&&r.ce._setProp(i,n)}o[0]&&(s&&!a?n=!1:o[1]&&(n===""||n===li(i))&&(n=!0))}return n}const nb=new WeakMap;function Tu(t,e,i=!1){const n=i?nb:e.propsCache,r=n.get(t);if(r)return r;const s=t.props,o={},a=[];let c=!1;if(!Z(t)){const u=d=>{c=!0;const[m,p]=Tu(d,e,!0);Ue(o,m),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)&&n.set(t,Fi),Fi;if(J(s))for(let u=0;u<s.length;u++){const d=Qt(s[u]);Ou(d)&&(o[d]=le)}else if(s)for(const u in s){const d=Qt(u);if(Ou(d)){const m=s[u],p=o[d]=J(m)||Z(m)?{type:m}:Ue({},m),h=p.type;let x=!1,k=!0;if(J(h))for(let E=0;E<h.length;++E){const y=h[E],b=Z(y)&&y.name;if(b==="Boolean"){x=!0;break}else b==="String"&&(k=!1)}else x=Z(h)&&h.name==="Boolean";p[0]=x,p[1]=k,(x||ce(p,"default"))&&a.push(d)}}const l=[o,a];return ke(t)&&n.set(t,l),l}function Ou(t){return t[0]!=="$"&&!_n(t)}const Yo=t=>t==="_"||t==="_ctx"||t==="$stable",Xo=t=>J(t)?t.map(Ft):[Ft(t)],rb=(t,e,i)=>{if(e._n)return e;const n=An((...r)=>Xo(e(...r)),i);return n._c=!1,n},Lu=(t,e,i)=>{const n=t._ctx;for(const r in t){if(Yo(r))continue;const s=t[r];if(Z(s))e[r]=rb(r,s,n);else if(s!=null){const o=Xo(s);e[r]=()=>o}}},Nu=(t,e)=>{const i=Xo(e);t.slots.default=()=>i},Mu=(t,e,i)=>{for(const n in e)(i||!Yo(n))&&(t[n]=e[n])},sb=(t,e,i)=>{const n=t.slots=Iu();if(t.vnode.shapeFlag&32){const r=e._;r?(Mu(n,e,i),i&&Cc(n,"_",r,!0)):Lu(e,n)}else e&&Nu(t,e)},ob=(t,e,i)=>{const{vnode:n,slots:r}=t;let s=!0,o=le;if(n.shapeFlag&32){const a=e._;a?i&&a===1?s=!1:Mu(r,e,i):(s=!e.$stable,Lu(e,r)),o=e}else e&&(Nu(t,e),o={default:1});if(s)for(const a in r)!Yo(a)&&o[a]==null&&delete r[a]},lt=db;function ab(t){return lb(t)}function lb(t,e){const i=$r();i.__VUE__=!0;const{insert:n,remove:r,patchProp:s,createElement:o,createText:a,createComment:c,setText:l,setElementText:u,parentNode:d,nextSibling:m,setScopeId:p=Nt,insertStaticContent:h}=t,x=(v,_,P,T=null,A=null,O=null,q=void 0,F=null,j=!!_.dynamicChildren)=>{if(v===_)return;v&&!Un(v,_)&&(T=z(v),Et(v,A,O,!0),v=null),_.patchFlag===-2&&(j=!1,_.dynamicChildren=null);const{type:L,ref:G,shapeFlag:H}=_;switch(L){case qr:k(v,_,P,T);break;case ti:E(v,_,P,T);break;case Zo:v==null&&y(_,P,T,q);break;case We:Fe(v,_,P,T,A,O,q,F,j);break;default:H&1?w(v,_,P,T,A,O,q,F,j):H&6?fe(v,_,P,T,A,O,q,F,j):(H&64||H&128)&&L.process(v,_,P,T,A,O,q,F,j,we)}G!=null&&A?On(G,v&&v.ref,O,_||v,!_):G==null&&v&&v.ref!=null&&On(v.ref,null,O,v,!0)},k=(v,_,P,T)=>{if(v==null)n(_.el=a(_.children),P,T);else{const A=_.el=v.el;_.children!==v.children&&l(A,_.children)}},E=(v,_,P,T)=>{v==null?n(_.el=c(_.children||""),P,T):_.el=v.el},y=(v,_,P,T)=>{[v.el,v.anchor]=h(v.children,_,P,T,v.el,v.anchor)},b=({el:v,anchor:_},P,T)=>{let A;for(;v&&v!==_;)A=m(v),n(v,P,T),v=A;n(_,P,T)},g=({el:v,anchor:_})=>{let P;for(;v&&v!==_;)P=m(v),r(v),v=P;r(_)},w=(v,_,P,T,A,O,q,F,j)=>{if(_.type==="svg"?q="svg":_.type==="math"&&(q="mathml"),v==null)S(_,P,T,A,O,q,F,j);else{const L=v.el&&v.el._isVueCE?v.el:null;try{L&&L._beginPatch(),N(v,_,A,O,q,F,j)}finally{L&&L._endPatch()}}},S=(v,_,P,T,A,O,q,F)=>{let j,L;const{props:G,shapeFlag:H,transition:V,dirs:ee}=v;if(j=v.el=o(v.type,O,G&&G.is,G),H&8?u(j,v.children):H&16&&B(v.children,j,null,T,A,Jo(v,O),q,F),ee&&Si(v,null,T,"created"),R(j,v,v.scopeId,q,T),G){for(const _e in G)_e!=="value"&&!_n(_e)&&s(j,_e,null,G[_e],O,T);"value"in G&&s(j,"value",null,G.value,O),(L=G.onVnodeBeforeMount)&&Bt(L,T,v)}ee&&Si(v,null,T,"beforeMount");const se=cb(A,V);se&&V.beforeEnter(j),n(j,_,P),((L=G&&G.onVnodeMounted)||se||ee)&&lt(()=>{L&&Bt(L,T,v),se&&V.enter(j),ee&&Si(v,null,T,"mounted")},A)},R=(v,_,P,T,A)=>{if(P&&p(v,P),T)for(let O=0;O<T.length;O++)p(v,T[O]);if(A){let O=A.subTree;if(_===O||Bu(O.type)&&(O.ssContent===_||O.ssFallback===_)){const q=A.vnode;R(v,q,q.scopeId,q.slotScopeIds,A.parent)}}},B=(v,_,P,T,A,O,q,F,j=0)=>{for(let L=j;L<v.length;L++){const G=v[L]=F?fi(v[L]):Ft(v[L]);x(null,G,_,P,T,A,O,q,F)}},N=(v,_,P,T,A,O,q)=>{const F=_.el=v.el;let{patchFlag:j,dynamicChildren:L,dirs:G}=_;j|=v.patchFlag&16;const H=v.props||le,V=_.props||le;let ee;if(P&&Ei(P,!1),(ee=V.onVnodeBeforeUpdate)&&Bt(ee,P,_,v),G&&Si(_,v,P,"beforeUpdate"),P&&Ei(P,!0),(H.innerHTML&&V.innerHTML==null||H.textContent&&V.textContent==null)&&u(F,""),L?Y(v.dynamicChildren,L,F,P,T,Jo(_,A),O):q||ge(v,_,F,null,P,T,Jo(_,A),O,!1),j>0){if(j&16)K(F,H,V,P,A);else if(j&2&&H.class!==V.class&&s(F,"class",null,V.class,A),j&4&&s(F,"style",H.style,V.style,A),j&8){const se=_.dynamicProps;for(let _e=0;_e<se.length;_e++){const he=se[_e],st=H[he],ot=V[he];(ot!==st||he==="value")&&s(F,he,st,ot,A,P)}}j&1&&v.children!==_.children&&u(F,_.children)}else!q&&L==null&&K(F,H,V,P,A);((ee=V.onVnodeUpdated)||G)&&lt(()=>{ee&&Bt(ee,P,_,v),G&&Si(_,v,P,"updated")},T)},Y=(v,_,P,T,A,O,q)=>{for(let F=0;F<_.length;F++){const j=v[F],L=_[F],G=j.el&&(j.type===We||!Un(j,L)||j.shapeFlag&198)?d(j.el):P;x(j,L,G,null,T,A,O,q,!0)}},K=(v,_,P,T,A)=>{if(_!==P){if(_!==le)for(const O in _)!_n(O)&&!(O in P)&&s(v,O,_[O],null,A,T);for(const O in P){if(_n(O))continue;const q=P[O],F=_[O];q!==F&&O!=="value"&&s(v,O,F,q,A,T)}"value"in P&&s(v,"value",_.value,P.value,A)}},Fe=(v,_,P,T,A,O,q,F,j)=>{const L=_.el=v?v.el:a(""),G=_.anchor=v?v.anchor:a("");let{patchFlag:H,dynamicChildren:V,slotScopeIds:ee}=_;ee&&(F=F?F.concat(ee):ee),v==null?(n(L,P,T),n(G,P,T),B(_.children||[],P,G,A,O,q,F,j)):H>0&&H&64&&V&&v.dynamicChildren&&v.dynamicChildren.length===V.length?(Y(v.dynamicChildren,V,P,A,O,q,F),(_.key!=null||A&&_===A.subTree)&&Du(v,_,!0)):ge(v,_,P,G,A,O,q,F,j)},fe=(v,_,P,T,A,O,q,F,j)=>{_.slotScopeIds=F,v==null?_.shapeFlag&512?A.ctx.activate(_,P,T,q,j):Ae(_,P,T,A,O,q,j):Ee(v,_,j)},Ae=(v,_,P,T,A,O,q)=>{const F=v.component=yb(v,T,A);if(Bo(v)&&(F.ctx.renderer=we),bb(F,!1,q),F.asyncDep){if(A&&A.registerDep(F,ae,q),!v.el){const j=F.subTree=Ne(ti);E(null,j,_,P),v.placeholder=j.el}}else ae(F,v,_,P,A,O,q)},Ee=(v,_,P)=>{const T=_.component=v.component;if(Zy(v,_,P))if(T.asyncDep&&!T.asyncResolved){me(T,_,P);return}else T.next=_,T.update();else _.el=v.el,T.vnode=_},ae=(v,_,P,T,A,O,q)=>{const F=()=>{if(v.isMounted){let{next:H,bu:V,u:ee,parent:se,vnode:_e}=v;{const Ht=ju(v);if(Ht){H&&(H.el=_e.el,me(v,H,q)),Ht.asyncDep.then(()=>{v.isUnmounted||F()});return}}let he=H,st;Ei(v,!1),H?(H.el=_e.el,me(v,H,q)):H=_e,V&&Sr(V),(st=H.props&&H.props.onVnodeBeforeUpdate)&&Bt(st,se,H,_e),Ei(v,!0);const ot=Eu(v),zt=v.subTree;v.subTree=ot,x(zt,ot,d(zt.el),z(zt),v,A,O),H.el=ot.el,he===null&&eb(v,ot.el),ee&&lt(ee,A),(st=H.props&&H.props.onVnodeUpdated)&&lt(()=>Bt(st,se,H,_e),A)}else{let H;const{el:V,props:ee}=_,{bm:se,m:_e,parent:he,root:st,type:ot}=v,zt=Gi(_);Ei(v,!1),se&&Sr(se),!zt&&(H=ee&&ee.onVnodeBeforeMount)&&Bt(H,he,_),Ei(v,!0);{st.ce&&st.ce._def.shadowRoot!==!1&&st.ce._injectChildStyle(ot);const Ht=v.subTree=Eu(v);x(null,Ht,P,T,v,A,O),_.el=Ht.el}if(_e&&lt(_e,A),!zt&&(H=ee&&ee.onVnodeMounted)){const Ht=_;lt(()=>Bt(H,he,Ht),A)}(_.shapeFlag&256||he&&Gi(he.vnode)&&he.vnode.shapeFlag&256)&&v.a&&lt(v.a,A),v.isMounted=!0,_=P=T=null}};v.scope.on();const j=v.effect=new Oc(F);v.scope.off();const L=v.update=j.run.bind(j),G=v.job=j.runIfDirty.bind(j);G.i=v,G.id=v.uid,j.scheduler=()=>Do(G),Ei(v,!0),L()},me=(v,_,P)=>{_.component=v;const T=v.vnode.props;v.vnode=_,v.next=null,ib(v,_.props,T,P),ob(v,_.children,P),Mt(),nu(v),Dt()},ge=(v,_,P,T,A,O,q,F,j=!1)=>{const L=v&&v.children,G=v?v.shapeFlag:0,H=_.children,{patchFlag:V,shapeFlag:ee}=_;if(V>0){if(V&128){on(L,H,P,T,A,O,q,F,j);return}else if(V&256){ni(L,H,P,T,A,O,q,F,j);return}}ee&8?(G&16&&M(L,A,O),H!==L&&u(P,H)):G&16?ee&16?on(L,H,P,T,A,O,q,F,j):M(L,A,O,!0):(G&8&&u(P,""),ee&16&&B(H,P,T,A,O,q,F,j))},ni=(v,_,P,T,A,O,q,F,j)=>{v=v||Fi,_=_||Fi;const L=v.length,G=_.length,H=Math.min(L,G);let V;for(V=0;V<H;V++){const ee=_[V]=j?fi(_[V]):Ft(_[V]);x(v[V],ee,P,null,A,O,q,F,j)}L>G?M(v,A,O,!0,!1,H):B(_,P,T,A,O,q,F,j,H)},on=(v,_,P,T,A,O,q,F,j)=>{let L=0;const G=_.length;let H=v.length-1,V=G-1;for(;L<=H&&L<=V;){const ee=v[L],se=_[L]=j?fi(_[L]):Ft(_[L]);if(Un(ee,se))x(ee,se,P,null,A,O,q,F,j);else break;L++}for(;L<=H&&L<=V;){const ee=v[H],se=_[V]=j?fi(_[V]):Ft(_[V]);if(Un(ee,se))x(ee,se,P,null,A,O,q,F,j);else break;H--,V--}if(L>H){if(L<=V){const ee=V+1,se=ee<G?_[ee].el:T;for(;L<=V;)x(null,_[L]=j?fi(_[L]):Ft(_[L]),P,se,A,O,q,F,j),L++}}else if(L>V)for(;L<=H;)Et(v[L],A,O,!0),L++;else{const ee=L,se=L,_e=new Map;for(L=se;L<=V;L++){const ft=_[L]=j?fi(_[L]):Ft(_[L]);ft.key!=null&&_e.set(ft.key,L)}let he,st=0;const ot=V-se+1;let zt=!1,Ht=0;const Yn=new Array(ot);for(L=0;L<ot;L++)Yn[L]=0;for(L=ee;L<=H;L++){const ft=v[L];if(st>=ot){Et(ft,A,O,!0);continue}let Wt;if(ft.key!=null)Wt=_e.get(ft.key);else for(he=se;he<=V;he++)if(Yn[he-se]===0&&Un(ft,_[he])){Wt=he;break}Wt===void 0?Et(ft,A,O,!0):(Yn[Wt-se]=L+1,Wt>=Ht?Ht=Wt:zt=!0,x(ft,_[Wt],P,null,A,O,q,F,j),st++)}const Df=zt?ub(Yn):Fi;for(he=Df.length-1,L=ot-1;L>=0;L--){const ft=se+L,Wt=_[ft],jf=_[ft+1],Uf=ft+1<G?jf.el||Fu(jf):T;Yn[L]===0?x(null,Wt,P,Uf,A,O,q,F,j):zt&&(he<0||L!==Df[he]?ri(Wt,P,Uf,2):he--)}}},ri=(v,_,P,T,A=null)=>{const{el:O,type:q,transition:F,children:j,shapeFlag:L}=v;if(L&6){ri(v.component.subTree,_,P,T);return}if(L&128){v.suspense.move(_,P,T);return}if(L&64){q.move(v,_,P,we);return}if(q===We){n(O,_,P);for(let H=0;H<j.length;H++)ri(j[H],_,P,T);n(v.anchor,_,P);return}if(q===Zo){b(v,_,P);return}if(T!==2&&L&1&&F)if(T===0)F.beforeEnter(O),n(O,_,P),lt(()=>F.enter(O),A);else{const{leave:H,delayLeave:V,afterLeave:ee}=F,se=()=>{v.ctx.isUnmounted?r(O):n(O,_,P)},_e=()=>{O._isLeaving&&O[Py](!0),H(O,()=>{se(),ee&&ee()})};V?V(O,se,_e):_e()}else n(O,_,P)},Et=(v,_,P,T=!1,A=!1)=>{const{type:O,props:q,ref:F,children:j,dynamicChildren:L,shapeFlag:G,patchFlag:H,dirs:V,cacheIndex:ee}=v;if(H===-2&&(A=!1),F!=null&&(Mt(),On(F,null,P,v,!0),Dt()),ee!=null&&(_.renderCache[ee]=void 0),G&256){_.ctx.deactivate(v);return}const se=G&1&&V,_e=!Gi(v);let he;if(_e&&(he=q&&q.onVnodeBeforeUnmount)&&Bt(he,_,v),G&6)C(v.component,P,T);else{if(G&128){v.suspense.unmount(P,T);return}se&&Si(v,null,_,"beforeUnmount"),G&64?v.type.remove(v,_,P,we,T):L&&!L.hasOnce&&(O!==We||H>0&&H&64)?M(L,_,P,!1,!0):(O===We&&H&384||!A&&G&16)&&M(j,_,P),T&&ys(v)}(_e&&(he=q&&q.onVnodeUnmounted)||se)&&lt(()=>{he&&Bt(he,_,v),se&&Si(v,null,_,"unmounted")},P)},ys=v=>{const{type:_,el:P,anchor:T,transition:A}=v;if(_===We){Oi(P,T);return}if(_===Zo){g(v);return}const O=()=>{r(P),A&&!A.persisted&&A.afterLeave&&A.afterLeave()};if(v.shapeFlag&1&&A&&!A.persisted){const{leave:q,delayLeave:F}=A,j=()=>q(P,O);F?F(v.el,O,j):j()}else O()},Oi=(v,_)=>{let P;for(;v!==_;)P=m(v),r(v),v=P;r(_)},C=(v,_,P)=>{const{bum:T,scope:A,job:O,subTree:q,um:F,m:j,a:L}=v;Uu(j),Uu(L),T&&Sr(T),A.stop(),O&&(O.flags|=8,Et(q,v,_,P)),F&&lt(F,_),lt(()=>{v.isUnmounted=!0},_)},M=(v,_,P,T=!1,A=!1,O=0)=>{for(let q=O;q<v.length;q++)Et(v[q],_,P,T,A)},z=v=>{if(v.shapeFlag&6)return z(v.component.subTree);if(v.shapeFlag&128)return v.suspense.next();const _=m(v.anchor||v.el),P=_&&_[$y];return P?m(P):_};let te=!1;const Je=(v,_,P)=>{let T;v==null?_._vnode&&(Et(_._vnode,null,null,!0),T=_._vnode.component):x(_._vnode||null,v,_,null,null,null,P),_._vnode=v,te||(te=!0,nu(T),ru(),te=!1)},we={p:x,um:Et,m:ri,r:ys,mt:Ae,mc:B,pc:ge,pbc:Y,n:z,o:t};return{render:Je,hydrate:void 0,createApp:Gy(Je)}}function Jo({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 Ei({effect:t,job:e},i){i?(t.flags|=32,e.flags|=4):(t.flags&=-33,e.flags&=-5)}function cb(t,e){return(!t||t&&!t.pendingBranch)&&e&&!e.persisted}function Du(t,e,i=!1){const n=t.children,r=e.children;if(J(n)&&J(r))for(let s=0;s<n.length;s++){const o=n[s];let a=r[s];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=r[s]=fi(r[s]),a.el=o.el),!i&&a.patchFlag!==-2&&Du(o,a)),a.type===qr&&(a.patchFlag!==-1?a.el=o.el:a.__elIndex=s+(t.type===We?1:0)),a.type===ti&&!a.el&&(a.el=o.el)}}function ub(t){const e=t.slice(),i=[0];let n,r,s,o,a;const c=t.length;for(n=0;n<c;n++){const l=t[n];if(l!==0){if(r=i[i.length-1],t[r]<l){e[n]=r,i.push(n);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[n]=i[s-1]),i[s]=n)}}for(s=i.length,o=i[s-1];s-- >0;)i[s]=o,o=e[o];return i}function ju(t){const e=t.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:ju(e)}function Uu(t){if(t)for(let e=0;e<t.length;e++)t[e].flags|=8}function Fu(t){if(t.placeholder)return t.placeholder;const e=t.component;return e?Fu(e.subTree):null}const Bu=t=>t.__isSuspense;function db(t,e){e&&e.pendingBranch?J(t)?e.effects.push(...t):e.effects.push(t):wy(t)}const We=Symbol.for("v-fgt"),qr=Symbol.for("v-txt"),ti=Symbol.for("v-cmt"),Zo=Symbol.for("v-stc"),Dn=[];let ct=null;function ue(t=!1){Dn.push(ct=t?null:[])}function fb(){Dn.pop(),ct=Dn[Dn.length-1]||null}let jn=1;function qu(t,e=!1){jn+=t,t<0&&ct&&e&&(ct.hasOnce=!0)}function zu(t){return t.dynamicChildren=jn>0?ct||Fi:null,fb(),jn>0&&ct&&ct.push(t),t}function ve(t,e,i,n,r,s){return zu(ie(t,e,i,n,r,s,!0))}function zr(t,e,i,n,r){return zu(Ne(t,e,i,n,r,!0))}function ea(t){return t?t.__v_isVNode===!0:!1}function Un(t,e){return t.type===e.type&&t.key===e.key}const Hu=({key:t})=>t??null,Hr=({ref:t,ref_key:e,ref_for:i})=>(typeof t=="number"&&(t=""+t),t!=null?Ie(t)||De(t)||Z(t)?{i:He,r:t,k:e,f:!!i}:t:null);function ie(t,e=null,i=null,n=0,r=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&&Hr(e),scopeId:ou,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:n,dynamicProps:r,dynamicChildren:null,appContext:null,ctx:He};return a?(ta(c,i),s&128&&t.normalize(c)):i&&(c.shapeFlag|=Ie(i)?8:16),jn>0&&!o&&ct&&(c.patchFlag>0||s&6)&&c.patchFlag!==32&&ct.push(c),c}const Ne=hb;function hb(t,e=null,i=null,n=0,r=null,s=!1){if((!t||t===Uy)&&(t=ti),ea(t)){const a=Yi(t,e,!0);return i&&ta(a,i),jn>0&&!s&&ct&&(a.shapeFlag&6?ct[ct.indexOf(t)]=a:ct.push(a)),a.patchFlag=-2,a}if($b(t)&&(t=t.__vccOpts),e){e=pb(e);let{class:a,style:c}=e;a&&!Ie(a)&&(e.class=_t(a)),ke(c)&&(No(c)&&!J(c)&&(c=Ue({},c)),e.style=_o(c))}const o=Ie(t)?1:Bu(t)?128:Ey(t)?64:ke(t)?4:Z(t)?2:0;return ie(t,e,i,n,r,o,s,!0)}function pb(t){return t?No(t)||Ru(t)?Ue({},t):t:null}function Yi(t,e,i=!1,n=!1){const{props:r,ref:s,patchFlag:o,children:a,transition:c}=t,l=e?Wu(r||{},e):r,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(Hr(e)):[s,Hr(e)]:Hr(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&&Yi(t.ssContent),ssFallback:t.ssFallback&&Yi(t.ssFallback),placeholder:t.placeholder,el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce};return c&&n&&Uo(u,c.clone(u)),u}function Fn(t=" ",e=0){return Ne(qr,null,t,e)}function di(t="",e=!1){return e?(ue(),zr(ti,null,t)):Ne(ti,null,t)}function Ft(t){return t==null||typeof t=="boolean"?Ne(ti):J(t)?Ne(We,null,t.slice()):ea(t)?fi(t):Ne(qr,null,String(t))}function fi(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:Yi(t)}function ta(t,e){let i=0;const{shapeFlag:n}=t;if(e==null)e=null;else if(J(e))i=16;else if(typeof e=="object")if(n&65){const r=e.default;r&&(r._c&&(r._d=!1),ta(t,r()),r._c&&(r._d=!0));return}else{i=32;const r=e._;!r&&!Ru(e)?e._ctx=He:r===3&&He&&(He.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else Z(e)?(e={default:e,_ctx:He},i=32):(e=String(e),n&64?(i=16,e=[Fn(e)]):i=8);t.children=e,t.shapeFlag|=i}function Wu(...t){const e={};for(let i=0;i<t.length;i++){const n=t[i];for(const r in n)if(r==="class")e.class!==n.class&&(e.class=_t([e.class,n.class]));else if(r==="style")e.style=_o([e.style,n.style]);else if(_r(r)){const s=e[r],o=n[r];o&&s!==o&&!(J(s)&&s.includes(o))&&(e[r]=s?[].concat(s,o):o)}else r!==""&&(e[r]=n[r])}return e}function Bt(t,e,i,n=null){jt(t,e,7,[i,n])}const gb=xu();let mb=0;function yb(t,e,i){const n=t.type,r=(e?e.appContext:t.appContext)||gb,s={uid:mb++,vnode:t,type:n,parent:e,appContext:r,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new jm(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:e?e.provides:Object.create(r.provides),ids:e?e.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:Tu(n,r),emitsOptions:$u(n,r),emit:null,emitted:null,propsDefaults:le,inheritAttrs:n.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=Qy.bind(null,s),t.ce&&t.ce(s),s}let Ke=null;const ia=()=>Ke||He;let Wr,na;{const t=$r(),e=(i,n)=>{let r;return(r=t[i])||(r=t[i]=[]),r.push(n),s=>{r.length>1?r.forEach(o=>o(s)):r[0](s)}};Wr=e("__VUE_INSTANCE_SETTERS__",i=>Ke=i),na=e("__VUE_SSR_SETTERS__",i=>Xi=i)}const Bn=t=>{const e=Ke;return Wr(t),t.scope.on(),()=>{t.scope.off(),Wr(e)}},Ku=()=>{Ke&&Ke.scope.off(),Wr(null)};function Vu(t){return t.vnode.shapeFlag&4}let Xi=!1;function bb(t,e=!1,i=!1){e&&na(e);const{props:n,children:r}=t.vnode,s=Vu(t);tb(t,n,s,e),sb(t,r,i||e);const o=s?vb(t,e):void 0;return e&&na(!1),o}function vb(t,e){const i=t.type;t.accessCache=Object.create(null),t.proxy=new Proxy(t.ctx,By);const{setup:n}=i;if(n){Mt();const r=t.setupContext=n.length>1?_b(t):null,s=Bn(t),o=Hi(n,t,0,[t.props,r]),a=Sc(o);if(Dt(),s(),(a||t.sp)&&!Gi(t)&&Fo(t),a){if(o.then(Ku,Ku),e)return o.then(c=>{Gu(t,c)}).catch(c=>{Cn(c,t,0)});t.asyncDep=o}else Gu(t,o)}else Qu(t)}function Gu(t,e,i){Z(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:ke(e)&&(t.setupState=Zc(e)),Qu(t)}function Qu(t,e,i){const n=t.type;t.render||(t.render=n.render||Nt);{const r=Bn(t);Mt();try{qy(t)}finally{Dt(),r()}}}const wb={get(t,e){return ze(t,"get",""),t[e]}};function _b(t){const e=i=>{t.exposed=i||{}};return{attrs:new Proxy(t.attrs,wb),slots:t.slots,emit:t.emit,expose:e}}function Kr(t){return t.exposed?t.exposeProxy||(t.exposeProxy=new Proxy(Zc(sy(t.exposed)),{get(e,i){if(i in e)return e[i];if(i in Nn)return Nn[i](t)},has(e,i){return i in e||i in Nn}})):t.proxy}const xb=/(?:^|[-_])\w/g,kb=t=>t.replace(xb,e=>e.toUpperCase()).replace(/[-_]/g,"");function Sb(t,e=!0){return Z(t)?t.displayName||t.name:t.name||e&&t.__name}function Yu(t,e,i=!1){let n=Sb(e);if(!n&&e.__file){const r=e.__file.match(/([^/\\]+)\.\w+$/);r&&(n=r[1])}if(!n&&t){const r=s=>{for(const o in s)if(s[o]===e)return o};n=r(t.components)||t.parent&&r(t.parent.type.components)||r(t.appContext.components)}return n?kb(n):i?"App":"Anonymous"}function $b(t){return Z(t)&&"__vccOpts"in t}const qt=(t,e)=>dy(t,e,Xi),Eb="3.5.26";let ra;const Xu=typeof window<"u"&&window.trustedTypes;if(Xu)try{ra=Xu.createPolicy("vue",{createHTML:t=>t})}catch{}const Ju=ra?t=>ra.createHTML(t):t=>t,Pb="http://www.w3.org/2000/svg",Cb="http://www.w3.org/1998/Math/MathML",ii=typeof document<"u"?document:null,Zu=ii&&ii.createElement("template"),Ib={insert:(t,e,i)=>{e.insertBefore(t,i||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,i,n)=>{const r=e==="svg"?ii.createElementNS(Pb,t):e==="mathml"?ii.createElementNS(Cb,t):i?ii.createElement(t,{is:i}):ii.createElement(t);return t==="select"&&n&&n.multiple!=null&&r.setAttribute("multiple",n.multiple),r},createText:t=>ii.createTextNode(t),createComment:t=>ii.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>ii.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,i,n,r,s){const o=i?i.previousSibling:e.lastChild;if(r&&(r===s||r.nextSibling))for(;e.insertBefore(r.cloneNode(!0),i),!(r===s||!(r=r.nextSibling)););else{Zu.innerHTML=Ju(n==="svg"?`<svg>${t}</svg>`:n==="mathml"?`<math>${t}</math>`:t);const a=Zu.content;if(n==="svg"||n==="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]}},Rb=Symbol("_vtc");function Ab(t,e,i){const n=t[Rb];n&&(e=(e?[e,...n]:[...n]).join(" ")),e==null?t.removeAttribute("class"):i?t.setAttribute("class",e):t.className=e}const ed=Symbol("_vod"),Tb=Symbol("_vsh"),Ob=Symbol(""),Lb=/(?:^|;)\s*display\s*:/;function Nb(t,e,i){const n=t.style,r=Ie(i);let s=!1;if(i&&!r){if(e)if(Ie(e))for(const o of e.split(";")){const a=o.slice(0,o.indexOf(":")).trim();i[a]==null&&Vr(n,a,"")}else for(const o in e)i[o]==null&&Vr(n,o,"");for(const o in i)o==="display"&&(s=!0),Vr(n,o,i[o])}else if(r){if(e!==i){const o=n[Ob];o&&(i+=";"+o),n.cssText=i,s=Lb.test(i)}}else e&&t.removeAttribute("style");ed in t&&(t[ed]=s?n.display:"",t[Tb]&&(n.display="none"))}const td=/\s*!important$/;function Vr(t,e,i){if(J(i))i.forEach(n=>Vr(t,e,n));else if(i==null&&(i=""),e.startsWith("--"))t.setProperty(e,i);else{const n=Mb(t,e);td.test(i)?t.setProperty(li(n),i.replace(td,""),"important"):t[n]=i}}const id=["Webkit","Moz","ms"],sa={};function Mb(t,e){const i=sa[e];if(i)return i;let n=Qt(e);if(n!=="filter"&&n in t)return sa[e]=n;n=Pc(n);for(let r=0;r<id.length;r++){const s=id[r]+n;if(s in t)return sa[e]=s}return e}const nd="http://www.w3.org/1999/xlink";function rd(t,e,i,n,r,s=Dm(e)){n&&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?"":Gt(i)?String(i):i)}function sd(t,e,i,n,r){if(e==="innerHTML"||e==="textContent"){i!=null&&(t[e]=e==="innerHTML"?Ju(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(r||e)}function Ji(t,e,i,n){t.addEventListener(e,i,n)}function Db(t,e,i,n){t.removeEventListener(e,i,n)}const od=Symbol("_vei");function jb(t,e,i,n,r=null){const s=t[od]||(t[od]={}),o=s[e];if(n&&o)o.value=n;else{const[a,c]=Ub(e);if(n){const l=s[e]=qb(n,r);Ji(t,a,l,c)}else o&&(Db(t,a,o,c),s[e]=void 0)}}const ad=/(?:Once|Passive|Capture)$/;function Ub(t){let e;if(ad.test(t)){e={};let n;for(;n=t.match(ad);)t=t.slice(0,t.length-n[0].length),e[n[0].toLowerCase()]=!0}return[t[2]===":"?t.slice(3):li(t.slice(2)),e]}let oa=0;const Fb=Promise.resolve(),Bb=()=>oa||(Fb.then(()=>oa=0),oa=Date.now());function qb(t,e){const i=n=>{if(!n._vts)n._vts=Date.now();else if(n._vts<=i.attached)return;jt(zb(n,i.value),e,5,[n])};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(n=>r=>!r._stopped&&n&&n(r))}else return e}const ld=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>96&&t.charCodeAt(2)<123,Hb=(t,e,i,n,r,s)=>{const o=r==="svg";e==="class"?Ab(t,n,o):e==="style"?Nb(t,i,n):_r(e)?mo(e)||jb(t,e,i,n,s):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):Wb(t,e,n,o))?(sd(t,e,n),!t.tagName.includes("-")&&(e==="value"||e==="checked"||e==="selected")&&rd(t,e,n,o,s,e!=="value")):t._isVueCE&&(/[A-Z]/.test(e)||!Ie(n))?sd(t,Qt(e),n,s,e):(e==="true-value"?t._trueValue=n:e==="false-value"&&(t._falseValue=n),rd(t,e,n,o))};function Wb(t,e,i,n){if(n)return!!(e==="innerHTML"||e==="textContent"||e in t&&ld(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 r=t.tagName;if(r==="IMG"||r==="VIDEO"||r==="CANVAS"||r==="SOURCE")return!1}return ld(e)&&Ie(i)?!1:e in t}const cd=t=>{const e=t.props["onUpdate:modelValue"]||!1;return J(e)?i=>Sr(e,i):e};function Kb(t){t.target.composing=!0}function ud(t){const e=t.target;e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}const aa=Symbol("_assign");function dd(t,e,i){return e&&(t=t.trim()),i&&(t=wo(t)),t}const fd={created(t,{modifiers:{lazy:e,trim:i,number:n}},r){t[aa]=cd(r);const s=n||r.props&&r.props.type==="number";Ji(t,e?"change":"input",o=>{o.target.composing||t[aa](dd(t.value,i,s))}),(i||s)&&Ji(t,"change",()=>{t.value=dd(t.value,i,s)}),e||(Ji(t,"compositionstart",Kb),Ji(t,"compositionend",ud),Ji(t,"change",ud))},mounted(t,{value:e}){t.value=e??""},beforeUpdate(t,{value:e,oldValue:i,modifiers:{lazy:n,trim:r,number:s}},o){if(t[aa]=cd(o),t.composing)return;const a=(s||t.type==="number")&&!/^0\d/.test(t.value)?wo(t.value):t.value,c=e??"";a!==c&&(document.activeElement===t&&t.type!=="range"&&(n&&e===i||r&&t.value.trim()===c)||(t.value=c))}},Vb=Ue({patchProp:Hb},Ib);let hd;function Gb(){return hd||(hd=ab(Vb))}const Qb=((...t)=>{const e=Gb().createApp(...t),{mount:i}=e;return e.mount=n=>{const r=Xb(n);if(!r)return;const s=e._component;!Z(s)&&!s.render&&!s.template&&(s.template=r.innerHTML),r.nodeType===1&&(r.textContent="");const o=i(r,!1,Yb(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),o},e});function Yb(t){if(t instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&t instanceof MathMLElement)return"mathml"}function Xb(t){return Ie(t)?document.querySelector(t):t}const Jb=1;var Gr;(t=>{t.PackageLoader=new I(I.object({kind:I.union(["autoload","module","umd","styles"]).required().default("autoload"),entry:I.string(),styles:I.array(I.string()),main_export:I.string()})),t.Package=new I(I.object({id:I.string().required(),name:I.string().required(),version:I.string().required(),description:I.string(),author:I.string(),license:I.string(),loader:t.PackageLoader.required()})),t.RegistryMaintainer=new I(I.object({name:I.string().required(),email:I.string()})),t.RegistryRepository=new I(I.object({type:I.string().required(),url:I.string().required()})),t.Registry=new I(I.object({manifest_version:I.number().min(Jb).required(),name:I.string().required(),base_url:I.string().required(),homepage:I.string(),maintainers:I.array(t.RegistryMaintainer),repository:t.RegistryRepository,packages:I.array(t.Package).required()}))})(Gr||(Gr={}));const la=Symbol("IPEInjectKey"),Zb=(t,e)=>(e?e.provide(la,t):lu(la,t),t),ca=()=>{const t=Tn(la);if(!t)throw new Error("InPageEdit instance is not provided");return t},pd=(t,...e)=>{const i=Qb(...e);return Zb(t,i),i};var ev=Object.create,ua=Object.defineProperty,tv=Object.getOwnPropertyDescriptor,gd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),md=t=>{throw TypeError(t)},iv=(t,e,i)=>e in t?ua(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,nv=(t,e)=>ua(t,"name",{value:e,configurable:!0}),rv=t=>[,,,ev(t?.[gd("metadata")]??null)],sv=["class","method","getter","setter","accessor","field","value","get","set"],yd=t=>t!==void 0&&typeof t!="function"?md("Function expected"):t,ov=(t,e,i,n,r)=>({kind:sv[t],name:e,metadata:n,addInitializer:s=>i._?md("Already initialized"):r.push(yd(s||null))}),av=(t,e)=>iv(e,gd("metadata"),t[3]),lv=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},cv=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&tv(r,i));nv(r,i);for(var h=n.length-1;h>=0;h--)c=ov(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,yd(o)&&(r=o);return av(t,r),p&&ua(r,i,p),u?l^4?s:p:r},bd,da,vd;const wd=t=>{if(!t)return null;try{return t.split(".").reduce((e,i)=>e==null?e:e[i],globalThis)}catch{return null}},_d=(t,e,i)=>{if(/^https?:\/\//i.test(t))return t;const n=o=>o.endsWith("/")?o:o+"/";if(/^https?:\/\//i.test(e)){const o=n(e);return new URL(t,o).href}const r=(()=>{try{return new URL(i).href}catch{return new URL(i,location.origin).href}})(),s=new URL(n(e),r).href;return new URL(t,s).href};bd=[xe(["storage","preferences","resourceLoader","$"])];let Qr=($t=class extends(vd=je){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 pd(e,Iy(()=>Promise.resolve().then(()=>J_)))}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:n})=>{const r=f("div",{id:"ipe-plugin-store-preferences-vue"}),s=await this._createManagementApp();return s.mount(r),n(()=>{s.unmount(),this.ctx.logger.debug("Plugin Store preferences app unmounted")}),f("section",{children:r})}}),e.preferences.registerCustomConfig("plugin-store",I.object({"pluginStore.registries":I.array(I.string()).default([Lt.PLUGIN_REGISTRY_URL]).description(i`Registry URLs`).hidden(),"pluginStore.cdnForNpm":I.string().description(i`CDN to install packages from npm`).default('https://cdn.jsdelivr.net/npm/{{ package }}{{ version ? "@" + version : "" }}').hidden(),"pluginStore.plugins":I.array(I.object({source:I.union(["online_manifest","npm"]).default("online_manifest"),registry:I.string().required(),id:I.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 n=await this._createManagementApp();return n.mount(i),e.on(e.Event.Close,()=>{n.unmount()}),e}async install(e,i,n="online_manifest",r="new-added"){const s=await this.getRegistryInfo(e,n);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:r}),c}async uninstall(e,i){const n=this._installedPlugins.get(`${e}#${i}`);if(n===void 0)return!0;this._installedPlugins.delete(`${e}#${i}`);const r=await n;if(r){const s=r.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 n=await this.ctx.preferences.get("pluginStore.plugins")||[];return n.some(s=>s.registry===e&&s.id===i)||(n.push({registry:e,id:i}),await this.ctx.preferences.set("pluginStore.plugins",n)),!0}async removeFromPreferences(e,i){let n=await this.ctx.preferences.get("pluginStore.plugins")||[];return n=n.filter(r=>r.registry!==e||r.id!==i),await this.ctx.preferences.set("pluginStore.plugins",n),!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,n){const r=i.base_url,s=i.packages.find(h=>h.id===n);if(!s)return this.ctx.logger.warn(`Package ${n} 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 ${n}`,o),null;try{d=_d(c,r,e)}catch(h){return this.ctx.logger.warn(`Failed to resolve entry "${c}" with base "${r}" and registry "${e}"`,h),null}}const m={"data-plugin-registry":e,"data-plugin-id":n};let p=null;switch(a){case"autoload":{p=this.ctx.plugin({inject:["resourceLoader"],name:`plugin-store-${e}-${n}`,apply:h=>{d&&h.resourceLoader.loadScript(d,{...m})}});break}case"module":{if(!d)return this.ctx.logger.warn(`Entry url missing for module kind, package ${n}`),null;const h=await import(d).then(x=>(u?x[u]:x.default)??x);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=wd(u);if(!h){if(!d)return this.ctx.logger.warn(`Entry url missing for umd kind, package ${n}`),null;await this.ctx.resourceLoader.loadScript(d,{...m}),h=wd(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(x=>_d(x,r,e)).filter(Boolean)}catch(x){this.ctx.logger.warn(`Failed to resolve styles for ${n}`,l,x)}p||(p=this.ctx.plugin({name:`plugin-store-${e}-${n}`,apply(){}})),p.ctx.plugin({inject:["resourceLoader"],name:`plugin-store-${e}-${n}-styles`,apply:x=>{h.forEach(k=>x.resourceLoader.loadStyle(k,{...m})),x.on("dispose",()=>{try{h.forEach(k=>x.resourceLoader.removeStyle(k))}catch{}})}})}return p}validateRegistry(e){return Gr.Registry(e)}async getRegistryInfo(e,i="online_manifest",n=!1){try{let s;if(i==="online_manifest")s=await this._fetchOnlineRegistryInfo(e,n),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 r=await this.getRegistryCache(e);if(!r)throw this.ctx.emit("plugin-store/registry-not-found",{ctx:this.ctx,registryUrl:e}),new Error(`Failed to fetch registry info: ${e}`);return r}async _fetchOnlineRegistryInfo(e,i=!1){if(!i&&this._onlineRegistryQueries.has(e))return await this._onlineRegistryQueries.get(e);const r=(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,r),await r}async getRegistryCache(e){const i=await this.regInfoDB.get(e);if(i)try{return this.validateRegistry(i)}catch(n){this.ctx.logger.warn("Invalid cached registry",n,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(r=>this.refreshRegistryCache(r))),n={};for(const[r,s]of i.entries())s.status==="fulfilled"?n[e[r]]=s.value:n[e[r]]=null;return n}},$t.PluginStoreSchemas=Gr,$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);da=rv(vd),Qr=cv(da,0,"PluginPluginStore",bd,Qr),lv(da,1,Qr);const uv=Object.freeze(Object.defineProperty({__proto__:null,PluginPluginStore:Qr},Symbol.toStringTag,{value:"Module"})),ut='@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}',xd={arrayAdd:"+",arrayMoveUp:"↑",arrayMoveDown:"↓",arrayRemove:"×",dictAdd:"+",dictRemove:"×",rootLabel:"root"},Se=(t,e)=>{customElements.get(t)||customElements.define(t,e)},dv=(t,e,i)=>{if(!e.length)return;let n=t,r=null,s=null;for(let a=0;a<e.length-1;a++){const c=e[a];let l=n?.[c];l==null?(l=typeof e[a+1]=="number"?[]:{},n[c]=l):typeof l!="object"&&(l=typeof e[a+1]=="number"?[]:{},n[c]=l),r=n,s=c,n=l}const o=e[e.length-1];if(n==null||typeof n!="object"){const a=typeof o=="number"?[]:{};if(r)r[s]=a,n=a;else return}try{n[o]=i}catch{try{const a=Array.isArray(n)?n.slice():{...n};a[o]=i,r&&(r[s]=a)}catch{}}},qn=t=>t.map(String).join("."),fv=t=>t.replace(/[^a-zA-Z0-9_-]/g,"_"),hi=t=>`schema_${fv(qn(t)||"root")}`,Pi=t=>qn(t),re=(t,...e)=>{const i=new Set(e);i.size&&t.setAttribute("part",Array.from(i).join(" "))},hv=["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 fa(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 kd(t){return typeof t=="function"&&!!t?.type}function Sd(t){if(!t)throw new Error("schema is required");if(kd(t))return t;try{const e=Schema.from(t);if(kd(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 yt(t){return t?.meta??{}}function pv(t){return t.length>0&&t.every(e=>e?.type==="const")}function Ci(t){if(!t)return;const e=t,i=e.meta||{};if(Object.prototype.hasOwnProperty.call(i,"default"))return i.default;const n=e.type;try{const r=t();if(r!==void 0)return r}catch{}switch(n){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 r=e.list||[];return r.length?Ci(r[0]):void 0}case"const":return e.value;case"date":return;case"intersect":{const r=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 r)o=s(o,Ci(a));return o}default:return}}class St extends HTMLElement{constructor(){super(),this._path=[],this._i18n=xd,this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=ut,this.$root.appendChild(e)}makeFieldContainer(e,i){const n=document.createElement("div");if(n.className=`field schema-form-item schema-type-${e}`,n.setAttribute("data-path",qn(this._path)),re(n,"field",`field-${e}`),this._label){const r=document.createElement("label");r.className="label",r.textContent=this._label,re(r,"field-label"),n.appendChild(r)}if(i&&i!==this._label){const r=document.createElement("div");r.className="helper",r.textContent=i,re(r,"field-helper"),n.appendChild(r)}return n}set schema(e){this._schema=Sd(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 St{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>${ut}</style>`;const e=yt(this._schema),i=this.makeFieldContainer("string",e.description),n=document.createElement("input");this.$input=n,n.className="input",re(n,"field-input","field-input-text"),n.type="text",n.name=Pi(this._path),n.id=hi(this._path),e?.pattern?.source&&(n.pattern=e.pattern.source),e?.max!=null&&(n.maxLength=e.max),n.value=this._value??"",n.oninput=()=>this.emitChange(fa("string",n.value));const r=i.querySelector("label.label");r&&(r.htmlFor=n.id),i.appendChild(n),this.$root.appendChild(i)}}Se("schema-form-string",$d);class Ed extends St{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>${ut}</style>`;const e=this._schema?.type??"number",i=yt(this._schema),n=this.makeFieldContainer("number",i.description),r=document.createElement("input");this.$input=r,r.className="input",re(r,"field-input","field-input-number"),r.name=Pi(this._path),r.id=hi(this._path),i?.min!=null&&(r.min=String(i.min)),i?.max!=null&&(r.max=String(i.max)),i?.step!=null&&(r.step=String(i.step)),e==="percent"&&!r.step&&(r.step="0.01"),r.value=this._value??"",r.oninput=()=>this.emitChange(fa(e,r.value));const s=n.querySelector("label.label");s&&(s.htmlFor=r.id),i.role==="slider"?r.type="range":r.type="number",n.appendChild(r),this.$root.appendChild(n)}}Se("schema-form-number",Ed);class Pd extends St{render(){this.$root.innerHTML=`<style>${ut}</style>`;const e=yt(this._schema),i=this.makeFieldContainer("boolean",e.description),n=document.createElement("label");n.className="checkbox",re(n,"field-checkbox");const r=document.createElement("input");r.type="checkbox",r.checked=!!this._value,r.name=Pi(this._path),r.id=hi(this._path),re(r,"field-input","field-input-checkbox");const s=document.createElement("span");s.textContent=e.description??this._label??"",re(s,"field-checkbox-text"),r.onchange=()=>this.emitChange(r.checked);const o=i.querySelector("label.label");o&&(o.htmlFor=r.id),n.append(r,s),i.appendChild(n),this.$root.appendChild(i)}}Se("schema-form-boolean",Pd);function Yr(t){return String(t).padStart(2,"0")}function zn(t){return`${t.getFullYear()}-${Yr(t.getMonth()+1)}-${Yr(t.getDate())}`}function ha(t){return`${Yr(t.getHours())}:${Yr(t.getMinutes())}`}function Xr(t){return`${zn(t)}T${ha(t)}`}class Cd extends St{render(){if(this.$input&&this.$root.contains(this.$input)){const o=!!this.$root.querySelector("label.label");if(!(this._label&&!o)){const a=yt(this._schema).role||"date";if(document.activeElement!==this.$input)if(this._value instanceof Date)a==="date"?this.$input.value=zn(this._value):a==="time"?this.$input.value=ha(this._value):a==="datetime"&&(this.$input.value=Xr(this._value));else if(typeof this._value=="string"&&a!=="time"){const c=new Date(this._value);isNaN(+c)||(a==="date"?this.$input.value=zn(c):a==="datetime"&&(this.$input.value=Xr(c)))}else this._value||(this.$input.value="");return}}this.$root.innerHTML=`<style>${ut}</style>`;const e=yt(this._schema),i=this.makeFieldContainer("date",e.description),n=document.createElement("input");this.$input=n,n.className="input",re(n,"field-input","field-input-date");const r=e.role||"date";if(r==="datetime"?n.type="datetime-local":r==="time"?n.type="time":n.type="date",n.name=Pi(this._path),n.id=hi(this._path),this._value instanceof Date)r==="date"?n.value=zn(this._value):r==="time"?n.value=ha(this._value):r==="datetime"&&(n.value=Xr(this._value));else if(typeof this._value=="string"&&r!=="time"){const o=new Date(this._value);isNaN(+o)||(r==="date"?n.value=zn(o):r==="datetime"&&(n.value=Xr(o)))}n.oninput=()=>{e.role;let o;if(!n.value)o=void 0;else{const a=new Date(n.value);o=Number.isNaN(+a)?void 0:a}this.emitChange(o)};const s=i.querySelector("label.label");s&&(s.htmlFor=n.id),i.appendChild(n),this.$root.appendChild(i)}}Se("schema-form-date",Cd);class pa extends St{render(){this.$root.innerHTML=`<style>${ut}</style>`;const e=yt(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),re(o,"field-const-value"),this.$root.appendChild(o);return}}const n=this.makeFieldContainer("const",e.description),r=document.createElement("section");r.className="const content",r.textContent=String(i),r.id=hi(this._path),re(r,"field-const-value");const s=n.querySelector("label.label");s&&(s.htmlFor=r.id),n.appendChild(r),this.$root.appendChild(n)}}Se("schema-form-const",pa);class Id extends St{render(){this.$root.innerHTML=`<style>${ut}</style>`;const e=yt(this._schema),i=this.makeFieldContainer("intersect",e.description);i.classList.remove("field");const n=document.createElement("div");n.classList.add("group"),re(n,"field-group");const r=this._schema.list||[],s=r.length>0&&r.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:{};r.forEach((c,l)=>{const u=c?.meta?.description??"",d=pi(c,this._path,a,u,this._i18n);d.addEventListener("change",m=>{m.stopPropagation();const p=o(this._value??{},m.detail.value);this.emitChange(p)}),n.appendChild(d)})}else{const a=r[r.length-1],c=pi(a,this._path,this._value,this._label,this._i18n);c.addEventListener("change",l=>{l.stopPropagation(),this.emitChange(l.detail.value)}),n.appendChild(c)}i.appendChild(n),this.$root.appendChild(i)}}Se("schema-form-intersect",Id);function gv(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 pi(t,e,i,n,r){const s=gv(t),o=document.createElement(s);return o.schema=t,o.path=e,o.label=n,r&&(o.i18n=r),o.setValue?.(i),o.setAttribute("exportparts",hv),o}class Rd extends St{render(){this.$root.innerHTML=`<style>${ut}</style>`;const e=yt(this._schema),i=this.makeFieldContainer("union",e.description),n=this._schema.list||[];if(pv(n)){const r=document.createElement("select");r.className="input",re(r,"field-input","field-input-select"),r.name=Pi(this._path),r.id=hi(this._path),n.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),r.appendChild(a)}),r.onchange=()=>this.emitChange(fa("string",r.value));const s=i.querySelector("label.label");s&&(s.htmlFor=r.id),i.appendChild(r)}else{const r=document.createElement("div");r.className="toolbar",re(r,"field-toolbar");const s=document.createElement("select");s.className="input",re(s,"field-input","field-input-select","field-toolbar-select"),s.name=Pi(this._path)+".__type",s.id=hi(this._path)+"__type";let o=0;n.forEach((u,d)=>{const m=document.createElement("option");m.value=String(d),m.textContent=String(u.meta?.description||u.value||u.type),s.appendChild(m)}),s.onchange=()=>{o=Number(s.value);const u=n[o],d=Ci(u);this.emitChange(d),l()};const a=i.querySelector("label.label");a&&(a.htmlFor=s.id),r.appendChild(s),i.appendChild(r);const c=document.createElement("div");c.className="group",re(c,"field-group");const l=()=>{c.innerHTML="";const u=n[o],d=pi(u,this._path,this._value,this._label);d instanceof pa||(d.addEventListener("change",m=>{m.stopPropagation(),this.emitChange(m.detail.value)}),c.appendChild(d))};l(),i.appendChild(c)}this.$root.appendChild(i)}}Se("schema-form-union",Rd);class Ad extends St{render(){this.$root.innerHTML=`<style>${ut}</style>`;const e=yt(this._schema),i=this.makeFieldContainer("tuple",e.description),n=document.createElement("div");n.className="group",re(n,"field-group");const r=Array.isArray(this._value)?this._value:[];(this._schema.list||[]).forEach((s,o)=>{const a=pi(s,[...this._path,o],r[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)}),n.appendChild(a)}),i.appendChild(n),this.$root.appendChild(i)}}Se("schema-form-tuple",Ad);class Td extends St{render(){this.$root.innerHTML=`<style>${ut}</style>`;const e=yt(this._schema),i=this.makeFieldContainer("object",e.description),n=document.createElement("div");n.className="group",re(n,"field-group");const r=this._schema.dict||{};Object.keys(r).forEach(s=>{if(r[s]?.meta?.hidden)return;const o=(this._value??{})[s],a=pi(r[s],[...this._path,s],o,s);a.addEventListener("change",c=>{c.stopPropagation();const l={...this._value??{}};l[s]=c.detail.value,this.emitChange(l)}),n.appendChild(a)}),i.appendChild(n),this.$root.appendChild(i)}}Se("schema-form-object",Td);const gs=class gs extends St{constructor(){super(...arguments),this._itemIds=[]}generateItemId(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return"i"+gs._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(n=>{const r=n.dataset.uid;r&&(i[r]=n.getBoundingClientRect())}),i}playFLIP(e,i){Array.from(e.querySelectorAll(".row")).forEach(n=>{const r=n.dataset.uid;if(!r)return;const s=i[r];if(!s)return;const o=n.getBoundingClientRect(),a=s.left-o.left,c=s.top-o.top;(a||c)&&(n.style.transition="none",n.style.transform=`translate(${a}px, ${c}px)`,requestAnimationFrame(()=>{n.style.transition="transform .25s ease",n.style.transform=""}))})}render(){this.$root.innerHTML=`<style>${ut}</style>`;const e=yt(this._schema),i=this.makeFieldContainer("array",e.description),n=document.createElement("div");n.className="group",re(n,"field-group");const r=this._schema.inner,s=()=>Array.isArray(this._value)?this._value:[];this.ensureItemIds(s().length);const o=(l,u)=>{n.innerHTML="",s().forEach((d,m)=>{const p=[...this._path,m],h=document.createElement("div");h.className="row schema-collection-row",re(h,"field-row","collection-row");const x=this._itemIds[m];h.dataset.uid=x,h.setAttribute("data-path",qn(p));const k=pi(r,p,d,`${this._label??""}[${m}]`);k.addEventListener("change",w=>{w.stopPropagation();const S=s().slice();S[m]=w.detail.value,this._value=S,this.emitChange(S)});const E=document.createElement("div");E.className="actions",re(E,"field-actions");const y=document.createElement("button");y.type="button",y.className="btn",re(y,"field-button","field-button-secondary"),y.textContent=this._i18n.arrayMoveUp??"↑",y.onclick=()=>{if(m<=0)return;const w=this.capturePositions(n),S=s().slice();[S[m-1],S[m]]=[S[m],S[m-1]],[this._itemIds[m-1],this._itemIds[m]]=[this._itemIds[m],this._itemIds[m-1]],this._value=S,o(w),this.emitChange(S)};const b=document.createElement("button");b.type="button",b.className="btn",re(b,"field-button","field-button-secondary"),b.textContent=this._i18n.arrayMoveDown??"↓",b.onclick=()=>{const w=s();if(m>=w.length-1)return;const S=this.capturePositions(n),R=w.slice();[R[m+1],R[m]]=[R[m],R[m+1]],[this._itemIds[m+1],this._itemIds[m]]=[this._itemIds[m],this._itemIds[m+1]],this._value=R,o(S),this.emitChange(R)};const g=document.createElement("button");g.type="button",g.className="btn danger",re(g,"field-button","field-button-danger"),g.textContent=this._i18n.arrayRemove??"×",g.onclick=()=>{h.classList.add("leaving");const w=250;let S=!1;const R=()=>{if(S)return;S=!0,clearTimeout(B);const N=s().filter((K,Fe)=>Fe!==m);this._itemIds.splice(m,1);const Y=this.capturePositions(n);this._value=N,o(Y),this.emitChange(N)};h.addEventListener("transitionend",R,{once:!0});const B=setTimeout(R,w+80)},E.append(y,b,g),h.appendChild(k),h.appendChild(E),n.appendChild(h),u&&u===x&&(h.classList.add("enter"),requestAnimationFrame(()=>{h.classList.add("enter-active")}),requestAnimationFrame(()=>{h.classList.remove("enter")}))}),l&&this.playFLIP(n,l)};o();const a=document.createElement("button");a.type="button",a.className="btn primary",re(a,"field-button","field-button-primary"),a.textContent=this._i18n.arrayAdd??"+",a.onclick=()=>{const l=this.capturePositions(n),u=s().slice(),d=Ci(r);u.push(d);const m=this.generateItemId();this._itemIds.push(m),this._value=u,o(l,m),this.emitChange(u)};const c=document.createElement("div");c.className="actions",re(c,"field-actions"),c.appendChild(a),i.appendChild(n),i.appendChild(c),this.$root.appendChild(i)}};gs._idCounter=0;let Jr=gs;Se("schema-form-array",Jr);class Od extends St{render(){this.$root.innerHTML=`<style>${ut}</style>`;const e=yt(this._schema),i=this.makeFieldContainer("dict",e.description),n=document.createElement("div");n.className="group",re(n,"field-group");const r=this._schema.inner,s=this._value??{},o=m=>`d_${m}`,a=()=>{const m={};return n.querySelectorAll(".kv").forEach(p=>{const h=p.dataset.uid;h&&(m[h]=p.getBoundingClientRect())}),m},c=m=>{n.querySelectorAll(".kv").forEach(p=>{const h=p.dataset.uid;if(!h)return;const x=m[h];if(!x)return;const k=p.getBoundingClientRect(),E=x.left-k.left,y=x.top-k.top;(E||y)&&(p.style.transition="none",p.style.transform=`translate(${E}px, ${y}px)`,requestAnimationFrame(()=>{p.style.transition="transform .25s ease",p.style.transform=""}))})},l=(m,p)=>{n.innerHTML="",Object.keys(s).forEach(h=>{const x=[...this._path,h],k=document.createElement("div");k.className="kv schema-collection-row",re(k,"field-row","collection-row"),k.dataset.uid=o(h),k.setAttribute("data-path",qn(x));const E=document.createElement("input");E.className="input",re(E,"field-input","field-input-text"),E.value=h,E.name=Pi(x)+".__key",E.id=hi(x)+"__key";const y=pi(r,x,s[h],`${this._label??""}[${h}]`),b=document.createElement("button");b.type="button",b.className="btn danger",re(b,"field-button","field-button-danger"),b.textContent=this._i18n.dictRemove??"×",b.onclick=()=>{const g=a();delete s[h];const w={...this._value??{}};delete w[h],this._value=w,l(g),this.emitChange(w)},E.onchange=()=>{const g=E.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)},y.addEventListener("change",g=>{g.stopPropagation();const w={...this._value??{}};w[h]=g.detail.value,this._value=w,this.emitChange(w)}),k.append(E,y,b),n.appendChild(k),p===h&&(k.classList.add("enter"),requestAnimationFrame(()=>k.classList.add("enter-active")),requestAnimationFrame(()=>k.classList.remove("enter")))}),m&&c(m)};l();const u=document.createElement("button");u.type="button",u.className="btn primary",re(u,"field-button","field-button-primary"),u.textContent=this._i18n.dictAdd??"+",u.onclick=()=>{let m=Object.keys(s).length+1,p=`k${m}`;for(;s[p]!==void 0;)p=`k${++m}`;const h=a();s[p]=Ci(r);const x={...this._value??{},[p]:s[p]};this._value=x,l(h,p),this.emitChange(x)};const d=document.createElement("div");d.className="actions",re(d,"field-actions"),d.appendChild(u),i.appendChild(n),i.appendChild(d),this.$root.appendChild(i)}}Se("schema-form-dict",Od);class Ld extends HTMLElement{constructor(){super(),this._i18n={...xd},this._i18nCommitted=!1,this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=ut,this.$root.appendChild(e);const i=document.createElement("div");i.className="wrapper",re(i,"wrapper");const n=document.createElement("form");n.className="form",re(n,"form"),i.appendChild(n),this.$root.appendChild(i),this.addEventListener("change",r=>{if(!r?.detail)return;const{path:s,value:o}=r.detail;Array.isArray(s)&&s.length===0?this._state=o:dv(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=Sd(e);try{this._state=this._schema(null,{autofix:!0})}catch{this._state=Ci(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 n=i.validate?this._schema(e??null,{autofix:i.autofix}):e;this._state=n,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=Ci(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=pi(this._schema,[],this._state,this._i18n.rootLabel,this._i18n);e.appendChild(i)}}Se("schema-form",Ld);function mv(){Se("schema-form",Ld),Se("schema-form-string",$d),Se("schema-form-number",Ed),Se("schema-form-boolean",Pd),Se("schema-form-date",Cd),Se("schema-form-const",pa),Se("schema-form-union",Rd),Se("schema-form-tuple",Ad),Se("schema-form-object",Td),Se("schema-form-array",Jr),Se("schema-form-dict",Od),Se("schema-form-intersect",Id)}const yv=$i({__name:"SchemasteryFormVue",props:mu({schema:{},value:{},validateOnChange:{type:Boolean,default:!1}},{schema:{required:!0},schemaModifiers:{},value:{required:!1,default:{}},valueModifiers:{}}),emits:mu(["change"],["update:schema","update:value"]),setup(t,{expose:e,emit:i}){const n=ku(t,"schema"),r=ku(t,"value"),s=i,o=uu("elRef");let a=!1,c=!1;const l=u=>{if(c)return;const d=o.value,m=t.validateOnChange?d.getData({validate:!0}):u.detail.state;a=!0,r.value=m,In(()=>{a=!1}),s("change",u.detail)};return pu(()=>{mv()}),Ln(()=>{const u=o.value;n.value&&(u.schema=n.value),r.value!==void 0&&u.setData(r.value,{validate:!1,autofix:!0}),u.addEventListener("form-change",l)}),qo(()=>{o.value?.removeEventListener("form-change",l)}),Vi(n,u=>{a||o.value&&u&&o.value.schema!==u&&(c=!0,o.value.schema=u,In(()=>{c=!1}))},{deep:!0,immediate:!0}),Vi(r,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}),In(()=>{c=!1}))},{deep:!0,immediate:!0}),e({setData(u,d){const m=o.value;m.setData(u,{validate:!!d?.validate}),d?.emit&&(r.value=m.getData({validate:!!d?.validate}))},getData(u){return o.value.getData(u)},setSchema(u,d=!0){o.value.schema=u,d&&(n.value=u)},refresh(){o.value.refresh()},reset(){o.value.reset()},el:o}),(u,d)=>(ue(),ve("schema-form",Wu({ref_key:"elRef",ref:o},u.$attrs),null,16))}});function Ii(t,e=new WeakMap){if(De(t))return Ii(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 r=new Map;return e.set(t,r),Array.from(t.entries()).forEach(([s,o])=>{r.set(s,Ii(o,e))}),r}if(t instanceof Set){const r=new Set;return e.set(t,r),Array.from(t).forEach(s=>{r.add(Ii(s,e))}),r}if(Array.isArray(t)){const r=[];e.set(t,r);for(const s of t)r.push(Ii(s,e));return r}const i=oe(t),n={};e.set(t,n);for(const r of Object.keys(i))n[r]=Ii(i[r],e);for(const r of Object.getOwnPropertySymbols(i))n[r]=Ii(i[r],e);return n}const ga=()=>{},bv={id:"preferences-ui-app"},vv={class:"tabbar"},wv={class:"tabbar-tabs"},_v=["onClick","data-value"],xv={class:"tabbar-content"},kv={key:0},Sv={style:{"max-height":"20em",overflow:"auto"}},$v=$i({__name:"PreferencesApp",setup(t,{expose:e}){const i=ca(),n=!1,r=Xc([]),s=Qe([]),o=Qe(""),a=qt(()=>s.value.find(h=>h.name===o.value)||null),c=qt(()=>{const h=r.value.filter(x=>x.category===o.value).map(x=>x.schema);return h.length===0?null:I.intersect(h)}),l=qt(()=>a.value&&typeof a.value.autoGenerateForm=="boolean"?a.value.autoGenerateForm:!0),u=Qe({});e({getValue(){return Ii(u)},mergeValue(h){u.value={...u.value,...h}},selectTab(h){o.value=h}}),Ln(async()=>{i.inject(["preferences"],async h=>{const x=await h.preferences.getAll();u.value=x,s.value=h.preferences.getConfigCategories(),r.value=h.preferences.getConfigRegistries(),o.value=s.value[0].name})});const d=(h,x)=>{h.preventDefault(),o.value=x;const k=h.currentTarget;k&&k.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},m=uu("customRenderContainerRef"),p=Qe([]);return zo(()=>{p.value.forEach(h=>h()),p.value=[]}),Vi(a,async h=>{p.value.forEach(k=>k()),p.value=[],await In();const x=m.value;if(x&&(x.innerText="",h&&typeof h.customRenderer=="function")){let k=ga;const E=g=>{k=g},y=g=>{p.value.push(g)},b=await h.customRenderer({ctx:i,onMounted:E,onUnmount:y});b&&(x.appendChild(b),k?.(x))}},{immediate:!0,deep:!1}),(h,x)=>(ue(),ve("div",bv,[ie("div",vv,[ie("div",wv,[(ue(!0),ve(We,null,Ho(s.value,k=>(ue(),ve("a",{class:_t(["tab",{active:o.value===k.name}]),key:k.name,onClick:E=>d(E,k.name),"data-value":k.name},ye(k.label),11,_v))),128))]),ie("div",xv,[a.value&&a.value.customRenderer?(ue(),ve("div",{class:"custom-render-container",ref_key:"customRenderContainerRef",ref:m,key:o.value})):di("",!0),l.value&&c.value?(ue(),zr(Oe(yv),{class:"auto-schema-form",key:o.value,"data-category":o.value,schema:c.value,value:u.value,"onUpdate:value":x[0]||(x[0]=k=>u.value={...u.value,...k}),"validate-on-change":!1,i18n:{rootLabel:""}},null,8,["data-category","schema","value"])):di("",!0)])]),Oe(n)?(ue(),ve("details",kv,[ie("pre",Sv,ye(u.value),1)])):di("",!0)]))}}),Zr=(t,e)=>{const i=t.__vccOpts||t;for(const[n,r]of e)i[n]=r;return i},Ev=Zr($v,[["__scopeId","data-v-775e2739"]]);var Pv=Object.create,ma=Object.defineProperty,Cv=Object.getOwnPropertyDescriptor,Nd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Md=t=>{throw TypeError(t)},Iv=(t,e,i)=>e in t?ma(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Rv=(t,e)=>ma(t,"name",{value:e,configurable:!0}),Av=t=>[,,,Pv(t?.[Nd("metadata")]??null)],Tv=["class","method","getter","setter","accessor","field","value","get","set"],Dd=t=>t!==void 0&&typeof t!="function"?Md("Function expected"):t,Ov=(t,e,i,n,r)=>({kind:Tv[t],name:e,metadata:n,addInitializer:s=>i._?Md("Already initialized"):r.push(Dd(s||null))}),Lv=(t,e)=>Iv(e,Nd("metadata"),t[3]),Nv=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Mv=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&Cv(r,i));Rv(r,i);for(var h=n.length-1;h>=0;h--)c=Ov(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,Dd(o)&&(r=o);return Lv(t,r),p&&ma(r,i,p),u?l^4?s:p:r},jd,ya,Ud;jd=[xe(["preferences","modal","$","$$"])];class es extends(Ud=je){constructor(e){super(e,{},"preferences-ui"),this.ctx=e,this._modal=null,this._form=null,e.set("preferencesUI",this);const i=e.$,n=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:n`prefs.about.label`,description:n`prefs.about.description`,index:99,customRenderer:()=>f("section",{className:"theme-ipe-prose",children:[f("h2",{children:"✏️ InPageEdit NEXT"}),f("p",{children:n`prefs.about.intro`}),f("h3",{children:n`prefs.about.portals.header`}),f("ul",{children:[f("li",{children:f("a",{href:this.ctx.Endpoints.HOME_URL,target:"_blank",children:n`prefs.about.portals.officialwebsite`})}),f("li",{children:f("a",{href:`${this.ctx.Endpoints.UPDATE_LOGS_URL}#${this.ctx.version.split("-")[0]}`,target:"_blank",children:n`prefs.about.portals.updatelogs`})})]}),f("h3",{children:n`prefs.about.joinus.header`}),f("ul",{children:[f("li",{children:[f("strong",{children:n`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:n`prefs.about.joinus.qqgroup`}),": ",this.ctx.Endpoints.QQ_GROUP_ID]})]}),f("hr",{}),f("p",{style:{textAlign:"center"},children:n`prefs.about.copyright`}),f("hr",{})]})}),e.inject(["toolbox"],r=>{r.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(()=>c0).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(yi,{children:f(wi,{})})});i.get$window().classList.add("dialog");const n=f("div",{id:"ipe-preferences-app",style:{minHeight:"calc(85dvh - var(--ipe-modal-spacing) * 2)"}});i.setContent(n),this.ctx.emit("preferences-ui/modal-shown",{ctx:this.ctx,modal:i});const r=this.createPreferencesUIApp(),s=r.mount(n);return this._form=s,this.ctx.emit("preferences-ui/vue-app-mounted",{ctx:this.ctx,app:r,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"),r.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 pd(this.ctx,Ev)}}ya=Av(Ud),es=Mv(ya,0,"PluginPreferencesUI",jd,es),Nv(ya,1,es);const Dv=Object.freeze(Object.defineProperty({__proto__:null,get PluginPreferencesUI(){return es}},Symbol.toStringTag,{value:"Module"})),jv=Symbol("@@apply"),Uv=Symbol("@@ctor");function Fd(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[jv]=i,i[Uv]=t;const n=t?.constructor?.name;return n&&(i[Symbol.toStringTag]=n),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 ts={mbox:"_mbox_5x43w_1",title:"_title_5x43w_12",content:"_content_5x43w_19",close:"_close_5x43w_27"},ba=t=>{const{type:e="default",title:i,content:n,closeable:r=!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:m,resolve:p}=wn();return d.animate([{opacity:"1",height:d.clientHeight+"px"},{opacity:"0",height:"0px",margin:"0px"}],{duration:300,easing:"ease"}).addEventListener("finish",()=>{d.remove(),p()}),m},d=f("div",{className:`theme-ipe ipe-mbox mbox-type-${e||"default"} ${ts.mbox}`,...c,children:[l&&f("div",{className:`ipe-mbox-title ${ts.title}`,...s,children:l}),f("div",{className:`ipe-mbox-content ${ts.content}`,...o,children:a||n}),r&&f("a",{onClick:u,className:`ipe-mbox-close ${ts.close}`,children:"×"})]});return d.close=u,d},is=t=>{const{label:e,id:i,name:n,value:r,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(yi,{children:[" ",f("span",{className:"required",children:"*"})]})]}),u??f("input",{id:i,name:n,value:r,disabled:o,placeholder:s,required:a,style:{width:"100%"},...l})]})},Fv=t=>{const{id:e,name:i,value:n,label:r,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:n,...s}),f("span",{className:"ipe-checkbox-box"}),f("span",{...o,children:r||a})]})},Ri=t=>{const{id:e,name:i,label:n,checked:r,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:r,...s}),f("span",{className:"ipe-checkbox-box"}),f("span",{...o,children:n||a})]})},Bv=(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 qv=Object.create,va=Object.defineProperty,zv=Object.getOwnPropertyDescriptor,qd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),zd=t=>{throw TypeError(t)},Hv=(t,e,i)=>e in t?va(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Wv=(t,e)=>va(t,"name",{value:e,configurable:!0}),Kv=t=>[,,,qv(t?.[qd("metadata")]??null)],Vv=["class","method","getter","setter","accessor","field","value","get","set"],Hd=t=>t!==void 0&&typeof t!="function"?zd("Function expected"):t,Gv=(t,e,i,n,r)=>({kind:Vv[t],name:e,metadata:n,addInitializer:s=>i._?zd("Already initialized"):r.push(Hd(s||null))}),Qv=(t,e)=>Hv(e,qd("metadata"),t[3]),Yv=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Xv=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&zv(r,i));Wv(r,i);for(var h=n.length-1;h>=0;h--)c=Gv(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,Hd(o)&&(r=o);return Qv(t,r),p&&va(r,i,p),u?l^4?s:p:r},Wd,wa,Kd;Wd=[xe(["api","wikiPage","wikiTitle","currentPage","wiki","modal","preferences","$"]),Tt(I.object({"quickEdit.editSummary":I.string().description("Default edit summary for quick edits").default("[IPE-NEXT] Quick edit"),"quickEdit.editMinor":I.boolean().description('Default to checking "minor edit" option').default(!1),"quickEdit.outSideClose":I.boolean().description("Close editor modal by clicking outside").default(!0),"quickEdit.watchList":I.union([I.const(wt.preferences).description("Follow MW preferences"),I.const(wt.nochange).description("Keep the current watchlist status"),I.const(wt.watch).description("Add the page to watchlist"),I.const(wt.unwatch).description("Remove the page from watchlist")]).description("Watchlist options").default(wt.preferences),"quickEdit.keyshortcut.save":I.string().default("ctrl-s").description("save button key shortcut (blank to disable)"),"quickEdit.editFont":I.union([I.const("preferences").description("Follow MW preferences"),I.const("monospace").description("Monospace"),I.const("sans-serif").description("Sans-serif"),I.const("serif").description("Serif"),I.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 ns=(Ti=class extends(Kd=je){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",Fd(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 n=await this.ctx.preferences.get("quickEdit.outSideClose"),r=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:n}).init();l.setTitle(f(yi,{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(wi,{})})),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||"",m=u.revisions[0]?.revid,p=m&&m!==u.lastrevid,h=c.section==="new",x=u.pageid===0;l.setTitle(f(yi,{children:[h?i`New Section`:i`Quick ${x?"Create":"Edit"}`,": ",f("u",{children:u.pageInfo.title}),p?` (${i`Revision`} ${m})`:""]}));const k=[];x&&k.push(f(ba,{title:i`Attention`,type:"important",children:f("p",{children:i`This page does not exist.`})})),p&&k.push(f(ba,{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 E=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(yi,{children:f(is,{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(is,{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:[wt.preferences,wt.nochange,wt.watch,wt.unwatch].map(g=>f(Fv,{name:"watchlist",value:g,inputProps:{checked:r===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(E);let y=!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(E);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:r,createonly:u.pageid===0&&!y,recreate:u.pageid===0&&y}),l.setOptions({beforeClose:ga}),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")){y=!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(E.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:ga}),l.close()),!0)),!1)}}),this.ctx.emit("quick-edit/wiki-page",{ctx:this.ctx,options:c,modal:l,wikiPage:u});const b=g=>E.querySelector("textarea")?.value===d?!0:(g.preventDefault(),i`You have unsaved changes. Are you sure you want to leave?`);window.addEventListener("beforeunload",b),l.on(l.Event.Close,()=>{window.removeEventListener("beforeunload",b)})}async handleSubmit(e){const{wikiPage:i,...n}=e;return this.ctx.emit("quick-edit/submit",{ctx:this.ctx,wikiPage:i,...n}),i.edit({...n})}async getEditFontOptions(){const e=await this.ctx.preferences.get("quickEdit.editFont");return Ti.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,n=this.ctx.currentPage.wikiTitle,r=n&&n.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:!r},tooltip:()=>r?i`Quick Edit`:i`Not editable`,onClick:()=>{const s=new URLSearchParams(window.location.search).get("oldid");this.showModal({title:n?.getPrefixedText(),revision:s?Number(s):void 0})}})}removeToolbox(e){e.toolbox.removeButton("quick-edit")}createQuickEditButton(e,i){const{$:n}=this.ctx,r=i?.icon??f(Bd,{className:"ipe-icon"}),s=i?.label??n`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:[r,s]})}},Ti.BUILT_IN_FONT_OPTIONS=["preferences","monospace","sans-serif","serif"],Ti);wa=Kv(Kd),ns=Xv(wa,0,"PluginQuickEdit",Wd,ns),Yv(wa,1,ns);const Jv=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickEdit:ns},Symbol.toStringTag,{value:"Module"})),Hn={twinSwapInput:"_twinSwapInput_1gdgl_9",inputWrapper:"_inputWrapper_1gdgl_23",inputLeft:"_inputLeft_1gdgl_27",inputRight:"_inputRight_1gdgl_30",swapButton:"_swapButton_1gdgl_46"},Vd=t=>{const{inputs:e,enableSwap:i=!0,...n}=t,r=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],x=s[1],k=h.value,E=x.value;h.value=E,x.value=k,h.dispatchEvent(new Event("change")),x.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 x=h??!a.disabled;a.disabled=!x,x&&s.forEach(k=>{k&&(k.disabled=!1)})},m=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 ${Hn.twinSwapInput}`,...n,children:[r.map((h,x)=>{const{label:k,id:E,name:y,value:b,disabled:g,required:w,inputProps:S}=h,R=x===0,B=E||y;return f("div",{className:`${Hn.inputWrapper} ${R?Hn.inputLeft:Hn.inputRight}`,children:[k&&f("label",{htmlFor:B,children:k}),f("input",{ref:N=>s[x]=N,type:"text",id:B,name:y,value:b,disabled:g,required:w,...S})]})}),f("div",{className:Hn.swapButton,children:m})]});return p.swap=u,p.toggleEnableSwap=d,p};var Zv=Object.create,_a=Object.defineProperty,ew=Object.getOwnPropertyDescriptor,Gd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Qd=t=>{throw TypeError(t)},tw=(t,e,i)=>e in t?_a(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,iw=(t,e)=>_a(t,"name",{value:e,configurable:!0}),nw=t=>[,,,Zv(t?.[Gd("metadata")]??null)],rw=["class","method","getter","setter","accessor","field","value","get","set"],Yd=t=>t!==void 0&&typeof t!="function"?Qd("Function expected"):t,sw=(t,e,i,n,r)=>({kind:rw[t],name:e,metadata:n,addInitializer:s=>i._?Qd("Already initialized"):r.push(Yd(s||null))}),ow=(t,e)=>tw(e,Gd("metadata"),t[3]),aw=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},lw=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&ew(r,i));iw(r,i);for(var h=n.length-1;h>=0;h--)c=sw(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,Yd(o)&&(r=o);return ow(t,r),p&&_a(r,i,p),u?l^4?s:p:r},Xd,xa,Jd;Xd=[Tt(I.object({"quickMove.reason":I.string().default("[IPE-NEXT] Quick move")}).description("Quick move options").extra("category","editor")),xe(["modal","wiki","$"])];class rs extends(Jd=je){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.$,n=window.mw?.config.get("wgPageName")||"",r=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(r?{lockFromField:!0,from:n}:{})}})}async showModal(e){const{$:i}=this.ctx,n=await this.ctx.preferences.get("quickMove.reason"),r=this.ctx.modal.createObject({title:i`Quick Move`,content:f(wi,{}),className:"quick-move compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let s=null;return r.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:r,payload:c}),r.setLoadingState(!0),this.movePage(c).then(()=>{location.reload()}).catch(l=>{r.setLoadingState(!1),this.ctx.modal.notify("error",{title:i`Failed to move`,content:l instanceof Error?l.message:String(l)})})},children:[f(Vd,{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(is,{label:i`Reason`,id:"reason",name:"reason",value:e?.reason??n??""})]})),r.setButtons([{label:i`Move`,className:"is-primary is-ghost",method:()=>{s?.dispatchEvent(new Event("submit"))}}]),r.show()}async movePage(e){const{from:i,to:n,reason:r="",...s}=e;if(!i||!n)throw new Error("From and to titles are required.");if(i===n)throw new Error("From and to titles cannot be the same.");return(await this.ctx.wikiPage.newFromTitle(i)).moveTo(n,r,s)}}xa=nw(Jd),rs=lw(xa,0,"PluginQuickMove",Xd,rs),aw(xa,1,rs);const cw=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickMove(){return rs}},Symbol.toStringTag,{value:"Module"}));var uw=Object.create,ka=Object.defineProperty,dw=Object.getOwnPropertyDescriptor,Zd=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ef=t=>{throw TypeError(t)},fw=(t,e,i)=>e in t?ka(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,hw=(t,e)=>ka(t,"name",{value:e,configurable:!0}),pw=t=>[,,,uw(t?.[Zd("metadata")]??null)],gw=["class","method","getter","setter","accessor","field","value","get","set"],tf=t=>t!==void 0&&typeof t!="function"?ef("Function expected"):t,yw=(t,e,i,n,r)=>({kind:gw[t],name:e,metadata:n,addInitializer:s=>i._?ef("Already initialized"):r.push(tf(s||null))}),bw=(t,e)=>fw(e,Zd("metadata"),t[3]),vw=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},ww=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&dw(r,i));hw(r,i);for(var h=n.length-1;h>=0;h--)c=yw(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,tf(o)&&(r=o);return bw(t,r),p&&ka(r,i,p),u?l^4?s:p:r},nf,Sa,rf;nf=[xe(["api","wikiPage","modal","preferences","$"]),Tt(I.object({"quickPreview.keyshortcut":I.string().default("ctrl-i").description("Key shortcut to open quick preview in quick edit modal")}).extra("category","editor").description("Quick preview options"))];class ss extends(rf=je){constructor(e){super(e,{},"quickPreview"),this.ctx=e,this._contentTypeCache=new Map,this._objectUrls=new WeakMap,this.ctx.set("quickPreview",Fd(this,"previewWikitext"))}start(){this.ctx.on("quick-edit/wiki-page",this.injectQuickEdit.bind(this))}stop(){}previewWikitext(e,i,n,r,s){const{$:o}=this.ctx;return n||(n=this.ctx.wikiPage.newBlankPage({title:"API"})),(!r||r.isDestroyed)&&(r=this.ctx.modal.createObject({className:"in-page-edit ipe-quickPreview",sizeClass:"large",center:!1,...s}).init()),r.show(),r.setTitle(o`Preview - Loading...`),r.setContent(f(wi,{})),r.bringToFront(),this.ctx.emit("quick-preview/show-modal",{ctx:this.ctx,text:e,modal:r,wikiPage:n}),n.preview(e,i).then(a=>{const{data:{parse:c}}=a;r.setTitle(o(c.title)`Preview - {{ $1 }}`);let l=null;r.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:r,wikiPage:n,text:e,parseData:c})}).catch(a=>{r.setTitle(o`Preview - Failed`),r.setContent(f(yi,{children:[f("p",{children:o`Failed to preview`}),f("p",{children:a instanceof Error?a.message:String(a)})]}))}),r}async injectQuickEdit({options:e,modal:i,wikiPage:n}){const{$:r}=this.ctx;let s;i.addButton({label:r`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,n,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 n=fetch(e,{method:"HEAD"}).then(r=>r.headers.get("content-type")||"").catch(()=>(this._contentTypeCache.delete(e),""));return this._contentTypeCache.set(e,n),n}async getPreviewType(e){if(!e)return"unknown";let i,n;if(e instanceof File)i=e.type,n=e.name.split(".").pop()?.toLowerCase()||"";else{const r=new URL(e,location.origin);r.protocol==="data:"||r.protocol==="blob:"||r.protocol.startsWith("http")?i=await this.fetchContentType(r.href):i="",n=r.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":n==="md"?"markdown":i.startsWith("text/")?"text":["jpg","jpeg","png","gif","bmp","tiff","ico","webp"].includes(n)?"image":["mp4","webm","ogg","flv","avi","mov","wmv","mkv"].includes(n)?"video":["mp3","wav","ogg","flac","aac","m4a","wma"].includes(n)?"audio":["html","htm"].includes(n)?"html":["json","yml","yaml","toml","py"].includes(n)?"text":["pdf"].includes(n)?"pdf":"unknown"}async previewFile(e,i){const n=await this.getPreviewElement(e,i);return n?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:n})}):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 n=await this.getPreviewType(e),r=e instanceof File?this.getObjectUrl(e):e;switch(n){case"image":return f("img",{src:r,alt:i??(e instanceof File?e.name:e)});case"video":return f("video",{src:r,controls:!0,"aria-label":i});case"audio":return f("audio",{src:r,controls:!0,"aria-label":i});case"pdf":return f("embed",{type:"application/pdf",src:r,"aria-label":i})}return null}previewWikiPage(e){throw new Error("Not implemented")}}Sa=pw(rf),ss=ww(Sa,0,"PluginQuickPreview",nf,ss),vw(Sa,1,ss);const _w=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickPreview(){return ss}},Symbol.toStringTag,{value:"Module"})),xw=t=>{let{user:e,target:i,ctx:n}=t;const r=n.getUrl.bind(n);return f("span",{className:"mw-userlinks",children:[f("a",{href:r(`User:${e}`),className:"mw-userlink",target:i,children:e})," ",f("span",{className:"mw-usertoollinks",children:["(",f("a",{href:r(`User_talk:${e}`),className:"mw-usertoollinks-talk",target:i,children:"talk"})," | ",f("a",{href:r(`Special:Contributions/${e}`),className:"mw-usertoollinks-contribs",target:i,children:"contribs"})," | ",f("a",{href:r(`Special:Block/${e}`),className:"mw-usertoollinks-block",target:i,children:"block"}),")"]})]})};var os=(t=>(t.update="ipe:diff-table/update",t.edit="ipe:diff-table/edit",t))(os||{});const kw=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"medium"}).format,sf=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=n=>{n.preventDefault(),n.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(xw,{ctx:t.ctx,user:t.username,target:"_blank"})}),f("div",{className:"mw-diff-title--timestamp",children:t.timestamp&&kw(new Date(t.timestamp))}),f("div",{className:"mw-diff-title--comment",children:t.parsedcomment&&f(yi,{children:["(",f("i",{innerHTML:t.parsedcomment}),")"]})})]})},Sw=t=>{const e=t.data;if(!e.prev&&!e.next)return null;const i=(n,r,s)=>{n.preventDefault(),n.target.dispatchEvent(new CustomEvent("ipe:diff-table/update",{detail:{fromrev:r,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:n=>i(n,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:n=>i(n,e.torevid,e.next),children:"Next →"}):f("i",{children:"Newest version"})})]})},$w=t=>{const{data:e,...i}=t,n=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(sf,{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(sf,{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(Sw,{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 n.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,n},Ew=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 Pw=Object.create,$a=Object.defineProperty,Cw=Object.getOwnPropertyDescriptor,of=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),af=t=>{throw TypeError(t)},Iw=(t,e,i)=>e in t?$a(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Rw=(t,e)=>$a(t,"name",{value:e,configurable:!0}),Aw=t=>[,,,Pw(t?.[of("metadata")]??null)],Tw=["class","method","getter","setter","accessor","field","value","get","set"],lf=t=>t!==void 0&&typeof t!="function"?af("Function expected"):t,Ow=(t,e,i,n,r)=>({kind:Tw[t],name:e,metadata:n,addInitializer:s=>i._?af("Already initialized"):r.push(lf(s||null))}),Lw=(t,e)=>Iw(e,of("metadata"),t[3]),Nw=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Mw=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&Cw(r,i));Rw(r,i);for(var h=n.length-1;h>=0;h--)c=Ow(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,lf(o)&&(r=o);return Lw(t,r),p&&$a(r,i,p),u?l^4?s:p:r},cf,Ea,uf;cf=[xe(["wiki","getUrl","preferences","$"]),Tt(I.object({"quickDiff.keyshortcut":I.string().default("ctrl-d").description("Key shortcut to open quick diff in quick edit modal")}).description("Quick diff options").extra("category","editor"))];class as extends(uf=je){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=Ms("#mw-history-compare");if(!i)return;Oh(".mw-history-compareselectedversions-button",i).forEach(r=>{r.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:n}){if(i.pageid===0||n.section==="new")return;const{$:r}=this.ctx;let s;e.addButton({label:r`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:r`Quick Diff`,content:r`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,n){const{$:r}=this.ctx;return!i||i.isDestroyed?i=this.ctx.modal.createObject({title:r`Loading diff...`,content:"",className:"quick-diff",center:!1,...n}).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(wi,{})})),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})`:""}`:r`Differences`);let a;i.setContent(f("section",{style:{minHeight:"70vh"},children:f($w,{ref:c=>a=c,data:o,ctx:this.ctx})})),a.addEventListener(os.update,c=>{c.stopPropagation(),this.comparePages({fromrev:c.detail.fromrev,torev:c.detail.torev},i,n)},{once:!0}),this.ctx.inject(["quickEdit"],c=>{const l=u=>{u.stopPropagation(),c.quickEdit({revision:u.detail.revid})};a.addEventListener(os.edit,l),i.on(i.Event.Close,()=>{a.removeEventListener(os.edit,l)})}),o.fromrevid&&o.torevid&&i.addButton({label:r`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(ba,{title:r`Failed to load diff`,type:"error",children:f("pre",{children:s instanceof Error?s.message:String(s)})}))}),i.show()}createQuickDiffButton(e,i){const{$:n}=this.ctx,r=i?.icon??f(Ew,{className:"ipe-icon"}),s=i?.label??n`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:[r,s]})}}Ea=Aw(uf),as=Mw(Ea,0,"PluginQuickDiff",cf,as),Nw(Ea,1,as);const Dw=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickDiff(){return as}},Symbol.toStringTag,{value:"Module"})),ms=class ms extends je{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")||"",n=window.mw?.config.get("wgIsProbablyEditable");this.ctx.inject(["toolbox"],r=>{this.ctx=r,r.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(n?{to:i}:{})}}),this.addDisposeHandler(s=>{s.toolbox.removeButton("quick-redirect")})})}stop(){}async showModal(e){const{$:i}=this.ctx,n=await this.ctx.preferences.get("quickRedirect.reason");e||(e={}),this.ctx.emit("quick-redirect/init-options",{ctx:this.ctx,options:e});const r=this.ctx.modal.createObject({title:i`Quick Redirect`,content:f(wi,{}),className:"quick-redirect compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let s=null;return r.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}),r.setLoadingState(!0),this.redirectPage(c).then(l=>{r.close(),this.ctx.modal.notify("success",{title:i`Redirect successful`,content:i`The redirect has been created.`})}).catch(l=>{r.setLoadingState(!1),this.ctx.modal.notify("error",{title:i`Failed to redirect`,content:l instanceof Error?l.message:String(l)})})},children:[f(Vd,{inputs:[{label:i`Redirect from`,name:"from",value:e?.from,required:!0},{label:i`Redirect to`,name:"to",value:e?.to,required:!0}]}),f(is,{label:i`Reason`,id:"reason",name:"reason",value:e?.reason??n??""}),f("div",{children:f(Ri,{name:"overwrite",id:"overwrite",checked:e?.overwrite,children:i`Force create redirect even if the from page already exists`})})]})),r.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:r}),r.show()}async redirectPage(e){const{from:i,to:n,reason:r="",overwrite:s=!1}=e,o=await this.ctx.wikiPage.newBlankPage({title:i}),a=`#REDIRECT [[:${n}]]`;return o.edit({text:a,summary:r},{createonly:!s})}};ms.inject=["api","wikiPage","modal","$"],ms.PreferencesSchema=I.object({"quickRedirect.reason":I.string().default("[IPE-NEXT] Quick redirect")}).description("Quick redirect options").extra("category","editor");let Pa=ms;const jw=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickRedirect:Pa},Symbol.toStringTag,{value:"Module"})),df=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"})]}),Uw=window?.location?.origin,Wn=({type:t,tag:e,href:i,target:n,children:r,...s})=>(e=e||(i?"a":"button"),typeof n>"u"&&i&&i.startsWith("http")&&!i.startsWith(Uw)&&(n="_blank"),gn(e,{className:`theme-ipe ipe-action-button ipe-modal-btn is-${t||"default"}`,href:e==="a"?i:void 0,target:e==="a"?n:void 0,"data-href":e!=="a"?i:void 0,...s},r));var Fw=Object.create,Ca=Object.defineProperty,Bw=Object.getOwnPropertyDescriptor,ff=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),hf=t=>{throw TypeError(t)},qw=(t,e,i)=>e in t?Ca(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,zw=(t,e)=>Ca(t,"name",{value:e,configurable:!0}),Hw=t=>[,,,Fw(t?.[ff("metadata")]??null)],Ww=["class","method","getter","setter","accessor","field","value","get","set"],pf=t=>t!==void 0&&typeof t!="function"?hf("Function expected"):t,Kw=(t,e,i,n,r)=>({kind:Ww[t],name:e,metadata:n,addInitializer:s=>i._?hf("Already initialized"):r.push(pf(s||null))}),Vw=(t,e)=>qw(e,ff("metadata"),t[3]),Gw=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},Qw=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&Bw(r,i));zw(r,i);for(var h=n.length-1;h>=0;h--)c=Kw(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,pf(o)&&(r=o);return Vw(t,r),p&&Ca(r,i,p),u?l^4?s:p:r},gf,Ia,mf;const Yw=({$: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`})]})});gf=[Tt(I.object({"quickUpload.summary":I.string().description("Default summary of the quick upload").default("[IPE-NEXT] Quick upload")})),xe(["modal","$","wikiTitle","wikiFile","quickPreview","preferences"])];class ls extends(mf=je){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(df,{}),tooltip:()=>e`Quick Upload`,onClick:n=>{n.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 n=0;for(;e>=1024&&n<i.length-1;)e/=1024,n++;return`${new Intl.NumberFormat(void 0,{maximumFractionDigits:2}).format(e)} ${i[n]}`}isFileAccepted(e,i){if(!i)return!0;const n=i.split(",").map(o=>o.trim()).filter(Boolean);if(!n.length)return!0;const r=e.type||"",s=e.name||"";return n.some(o=>{if(o.startsWith("."))return s.toLowerCase().endsWith(o.toLowerCase());if(o.endsWith("/*")){const a=o.slice(0,-1);return r.startsWith(a)}return r===o})}getDefaultPreviewPlaceholder(){const{$:e}=this.ctx;return f("div",{className:"ipe-quickUpload__preview-placeholder",children:f("span",{children:[f(df,{}),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,n=!1;const r=(C,M,z)=>{this.ctx.modal.notify(C,{title:M,content:z,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?(r("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},m=(C,M)=>{l=l.map(z=>z.id===C?{...z,...M}:z)},p=C=>{l=l.filter(M=>M.id!==C),u===C&&(u=l[0]?.id??null)},h=(C,M)=>{l=l.map(z=>C.has(z.id)?M(z):z)},x=C=>{const M=[],z=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(z(C.data.error.info)):C?.error?.info?M.push(z(C.error.info)):C?.message&&M.push(z(C.message));return M.filter(Boolean)},k=C=>{let M=x(C);M.length===0&&(M=["Upload failed with unknown error."]);const z=M.join(`
26
+ `),te=z.toLowerCase();return te.includes("file is larger")||te.includes("files larger than")||te.includes("maximum upload size")?{message:`File too large
27
+ ${z}`,retryable:!1}:te.includes("network")||te.includes("timeout")||te.includes("timed out")?{message:`Network issue
28
+ ${z}`,retryable:!0}:{message:z,retryable:!0}},E=C=>C.status==="warning"?!0:C.status==="error"?C.retryable!==!1:!1,y=(C,M)=>C==="retry"?M.filter(z=>E(z)):C==="resume"?M.filter(z=>(z.status==="queued"||z.status==="paused")&&z.retryable!==!1):M.filter(z=>z.status==="queued"||z.status==="paused"),b=C=>{const M=new Set(C.map(z=>z.id));h(M,z=>z.retryable===!1?z:{...z,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},R=(C,M)=>{const z=M>0?Math.floor(C/M*100):0;d.progressTextEl&&(d.progressTextEl.textContent=`${C}/${M} (${z}%)`),d.progressEl&&(d.progressEl.style.width=`${Math.max(0,Math.min(100,z))}%`)},B=C=>(C||"").replace(/\s+/g," ").trim(),N=()=>{l=[],u=null,R(0,0),d.summaryInput&&(d.summaryInput.value=String(o||"")),d.ignoreWarnings&&(d.ignoreWarnings.checked=!1),fe(),Ae()},Y=C=>{const M=C.filter(te=>this.isFileAccepted(te,String(a)));if(!M.length)return;const z=M.map(te=>({id:this.safeId(),file:te,filename:te.name,text:"",status:"queued",retryable:!0}));l=[...l,...z],!u&&l.length&&(u=l[0].id),fe(),Ae()},K=C=>{const M={};M.filename=B(C.filename||C.file.name),M.file=C.file;const z=(d.summaryInput?.value||"").trim()||"";return M.comment=z,M.text=C.text||"",d.ignoreWarnings?.checked&&(M.ignorewarnings="1"),M},Fe=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||R(0,l.length),l.length){const C=f("ul",{style:{listStyle:"none",padding:0,margin:0,display:"grid",gap:"6px"}});l.forEach(M=>{const z=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:z?"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:Fe(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."})})),Oi();return}Oi()}},Ae=async()=>{if(!d.previewWrapper)return;d.previewWrapper.innerHTML="";const C=g();if(!C){d.previewWrapper.appendChild(this.getDefaultPreviewPlaceholder());return}const M=C.file,z=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(Yw,{$:e}),Je=f("div",{className:"ipe-quickUpload__preview-content",style:{marginTop:"10px"},children:te}),we=C.status==="success",Pe=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:_=>{const P=_.target.value;m(C.id,{filename:P}),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:_=>{const P=_.target.value;m(C.id,{text:P}),fe()}})]});d.previewWrapper.appendChild(z),d.previewWrapper.appendChild(Je),d.previewWrapper.appendChild(Pe),d.previewWrapper.appendChild(v)},Ee=async C=>{m(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 z=await this.ctx.wikiFile.upload(M);if(z.data?.upload?.result==="Success"){const te=this.ctx.wikiFile.getFileUrl(`File:${z.data.upload.filename}`);m(C.id,{status:"success",fileUrl:te,result:z.data.upload,retryable:!0}),fe(),await Ae();return}throw z}catch(z){let te=[];if(z?.data?.upload){const Pe=z.data.upload;if(Pe.result==="Success"){const P=Pe.filename||M.filename,T=this.ctx.wikiFile.getFileUrl(`File:${P}`);m(C.id,{status:"success",fileUrl:T,result:Pe,retryable:!0}),fe(),await Ae();return}if(Array.isArray(Pe.warnings?.duplicate)&&Pe.warnings.duplicate.length>0){te.push(`Duplicate of: ${Pe.warnings.duplicate.join(", ")}`),m(C.id,{status:"warning",message:te.join(`
30
+ `),result:Pe,retryable:!0}),fe(),await Ae();return}if(Pe.warnings?.exists){te.push("A file with the same name already exists."),m(C.id,{status:"warning",message:te.join(`
31
+ `),result:Pe,retryable:!0}),fe(),await Ae();return}const{message:v,retryable:_}=k(z);m(C.id,{status:"error",message:v,retryable:_}),fe(),await Ae();return}const{message:Je,retryable:we}=k(z);m(C.id,{status:"error",message:Je,retryable:we}),fe(),await Ae()}},ae=async(C="all")=>{if(i)return;let M=y(C,l);if(C==="retry"){if(M.length===0){r("warning","Nothing to retry",f("div",{children:"There are no retryable failed/warning items."}));return}}else if(C==="resume"){if(M.length===0){r("warning","Nothing to resume",f("div",{children:"There are no queued paused items to continue."}));return}}else{if(l.length===0){r("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"}},z=>(z&&ae("all"),!0));return}}C==="retry"&&(b(M),fe(),await Ae(),M=y("retry",l)),i=!0,n=!1,Oi();try{const z=M.length;let te=0;R(0,z);for(const _ of M){if(n){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 P=l.find(T=>T.id===_.id);if(!P){te++,R(te,z);continue}await Ee(P),te++,R(te,z)}const{ok:Je,warn:we,err:Pe,paused:v}=S();v>0?r("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:Pe})]}),f("div",{children:["Paused: ",f("strong",{children:v})]})]})):Pe===0&&we===0?r("success","Upload completed",f("div",{children:[f("strong",{children:"All files uploaded successfully."}),f("div",{children:["Uploaded: ",f("strong",{children:Je})]})]})):r("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,Pe?f("div",{children:["Errors: ",f("strong",{children:Pe})]}):null]}))}finally{i=!1,Oi()}},me=C=>{C.preventDefault(),C.stopPropagation(),C.currentTarget?.classList.remove("is-dragover");const z=Array.from(C.dataTransfer?.files||[]);z.length&&Y(z)},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")},on=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%)"})})]}),ri=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||[]);Y(M),C.target.value=""}})]}),f("div",{ref:C=>{d.listEl=C}})]}),ys=f("section",{className:"ipe-quickUpload__container",onDrop:me,onDragOver:ge,onDragLeave:ni,style:{display:"grid",gap:"12px"},children:[on,f("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 40%) minmax(0, 1fr)",gap:"12px",alignItems:"start",minWidth:0},children:[ri,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(ys),d.summaryInput&&(d.summaryInput.value=String(o||""));const Oi=()=>{const{warn:C,err:M,paused:z}=S(),te=M>0||C>0,Je=z>0;let we=e`Upload`,Pe=()=>{ae("all")},v="is-primary is-text";i?(we=n?"Pausing...":"Pause after current",Pe=()=>{n=!0,Oi()}):Je?(we="Resume",Pe=()=>{ae("resume")}):te&&(we="Retry failed/warnings",Pe=()=>{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:Pe}])};return fe(),await Ae(),s}}Ia=Hw(mf),ls=Qw(Ia,0,"PluginQuickUpload",gf,ls),Gw(Ia,1,ls);const Xw=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickUpload(){return ls}},Symbol.toStringTag,{value:"Module"}));class Jw extends je{constructor(e){super(e,{},"quick-usage"),this.ctx=e,e.set("quickUsage",this)}async start(){Promise.resolve().then(()=>w0).then(({PluginTemplatesUsed:e})=>this.ctx.plugin(e)),Promise.resolve().then(()=>A0).then(({PluginImagesUsed:e})=>this.ctx.plugin(e)),this.ctx.inject(["quickUpload","$"],e=>{e.on("quick-edit/wiki-page",({modal:i})=>{const{$:n}=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:n`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 Zw=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickUsage:Jw},Symbol.toStringTag,{value:"Module"}));var e_=Object.create,Ra=Object.defineProperty,t_=Object.getOwnPropertyDescriptor,yf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),bf=t=>{throw TypeError(t)},i_=(t,e,i)=>e in t?Ra(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,n_=(t,e)=>Ra(t,"name",{value:e,configurable:!0}),r_=t=>[,,,e_(t?.[yf("metadata")]??null)],s_=["class","method","getter","setter","accessor","field","value","get","set"],vf=t=>t!==void 0&&typeof t!="function"?bf("Function expected"):t,o_=(t,e,i,n,r)=>({kind:s_[t],name:e,metadata:n,addInitializer:s=>i._?bf("Already initialized"):r.push(vf(s||null))}),a_=(t,e)=>i_(e,yf("metadata"),t[3]),l_=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},c_=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&t_(r,i));n_(r,i);for(var h=n.length-1;h>=0;h--)c=o_(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,vf(o)&&(r=o);return a_(t,r),p&&Ra(r,i,p),u?l^4?s:p:r},wf,Aa,_f;wf=[Tt(I.object({toolboxAlwaysShow:I.boolean().description("Make the toolbox opened by default").default(!1)}).description("Toolbox preferences")),xe(["preferences"])];class cs extends(_f=pt){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,n)=>{const r=this.orderKey(i),s=this.orderKey(n),o=r??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(n.id)??0;return r===null&&s===null?c!==l?c-l:0:r===null&&s!==null?-1:r!==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 n=.15,r=e/(i-1),s=n*Math.sqrt(r);return Math.round(s*1e3)/1e3}updateButtonDelays(){this.container.querySelectorAll(".btn-group").forEach(i=>{const n=i.querySelectorAll(".btn-tip-group"),r=n.length;n.forEach((s,o)=>{const a=this.calculateButtonDelay(o,r);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(n=>n.group==="group1").length,i=this.buttons.filter(n=>n.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(r=>r.id===e.id),n=(()=>{if(i!==-1){const r=this.buttons[i];return!e.group||e.group==="auto"?r.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 r=this.buttons[i],s=typeof e.index=="number"&&!Number.isNaN(e.index)?e.index:r.index,o={...r,...e,group:n,index:s};this.buttons.splice(i,1,o)}else{const r=typeof e.index=="number"&&!Number.isNaN(e.index)?e.index:void 0,s={...e,group:n,index:r};this.buttons.push(s)}this.ctx.emit("toolbox/button-added",{ctx:this.ctx,payload:e}),this.renderAll()}removeButton(e){const i=this.buttons.findIndex(n=>n.id===e);if(i!==-1){const n=this.buttons[i];this.buttons.splice(i,1),this.ctx.emit("toolbox/button-removed",{ctx:this.ctx,payload:n}),this.renderAll()}}renderButton(e){let{id:i,icon:n,index:r,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":r,...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(n)})]})}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),n=this.container.querySelector(".btn-group.group1"),r=this.container.querySelector(".btn-group.group2");n.innerHTML="",r.innerHTML="",e.forEach(s=>{n.appendChild(this.renderButton(s))}),i.forEach(s=>{r.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,n=typeof e=="boolean"?e:!i;this.container.classList.toggle("is-persistent",n),this.container.classList.remove("is-hovered"),this.ctx.preferences.set("toolboxAlwaysShow",n),this.ctx.emit("toolbox/toggle",{ctx:this.ctx,opened:this.isOpened})}}Aa=r_(_f),cs=c_(Aa,0,"PluginToolbox",wf,cs),l_(Aa,1,cs);const u_=Object.freeze(Object.defineProperty({__proto__:null,get PluginToolbox(){return cs}},Symbol.toStringTag,{value:"Module"})),us=$i({__name:"UIBaseButton",props:{variant:{default:"neutral"},active:{type:Boolean,default:!1}},setup(t){const e=t,i=qt(()=>({"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(n,r)=>(ue(),ve("button",{class:_t(["ipeps-button",i.value])},[Fy(n.$slots,"default")],2))}}),d_={id:"ipe-registry-manager"},f_={class:"ipeps-header"},h_={class:"ipeps-header-title"},p_={class:"ipeps-input-wrapper"},g_=["placeholder","disabled"],m_={key:0,class:"ipeps-list"},y_={class:"registry-info"},b_={class:"item-name"},v_={class:"item-desc"},w_={class:"homepage"},__=["href"],x_={class:"url"},k_={class:"item-meta"},S_={class:"ipeps-actions"},$_={key:1,class:"ipeps-empty"},E_={class:"text"},P_={class:"description"},C_=Zr($i({__name:"RegistryManager",setup(t){const e=ca(),i=e.$,n=e.$$,r=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")||[],x=await Promise.allSettled(h.map(async k=>{const E=await e.store.getRegistryInfo(k);return{registryUrl:k,label:a(k),...E}}));r.value=x.filter(k=>k.status==="fulfilled").map(k=>k.value)}async function l(){const h=s.value.trim();if(h){if(r.value.some(x=>x.registryUrl===h)){e.modal.notify("info",{content:"Registry already exists."});return}o.value=!0;try{const x=await e.store.getRegistryInfo(h,"online_manifest",!0);if(!x)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),r.value.push({registryUrl:h,label:a(h),...x}),s.value="",e.modal.notify("success",{content:"Registry added."})}catch(x){e.modal.notify("error",{content:x instanceof Error?x.message:String(x)})}finally{o.value=!1}}}async function u(h){const k=(await e.preferences.get("pluginStore.registries")||[]).filter(E=>E!==h);await e.preferences.set("pluginStore.registries",k),r.value=r.value.filter(E=>E.registryUrl!==h)}async function d(h){const k=(await e.preferences.get("pluginStore.plugins")||[]).filter(E=>E.registry===h);if(k.length===0){e.modal.confirm({title:n`plugin-store.remove-registry.title`,content:n`plugin-store.remove-registry.tip-content`+`
32
+ ${h}`,cancelBtn:{label:i`Cancel`,className:"is-ghost"},okBtn:{label:i`Remove`,className:"is-danger"}},async E=>{E&&(await u(h),e.modal.notify("success",{content:n`plugin-store.remove-registry.remove-success`}))});return}e.modal.dialog({title:n`plugin-store.remove-registry.title`,content:gn("div",{class:"theme-ipe-prose"},[gn("p",{},n({count:k.length})`plugin-store.remove-registry.confirm-content`),gn("ul",{},k.map(E=>gn("li",{},E.id)))]),buttons:[{label:n`plugin-store.remove-registry.buttons.remove-only`,className:"is-danger is-ghost",method:async(E,y)=>{await u(h),e.modal.notify("success",{content:n`plugin-store.remove-registry.remove-success`}),y.close()}},{label:n`plugin-store.remove-registry.buttons.remove-and-uninstall`,className:"is-danger",method:async(E,y)=>{await u(h);for(const b of k)try{await e.store.uninstallAndRemovePreference(b.registry,b.id)}catch(g){e.modal.notify("error",{content:g instanceof Error?`Failed to uninstall ${b.id}: ${g.message}`:`Failed to uninstall ${b.id}`})}e.modal.notify("success",{content:n({$1:k.length})`plugin-store.remove-registry.remove-with-plugins-success`}),y.close()}}]},()=>{})}function m(h){const x=h.changes["pluginStore.registries"];Array.isArray(x)&&c()}function p(){const h=Lt.PLUGIN_REGISTRY_URL;s.value=h,l()}return Ln(()=>{c(),e.on("preferences/changed",m)}),(h,x)=>(ue(),ve("div",d_,[ie("div",f_,[ie("div",h_,ye(Oe(i)`Registries`),1),ie("div",p_,[au(ie("input",{class:"ipeps-input with-icon","onUpdate:modelValue":x[0]||(x[0]=k=>s.value=k),type:"url",placeholder:Oe(i)`Add registry URL`+" (https://...)",disabled:o.value},null,8,g_),[[fd,s.value,void 0,{trim:!0}]]),x[1]||(x[1]=ie("div",{class:"ipeps-input-icon"},"📦",-1))]),Ne(us,{onClick:l,disabled:o.value||!s.value,variant:"primary"},{default:An(()=>[Fn(ye(o.value?Oe(i)`Adding...`:Oe(i)`Add`),1)]),_:1},8,["disabled"])]),r.value.length?(ue(),ve("div",m_,[(ue(!0),ve(We,null,Ho(r.value,k=>(ue(),ve("div",{class:"ipeps-item",key:k.registryUrl},[ie("div",y_,[ie("div",b_,ye(k.label),1),ie("div",v_,[ie("div",w_,[k.homepage?(ue(),ve("a",{key:0,href:k.homepage,target:"_blank"},ye(k.homepage),9,__)):di("",!0)]),ie("div",x_,ye(k.registryUrl),1)]),ie("div",k_,ye(k.packages.length)+" packages",1)]),ie("div",S_,[Ne(us,{onClick:E=>d(k.registryUrl),variant:"danger"},{default:An(()=>[Fn(ye(Oe(i)`Remove`),1)]),_:1},8,["onClick"])])]))),128))])):(ue(),ve("div",$_,[x[2]||(x[2]=ie("div",{class:"icon"},"🗂️",-1)),ie("div",E_,ye(Oe(i)`No registries configured`),1),ie("div",P_,[Ne(us,{onClick:p,variant:"primary",style:{padding:"0.25rem 0.5rem"}},{default:An(()=>[Fn(ye(Oe(i)`Setup default registry`),1)]),_:1})])]))]))}}),[["__scopeId","data-v-0245c97d"]]),I_={id:"ipe-plugin-install-manager"},R_={class:"ipeps-header"},A_={class:"ipeps-header-title"},T_={class:"ipeps-input-wrapper"},O_=["placeholder","disabled"],L_=["disabled"],N_={key:0,class:"ipeps-loading"},M_={class:"loading-text"},D_={key:1,class:"ipeps-list"},j_={class:"plugin-info"},U_={class:"plugin-header"},F_={class:"item-name"},B_={class:"ipeps-tags"},q_=["href","title"],z_=["title"],H_={class:"plugin-meta"},W_={key:0,class:"version"},K_={key:1,class:"author"},V_={key:2,class:"license"},G_={key:2,class:"ipeps-empty"},Q_={class:"plugin-empty-text"},Y_=Zr($i({__name:"PluginInstallManager",setup(t){const e=ca(),i=e.$,n=e.$$,r=Qe([]),s=Qe([]),o=Qe(""),a=Qe(!1),c=(N,Y)=>`${N}
33
+ ${Y}`,l=qt(()=>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}},m=Qe(!1),p=qt(()=>r.value.length>0),h=qt(()=>r.value.flatMap(N=>(N.packages||[]).map(Y=>({...Y,_key:c(N.registryUrl,Y.id),registry:N.registryUrl,registryHomepage:N.homepage,registryLabel:d(N.registryUrl),isBroken:!1,isRegistryMissing:!1})))),x=qt(()=>{const N=o.value.trim().toLowerCase(),Y=h.value,K=new Set(Y.map(Ee=>Ee._key)),Fe=new Set(r.value.map(Ee=>Ee.registryUrl)),fe=s.value.filter(Ee=>!K.has(c(Ee.registry,Ee.id))).map(Ee=>{const ae=r.value.find(me=>me.registryUrl===Ee.registry);return{id:Ee.id,name:void 0,description:void 0,version:void 0,author:void 0,license:void 0,_key:c(Ee.registry,Ee.id),registry:Ee.registry,registryHomepage:ae?.homepage,registryLabel:d(Ee.registry),isBroken:!0,isRegistryMissing:!Fe.has(Ee.registry)}}),Ae=Ee=>N?Ee.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)):Ee;return[...Ae(fe),...Ae(Y)]}),k=qt(()=>x.value),E=N=>N.description?N.description:N.isBroken?N.isRegistryMissing?n`plugin-store.broken.registry-unavailable`:n`plugin-store.broken.plugin-removed`:"",y=async(N,Y)=>{e.store.installAndSetPreference(N,Y)},b=async(N,Y)=>{e.store.uninstallAndRemovePreference(N,Y)},g=(N,Y)=>u(c(N,Y))?b(N,Y):y(N,Y),w=N=>g(N.registry,N.id),S=async()=>{if(a.value)return;if(r.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(),Y=Object.entries(N).filter(([Fe,fe])=>fe!==null);r.value=Y.map(([Fe,fe])=>({...fe,registryUrl:Fe}));const K=Object.entries(N).filter(([Fe,fe])=>fe===null).map(([Fe])=>Fe);a.value=!1,Y.length===0?e.modal.notify("error",{content:"All registries failed to refresh"}):(e.modal.notify("success",{content:`${Y.length} ${Y.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
+ ${K.join(`
35
+ `)}`}))},R=async()=>{m.value=!1;const N=await e.store.ctx.preferences.get("pluginStore.registries")||[],Y=await Promise.allSettled(N.map(async K=>({...await e.store.getRegistryInfo(K),registryUrl:K})));r.value=Y.filter(K=>K.status==="fulfilled").map(K=>K.value),s.value=await e.preferences.get("pluginStore.plugins")||[],m.value=!0};function B(N){const Y=N.changes["pluginStore.registries"],K=N.changes["pluginStore.plugins"];Array.isArray(K)&&(s.value=K),Array.isArray(Y)&&R()}return Ln(()=>{R(),e.on("preferences/changed",B)}),qo(()=>{}),(N,Y)=>(ue(),ve("div",I_,[ie("div",R_,[ie("div",A_,ye(Oe(i)`Plugins`),1),ie("div",T_,[au(ie("input",{class:"ipeps-input with-icon","onUpdate:modelValue":Y[0]||(Y[0]=K=>o.value=K),type:"text",placeholder:Oe(i)`Search plugins...`,disabled:!h.value.length},null,8,O_),[[fd,o.value,void 0,{trim:!0}]]),Y[1]||(Y[1]=ie("div",{class:"ipeps-input-icon"},"🔍",-1))]),ie("button",{class:_t(["ipeps-button",{refreshing:a.value}]),onClick:S,disabled:a.value||!p.value,variant:"primary"},ye(a.value?Oe(i)`Refreshing...`:Oe(i)`Refresh`),11,L_)]),!p.value&&!m.value?(ue(),ve("div",N_,[Y[2]||(Y[2]=ie("div",{class:"loading-spinner"},null,-1)),ie("div",M_,ye(Oe(i)`Loading...`),1)])):k.value.length?(ue(),ve("div",D_,[(ue(!0),ve(We,null,Ho(k.value,K=>(ue(),ve("div",{class:_t(["ipeps-item",{installed:u(K._key),broken:K.isBroken}]),key:K._key},[ie("div",j_,[ie("div",U_,[ie("div",F_,ye(K.name||K.id),1),u(K._key)||K.isBroken?(ue(),ve("span",{key:0,class:_t(["ipeps-badge",{"is-installed":u(K._key),"is-broken":K.isBroken}])},ye(K.isBroken?Oe(n)`plugin-store.tags.broken`:Oe(n)`plugin-store.tags.installed`),3)):di("",!0)]),ie("div",B_,[K.registryHomepage&&!K.isRegistryMissing?(ue(),ve("a",{key:0,class:"ipeps-tag registry-tag",href:K.registryHomepage,target:"_blank",title:K.registryLabel},ye(K.registryLabel),9,q_)):(ue(),ve("span",{key:1,class:_t(["ipeps-tag registry-tag",{broken:K.isRegistryMissing}]),title:K.registryLabel},ye(K.registryLabel),11,z_)),ie("div",{class:_t(["plugin-id ipeps-tag",{broken:K.isBroken&&!K.isRegistryMissing}])},ye(K.id),3)]),ie("div",{class:_t(["plugin-desc",{"broken-desc":K.isBroken}])},ye(E(K)),3),ie("div",H_,[K.version?(ue(),ve("span",W_,"v"+ye(K.version),1)):di("",!0),K.author?(ue(),ve("span",K_,"👤 "+ye(K.author),1)):di("",!0),K.license?(ue(),ve("span",V_,"📜 "+ye(K.license),1)):di("",!0)])]),Ne(us,{active:u(K._key),variant:u(K._key)?"danger":"primary",onClick:Fe=>w(K)},{default:An(()=>[Fn(ye(u(K._key)?Oe(i)`Remove`:Oe(i)`Install`),1)]),_:2},1032,["active","variant","onClick"])],2))),128))])):(ue(),ve("div",G_,[Y[3]||(Y[3]=ie("div",{class:"plugin-empty-icon"},"📦",-1)),ie("div",Q_,ye(Oe(i)`No matching plugins found`),1)]))]))}}),[["__scopeId","data-v-d3aab2b1"]]),X_={id:"ipe-plugin-store-app"},J_=Object.freeze(Object.defineProperty({__proto__:null,default:Zr($i({__name:"PluginStoreApp",setup(t){return(e,i)=>(ue(),ve("div",X_,[Ne(Y_),i[0]||(i[0]=ie("div",{class:"divider-wrapper"},[ie("hr",{class:"divider"})],-1)),Ne(C_)]))}}),[["__scopeId","data-v-1b3d0d80"]])},Symbol.toStringTag,{value:"Module"}));var Z_=Object.create,Ta=Object.defineProperty,e0=Object.getOwnPropertyDescriptor,xf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),kf=t=>{throw TypeError(t)},t0=(t,e,i)=>e in t?Ta(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,i0=(t,e)=>Ta(t,"name",{value:e,configurable:!0}),n0=t=>[,,,Z_(t?.[xf("metadata")]??null)],r0=["class","method","getter","setter","accessor","field","value","get","set"],Sf=t=>t!==void 0&&typeof t!="function"?kf("Function expected"):t,s0=(t,e,i,n,r)=>({kind:r0[t],name:e,metadata:n,addInitializer:s=>i._?kf("Already initialized"):r.push(Sf(s||null))}),o0=(t,e)=>t0(e,xf("metadata"),t[3]),a0=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},l0=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&e0(r,i));i0(r,i);for(var h=n.length-1;h>=0;h--)c=s0(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,Sf(o)&&(r=o);return o0(t,r),p&&Ta(r,i,p),u?l^4?s:p:r},$f,Oa,Ef;$f=[xe(["preferences","wiki","wikiPage","wikiTitle","modal","preferencesUI","$"])];class ds extends(Ef=je){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 n=this.getUserPrefsPageTitle();return f("div",{className:"theme-ipe-prose",children:[n&&f("section",{children:[f("h3",{children:i`Backup your preferences via user page`}),f("p",{children:f("a",{href:n?.getURL().toString(),target:"_blank",children:[n?.getPrefixedText()," →"]})}),f("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[f(Wn,{type:"primary",onClick:r=>{r.preventDefault();const s=r.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(Wn,{onClick:r=>{r.preventDefault();const s=e.preferencesUI.getCurrentModal(),o=r.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(Wn,{onClick:r=>{r.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(Wn,{onClick:r=>{r.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(Wn,{onClick:async r=>{r.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"}),n=await this.importFromUrl(i.toString());return this.logger.info("Loaded preferences from user page:",e),n}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 n=await e.preferences.getExportableRecord(),r=JSON.stringify(n,null,2);try{return await this.ctx.wikiPage.newBlankPage({title:i.toString(),ns:2}).edit({text:r,summary:"Update InPageEdit preferences",watchlist:wt.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 n=await i.blob();return await this.importFromFile(n)}async importFromFile(e){const i=await e.text(),n=JSON.parse(i);return await this.ctx.preferences.setMany(n)}notifyImportSuccess(e){const{$:i}=this.ctx,n=Object.keys(e??{}),r=n.length;return this.ctx.modal.notify("success",{title:i`Preferences Imported`,content:f("section",{children:[f("p",{children:i({count:r})`Successfully imported {{ count }} {{ count > 1 ? "settings" : "setting" }}:`}),f("ol",{style:{listStyle:"auto",paddingLeft:"1em"},children:n.map(s=>f("li",{children:s},s))})]})})}}Oa=n0(Ef),ds=l0(Oa,0,"PluginPrefSync",$f,ds),a0(Oa,1,ds);const c0=Object.freeze(Object.defineProperty({__proto__:null,get PluginPrefSync(){return ds}},Symbol.toStringTag,{value:"Module"}));var u0=Object.create,La=Object.defineProperty,d0=Object.getOwnPropertyDescriptor,Pf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Cf=t=>{throw TypeError(t)},f0=(t,e,i)=>e in t?La(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,h0=(t,e)=>La(t,"name",{value:e,configurable:!0}),p0=t=>[,,,u0(t?.[Pf("metadata")]??null)],g0=["class","method","getter","setter","accessor","field","value","get","set"],If=t=>t!==void 0&&typeof t!="function"?Cf("Function expected"):t,m0=(t,e,i,n,r)=>({kind:g0[t],name:e,metadata:n,addInitializer:s=>i._?Cf("Already initialized"):r.push(If(s||null))}),y0=(t,e)=>f0(e,Pf("metadata"),t[3]),b0=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},v0=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&d0(r,i));h0(r,i);for(var h=n.length-1;h>=0;h--)c=m0(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,If(o)&&(r=o);return y0(t,r),p&&La(r,i,p),u?l^4?s:p:r},Rf,Na,Af;Rf=[xe(["modal","$"])];class fs extends(Af=je){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:n,modal:r}=e;if(!n||!n.pageid)return;const s=this.ctx.quickUsage.getWrapperForQuickEdit(r),o=f("a",{href:`#ipe://quick-usage/templates?title=${n.title}`,onClick:async a=>{a.preventDefault();const c=await this.showModal({wikiPage:n});c&&r.on(r.Event.Close,()=>{c.destroy()})},children:i`Templates Used`});s.appendChild(o)}async showModal(e={}){const{$:i}=this.ctx,n=e.wikiPage||await this.ctx.wikiPage.WikiPage.newFromAnyKind(e);if(!n||!n.pageid)return;const r=this.ctx.modal.show({title:i`Templates Used`,content:f("section",{className:"ipe-quickUsage__templates",children:f("ol",{children:n.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"}),r}}Na=p0(Af),fs=v0(Na,0,"PluginTemplatesUsed",Rf,fs),b0(Na,1,fs);const w0=Object.freeze(Object.defineProperty({__proto__:null,get PluginTemplatesUsed(){return fs}},Symbol.toStringTag,{value:"Module"}));var _0=Object.create,Ma=Object.defineProperty,x0=Object.getOwnPropertyDescriptor,Tf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Of=t=>{throw TypeError(t)},k0=(t,e,i)=>e in t?Ma(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,S0=(t,e)=>Ma(t,"name",{value:e,configurable:!0}),$0=t=>[,,,_0(t?.[Tf("metadata")]??null)],E0=["class","method","getter","setter","accessor","field","value","get","set"],Lf=t=>t!==void 0&&typeof t!="function"?Of("Function expected"):t,P0=(t,e,i,n,r)=>({kind:E0[t],name:e,metadata:n,addInitializer:s=>i._?Of("Already initialized"):r.push(Lf(s||null))}),C0=(t,e)=>k0(e,Tf("metadata"),t[3]),I0=(t,e,i,n)=>{for(var r=0,s=t[e>>1],o=s&&s.length;r<o;r++)s[r].call(i);return n},R0=(t,e,i,n,r,s)=>{var o,a,c,l=e&7,u=!1,d=0,m=t[d]||(t[d]=[]),p=l&&(r=r.prototype,l<5&&(l>3||!u)&&x0(r,i));S0(r,i);for(var h=n.length-1;h>=0;h--)c=P0(l,i,a={},t[3],m),o=(0,n[h])(r,c),a._=1,Lf(o)&&(r=o);return C0(t,r),p&&Ma(r,i,p),u?l^4?s:p:r},Nf,Da,Mf;Nf=[xe(["modal","$"])];class hs extends(Mf=je){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:n,modal:r}=e;if(!n||!n.pageid)return;const s=this.ctx.quickUsage.getWrapperForQuickEdit(r),o=f("a",{href:`#ipe://quick-usage/images?title=${n.title}`,onClick:async a=>{a.preventDefault();const c=await this.showModal({wikiPage:n});c&&r.on(r.Event.Close,()=>{c.destroy()})},children:i`Images Used`});s.appendChild(o)}async showModal(e={}){const{$:i}=this.ctx,n=e.wikiPage||await this.ctx.wikiPage.WikiPage.newFromAnyKind(e);if(!n||!n.pageid)return;const r=this.ctx.modal.show({title:i`Images Used`,content:f("section",{className:"ipe-quickUsage__images",children:f("ol",{children:n.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"}),r}}Da=$0(Mf),hs=R0(Da,0,"PluginImagesUsed",Nf,hs),I0(Da,1,hs);const A0=Object.freeze(Object.defineProperty({__proto__:null,get PluginImagesUsed(){return hs}},Symbol.toStringTag,{value:"Module"}));Q.BasePlugin=je,Q.CordisSymbols=U,Q.EffectScope=Ps,Q.Endpoints=Lt,Q.ForkScope=Ja,Q.InPageEdit=Ui,Q.Inject=xe,Q.Lifecycle=Ya,Q.Logger=tl,Q.LoggerLevel=Is,Q.MainScope=Cs,Q.RegisterPreferences=Tt,Q.Schema=I,Q.ScopeStatus=Xa,Q.Service=pt,Q.createLogger=rl,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})}));
32
36
  //# sourceMappingURL=index.umd.js.map