@inpageedit/core 0.11.1 → 0.12.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 (102) hide show
  1. package/LICENSE +20 -20
  2. package/dist/ActionButton-CRjo_l3y.js +24 -0
  3. package/dist/ActionButton-CRjo_l3y.js.map +1 -0
  4. package/dist/{CheckBox-D3rHnX7I.js → CheckBox-Bc79KBEB.js} +2 -2
  5. package/dist/{CheckBox-D3rHnX7I.js.map → CheckBox-Bc79KBEB.js.map} +1 -1
  6. package/dist/{IconQuickEdit-CAL1HXIb.js → IconQuickEdit-CMCQncyj.js} +2 -2
  7. package/dist/IconQuickEdit-CMCQncyj.js.map +1 -0
  8. package/dist/InPageEdit.d.ts +5 -1
  9. package/dist/{InputBox-BV4m05Xs.js → InputBox-DZAdyZ4B.js} +2 -2
  10. package/dist/InputBox-DZAdyZ4B.js.map +1 -0
  11. package/dist/PluginPrefSync-BPQkNtX8.js +292 -0
  12. package/dist/PluginPrefSync-BPQkNtX8.js.map +1 -0
  13. package/dist/PluginStoreApp-Cxspe6t8.js +158 -0
  14. package/dist/PluginStoreApp-Cxspe6t8.js.map +1 -0
  15. package/dist/Preferences-DS4-CFWe.js.map +1 -1
  16. package/dist/{RadioBox-nJqWsxW2.js → RadioBox-0UuxlcWZ.js} +2 -2
  17. package/dist/{RadioBox-nJqWsxW2.js.map → RadioBox-0UuxlcWZ.js.map} +1 -1
  18. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +10 -0
  19. package/dist/_plugin-vue_export-helper-CHgC5LLL.js.map +1 -0
  20. package/dist/components/index.js +51 -69
  21. package/dist/components/index.js.map +1 -1
  22. package/dist/constants/endpoints.d.ts +2 -1
  23. package/dist/index-B5DtUqkK.js +180 -0
  24. package/dist/index-B5DtUqkK.js.map +1 -0
  25. package/dist/{index-BUI2IX49.js → index-BXaiDKnr.js} +2312 -2315
  26. package/dist/index-BXaiDKnr.js.map +1 -0
  27. package/dist/{index-BNDyaWnI.js → index-Bv7Dw5eO.js} +10 -9
  28. package/dist/index-Bv7Dw5eO.js.map +1 -0
  29. package/dist/{index-MhNAv9Vf.js → index-CB7TltEb.js} +25 -30
  30. package/dist/index-CB7TltEb.js.map +1 -0
  31. package/dist/{index-lZkYoUca.js → index-CG38LlAh.js} +2 -2
  32. package/dist/index-CG38LlAh.js.map +1 -0
  33. package/dist/{index-BQzuJxBO.js → index-CJFePavo.js} +4 -4
  34. package/dist/index-CJFePavo.js.map +1 -0
  35. package/dist/{index-CvhkVj_L.js → index-CM_6yF2v.js} +3 -3
  36. package/dist/{index-CvhkVj_L.js.map → index-CM_6yF2v.js.map} +1 -1
  37. package/dist/{index-U2RPZk8N.js → index-CPoUaSMw.js} +8 -8
  38. package/dist/index-CPoUaSMw.js.map +1 -0
  39. package/dist/{index-CfgnJ51A.js → index-CYc6LH26.js} +53 -43
  40. package/dist/index-CYc6LH26.js.map +1 -0
  41. package/dist/index-CZXxH2-9.js +173 -0
  42. package/dist/index-CZXxH2-9.js.map +1 -0
  43. package/dist/{index-D5J7RU5I.js → index-Ckozkp6W.js} +5 -7
  44. package/dist/index-Ckozkp6W.js.map +1 -0
  45. package/dist/{index-etJXONAj.js → index-D4uwfUZL.js} +6 -6
  46. package/dist/index-D4uwfUZL.js.map +1 -0
  47. package/dist/{index-Bh70Udzi.js → index-DD5CVCfD.js} +2 -2
  48. package/dist/index-DD5CVCfD.js.map +1 -0
  49. package/dist/index-DEav9Ptt.js +365 -0
  50. package/dist/index-DEav9Ptt.js.map +1 -0
  51. package/dist/index-hSl8LzNb.js +1169 -0
  52. package/dist/index-hSl8LzNb.js.map +1 -0
  53. package/dist/index.js +1 -1
  54. package/dist/makeCallable-LDU0xZMJ.js.map +1 -1
  55. package/dist/models/MemoryStorage.d.ts +10 -0
  56. package/dist/models/WikiPage/index.d.ts +14 -0
  57. package/dist/noop-ClDc6zv4.js.map +1 -1
  58. package/dist/plugins/in-article-links/index.d.ts +5 -0
  59. package/dist/plugins/plugin-store/index.d.ts +59 -0
  60. package/dist/plugins/plugin-store/schema.d.ts +41 -0
  61. package/dist/plugins/preferences-ui/PluginPrefSync.d.ts +1 -0
  62. package/dist/plugins/preferences-ui/index.d.ts +34 -5
  63. package/dist/plugins/quick-delete/index.d.ts +3 -0
  64. package/dist/plugins/quick-diff/index.d.ts +3 -0
  65. package/dist/plugins/quick-edit/index.d.ts +8 -0
  66. package/dist/plugins/quick-move/index.d.ts +5 -3
  67. package/dist/plugins/quick-preview/index.d.ts +4 -0
  68. package/dist/plugins/quick-redirect/index.d.ts +11 -4
  69. package/dist/plugins/toolbox/index.d.ts +3 -0
  70. package/dist/services/PreferencesService.d.ts +53 -11
  71. package/dist/services/ResourceLoaderService.d.ts +3 -0
  72. package/dist/services/WikiMetadataService.d.ts +1 -1
  73. package/dist/services/storage/index.d.ts +18 -8
  74. package/dist/services/storage/{IPEStorageManager.d.ts → managers/IDBStorageManager.d.ts} +9 -6
  75. package/dist/services/storage/managers/LocalStorageManager.d.ts +27 -0
  76. package/dist/style.css +1 -1
  77. package/dist/vueHooks-D0uVqbO-.js +4032 -0
  78. package/dist/vueHooks-D0uVqbO-.js.map +1 -0
  79. package/lib/index.umd.js +11 -115
  80. package/lib/index.umd.js.map +1 -1
  81. package/lib/style.css +1 -1
  82. package/package.json +14 -14
  83. package/dist/IconQuickEdit-CAL1HXIb.js.map +0 -1
  84. package/dist/InputBox-BV4m05Xs.js.map +0 -1
  85. package/dist/PluginPrefSync-COidewzp.js +0 -258
  86. package/dist/PluginPrefSync-COidewzp.js.map +0 -1
  87. package/dist/index-BNDyaWnI.js.map +0 -1
  88. package/dist/index-BQzuJxBO.js.map +0 -1
  89. package/dist/index-BUI2IX49.js.map +0 -1
  90. package/dist/index-Bh70Udzi.js.map +0 -1
  91. package/dist/index-CBszdxJJ.js +0 -159
  92. package/dist/index-CBszdxJJ.js.map +0 -1
  93. package/dist/index-CfgnJ51A.js.map +0 -1
  94. package/dist/index-Cx4qgCJK.js +0 -4914
  95. package/dist/index-Cx4qgCJK.js.map +0 -1
  96. package/dist/index-D5J7RU5I.js.map +0 -1
  97. package/dist/index-MhNAv9Vf.js.map +0 -1
  98. package/dist/index-U2RPZk8N.js.map +0 -1
  99. package/dist/index-VnRKIVau.js +0 -167
  100. package/dist/index-VnRKIVau.js.map +0 -1
  101. package/dist/index-etJXONAj.js.map +0 -1
  102. package/dist/index-lZkYoUca.js.map +0 -1
package/lib/index.umd.js CHANGED
@@ -1,122 +1,18 @@
1
- (function(X,ne){typeof exports=="object"&&typeof module<"u"?ne(exports):typeof define=="function"&&define.amd?define(["exports"],ne):(X=typeof globalThis<"u"?globalThis:X||self,ne(X.InPageEditBundle={}))})(this,function(X){"use strict";var jb=Object.defineProperty;var Xu=X=>{throw TypeError(X)};var Ub=(X,ne,_e)=>ne in X?jb(X,ne,{enumerable:!0,configurable:!0,writable:!0,value:_e}):X[ne]=_e;var j=(X,ne,_e)=>Ub(X,typeof ne!="symbol"?ne+"":ne,_e),jo=(X,ne,_e)=>ne.has(X)||Xu("Cannot "+_e);var J=(X,ne,_e)=>(jo(X,ne,"read from private field"),_e?_e.call(X):ne.get(X)),Ni=(X,ne,_e)=>ne.has(X)?Xu("Cannot add the same private member more than once"):ne instanceof WeakSet?ne.add(X):ne.set(X,_e),We=(X,ne,_e,z)=>(jo(X,ne,"write to private field"),z?z.call(X,_e):ne.set(X,_e),_e),nt=(X,ne,_e)=>(jo(X,ne,"access private method"),_e);var tt,Ii,si,Ai,Ti,Ri,Li,ve,Ge,ue,qe,Uo,nf,Fo,rf,sf,_t,of,af,lf,cf,vn,oi;const ne=()=>{let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};Promise.withResolvers||(Promise.withResolvers=ne);var _e=Object.defineProperty,z=(t,e)=>_e(t,"name",{value:e,configurable:!0});function uf(){}z(uf,"noop");function ge(t){return t==null}z(ge,"isNullable");function ff(t){return!ge(t)}z(ff,"isNonNullable");function kn(t){return t&&typeof t=="object"&&!Array.isArray(t)}z(kn,"isPlainObject");function Bo(t,e){return Object.fromEntries(Object.entries(t).filter(([i,n])=>e(i,n)))}z(Bo,"filterKeys");function $t(t,e){return Object.fromEntries(Object.entries(t).map(([i,n])=>[i,e(n,i)]))}z($t,"mapValues");function qo(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}z(qo,"pick");function df(t,e){if(!e)return{...t};const i={...t};for(const n of e)Reflect.deleteProperty(i,n);return i}z(df,"omit");function Oe(t,e,i){return Object.defineProperty(t,e,{writable:!0,value:i,enumerable:!1})}z(Oe,"defineProperty");function hf(t,e){return e.every(i=>t.includes(i))}z(hf,"contain");function pf(t,e){return t.filter(i=>e.includes(i))}z(pf,"intersection");function mf(t,e){return t.filter(i=>!e.includes(i))}z(mf,"difference");function gf(t,e){return Array.from(new Set([...t,...e]))}z(gf,"union");function yf(t){return[...new Set(t)]}z(yf,"deduplicate");function Mt(t,e){const i=t?.indexOf(e);return i>=0?(t.splice(i,1),!0):!1}z(Mt,"remove");function bf(t){return Array.isArray(t)?t:ge(t)?[]:[t]}z(bf,"makeArray");function Dt(t,e){return arguments.length===1?i=>Dt(t,i):t in globalThis&&e instanceof globalThis[t]||Object.prototype.toString.call(e).slice(8,-1)===t}z(Dt,"is");function Mi(t){return Dt("ArrayBuffer",t)||Dt("SharedArrayBuffer",t)}z(Mi,"isArrayBufferLike");function Ho(t){return Mi(t)||ArrayBuffer.isView(t)}z(Ho,"isArrayBufferSource");var ct;(t=>{t.is=Mi,t.isSource=Ho;function e(o){return ArrayBuffer.isView(o)?o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength):o}t.fromSource=e,z(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,z(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,z(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,z(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,z(s,"fromHex")})(ct||(ct={})),ct.fromBase64,ct.toBase64,ct.fromHex,ct.toHex;function En(t,e=new Map){if(!t||typeof t!="object")return t;if(Dt("Date",t))return new Date(t.valueOf());if(Dt("RegExp",t))return new RegExp(t.source,t.flags);if(Mi(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(En,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(En,null,[s.value,e])),Reflect.defineProperty(n,r,s)}return n}z(En,"clone");function Qt(t,e,i){if(t===e||!i&&ge(t)&&ge(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 z(n,"check"),n(Array.isArray,(r,s)=>r.length===s.length&&r.every((o,a)=>Qt(o,s[a])))??n(Dt("Date"),(r,s)=>r.valueOf()===s.valueOf())??n(Dt("RegExp"),(r,s)=>r.source===s.source&&r.flags===s.flags)??n(Mi,(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=>Qt(t[r],e[r],i))}z(Qt,"deepEqual");function wf(t){return t.charAt(0).toUpperCase()+t.slice(1)}z(wf,"capitalize");function vf(t){return t.charAt(0).toLowerCase()+t.slice(1)}z(vf,"uncapitalize");function _f(t){return t.replace(/[_-][a-z]/g,e=>e.slice(1).toUpperCase())}z(_f,"camelCase");function Lr(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)}z(Lr,"tokenize");function xf(t){return Lr(t,[45,95],45)}z(xf,"paramCase");function Sf(t){return Lr(t,[45,95],95)}z(Sf,"snakeCase");function kf(t){return typeof t!="string"?`[${t.toString()}]`:/^[a-z_$][\w$]*$/i.test(t)?`.${t}`:`[${JSON.stringify(t)}]`}z(kf,"formatProperty");function zo(t){return t.replace(/\/$/,"")}z(zo,"trimSlash");function Ef(t){return t.startsWith("/")||(t="/"+t),zo(t)}z(Ef,"sanitize");var Wo;(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(m){e=m}t.setTimezoneOffset=i,z(i,"setTimezoneOffset");function n(){return e}t.getTimezoneOffset=n,z(n,"getTimezoneOffset");function r(m=new Date,g){return typeof m=="number"&&(m=new Date(m)),g===void 0&&(g=e),Math.floor((m.valueOf()/t.minute-g)/1440)}t.getDateNumber=r,z(r,"getDateNumber");function s(m,g){const k=new Date(m*t.day);return g===void 0&&(g=e),new Date(+k+g*t.minute)}t.fromDateNumber=s,z(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(m=>`(${o}${m})?`).join("")}$`);function l(m){const g=a.exec(m);return g?(parseFloat(g[1])*t.week||0)+(parseFloat(g[2])*t.day||0)+(parseFloat(g[3])*t.hour||0)+(parseFloat(g[4])*t.minute||0)+(parseFloat(g[5])*t.second||0):0}t.parseTime=l,z(l,"parseTime");function c(m){const g=l(m);return g?m=Date.now()+g:/^\d{1,2}(:\d{1,2}){1,2}$/.test(m)?m=`${new Date().toLocaleDateString()}-${m}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(m)&&(m=`${new Date().getFullYear()}-${m}`),m?new Date(m):new Date}t.parseDate=c,z(c,"parseDate");function u(m){const g=Math.abs(m);return g>=t.day-t.hour/2?Math.round(m/t.day)+"d":g>=t.hour-t.minute/2?Math.round(m/t.hour)+"h":g>=t.minute-t.second/2?Math.round(m/t.minute)+"m":g>=t.second?Math.round(m/t.second)+"s":m+"ms"}t.format=u,z(u,"format");function f(m,g=2){return m.toString().padStart(g,"0")}t.toDigits=f,z(f,"toDigits");function h(m,g=new Date){return m.replace("yyyy",g.getFullYear().toString()).replace("yy",g.getFullYear().toString().slice(2)).replace("MM",f(g.getMonth()+1)).replace("dd",f(g.getDate())).replace("hh",f(g.getHours())).replace("mm",f(g.getMinutes())).replace("ss",f(g.getSeconds())).replace("SSS",f(g.getMilliseconds(),3))}t.template=h,z(h,"template")})(Wo||(Wo={}));var $f=Object.defineProperty,W=(t,e)=>$f(t,"name",{value:e,configurable:!0}),N={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")},Pf=function*(){}.constructor,Ko=async function*(){}.constructor;function Nr(t){return!(!t.prototype||t instanceof Pf||Ko!==Function&&t instanceof Ko)}W(Nr,"isConstructor");function Di(t,e){const i=t.Config||t.schema;return i&&t.schema!==!1&&(e=i(e)),e??{}}W(Di,"resolveConfig");function Vo(t){return[Map,Set,Date,Promise].some(e=>t instanceof e)}W(Vo,"isUnproxyable");function Mr(t,e){if(t===Object.prototype)return e;const i=Object.create(Mr(Object.getPrototypeOf(t),e));for(const n of Reflect.ownKeys(t))Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n));return i}W(Mr,"joinPrototype");function Dr(t){return t&&(typeof t=="object"||typeof t=="function")}W(Dr,"isObject");function ut(t,e,i){if(!Dr(e))return e;if(Object.hasOwn(e,N.shadow))return Object.getPrototypeOf(e);const n=e[N.tracker];return n?Pn(t,e,n,i):e}W(ut,"getTraceable");function ji(t,e){return e?new Proxy(t,{get:W((i,n,r)=>n in e&&n!=="constructor"?Reflect.get(e,n,r):Reflect.get(i,n,r),"get"),set:W((i,n,r,s)=>n in e&&n!=="constructor"?Reflect.set(e,n,r,s):Reflect.set(i,n,r,s),"set")}):t}W(ji,"withProps");function $n(t,e,i){return ji(t,Object.defineProperty(Object.create(null),e,{value:i,writable:!1}))}W($n,"withProp");function jr(t,e,i,n){if(!i)return n;const r=Reflect.getOwnPropertyDescriptor(e,i)?.value;return r?$n(n,i,t.extend({[N.shadow]:r})):n}W(jr,"createShadow");function Qo(t,e,i,n){return new Proxy(e,{apply:W((r,s,o)=>(s===i&&(s=n),o=o.map(a=>typeof a!="function"||a[N.original]?a:new Proxy(a,{get:W((l,c,u)=>{if(c===N.original)return l;const f=Reflect.get(l,c,u);return c==="toString"&&f===Function.prototype.toString?function(...h){return Reflect.apply(f,this===u?l:this,h)}:f},"get"),apply:W((l,c,u)=>Reflect.apply(l,ut(t,c),u.map(f=>ut(t,f))),"apply"),construct:W((l,c,u)=>Reflect.construct(l,c.map(f=>ut(t,f)),u),"construct")})),ut(t,Reflect.apply(r,s,o))),"apply")})}W(Qo,"createShadowMethod");function Pn(t,e,i,n){t[N.shadow]&&(t=Object.getPrototypeOf(t));const r=new Proxy(e,{get:W((s,o,a)=>{if(o===N.original)return s;if(o===i.property)return t;if(typeof o=="symbol")return Reflect.get(s,o,a);if(i.associate&&t[N.internal][`${i.associate}.${o}`])return Reflect.get(t,`${i.associate}.${o}`,$n(t,N.receiver,a));const l=jr(t,s,i.property,a),c=Reflect.get(s,o,l),u=c?.[N.tracker];return u?Pn(t,c,u):!n&&typeof c=="function"?Qo(t,c,a,l):c},"get"),set:W((s,o,a,l)=>{if(o===N.original||o===i.property)return!1;if(typeof o=="symbol")return Reflect.set(s,o,a,l);if(i.associate&&t[N.internal][`${i.associate}.${o}`])return Reflect.set(t,`${i.associate}.${o}`,a,$n(t,N.receiver,l));const c=jr(t,s,i.property,l);return Reflect.set(s,o,a,c)},"set"),apply:W((s,o,a)=>Ur(r,s,o,a),"apply")});return r}W(Pn,"createTraceable");function Ur(t,e,i,n){return e[N.invoke]?e[N.invoke].apply(t,n):Reflect.apply(e,i,n)}W(Ur,"applyTraceable");function Fr(t,e,i){const n=W(function(...r){const s=Pn(n.ctx,n,i);return Ur(s,n,this,r)},"self");return Oe(n,"name",t),Object.setPrototypeOf(n,e)}W(Fr,"createCallable");var Cf=(tt=class{constructor(e){this.ctx=e,Oe(this,N.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[N.internal][i];for(;n?.type==="alias";)i=n.name,n=e[N.internal][i];return[i,n]}static checkInject(e,i,n){if(e=e[N.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
- `);r.splice(1,1),n.stack=r.join(`
3
- `),e.emit(e,"internal/warning",n)}get(e){if(this.ctx[N.internal][e]?.type!=="service")return;const n=this.ctx[N.isolate][e],r=this.ctx[N.store][n]?.value;return ut(this.ctx,r)}set(e,i){this.provide(e);const n=this.ctx[N.isolate][e],r=this.ctx[N.store][n]?.value;i??(i=void 0);let s=W(()=>{},"dispose");if(r===i)return s;if(!ge(i)&&!ge(r))throw new Error(`service ${e} has been registered`);const o=this.ctx;ge(i)||(s=o.effect(()=>()=>{o.set(e,void 0)})),Vo(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[N.filter]=l=>o[N.isolate][e]===l[N.isolate][e],o.emit(a,"internal/before-service",e,i),o[N.store][n]={value:i,source:o},o.emit(a,"internal/service",e,r),s}provide(e,i,n){const r=this.ctx.root[N.internal];if(e in r)return;const s=Symbol(e);r[e]={type:"service",builtin:n},this.ctx.root[N.isolate][e]=s,Dr(i)&&(this.ctx[N.store][s]={value:i,source:null},Oe(i,N.tracker,{associate:e,property:"ctx"}))}_accessor(e,i){const n=this.ctx.root[N.internal];return e in n?()=>{}:(n[e]={type:"accessor",...i},()=>delete this.ctx.root[N.isolate][e])}accessor(e,i){this.ctx.scope.effect(()=>this._accessor(e,i))}alias(e,i){const n=this.ctx.root[N.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(ge(c))return c;const u=l?ji(l,c):c,f=Reflect.get(c,o,u);return typeof f!="function"?f:f.bind(u??c)},set(l,c){const u=r(this),f=c?ji(c,u):u;return Reflect.set(u,o,l,f)}}));return()=>s.forEach(o=>o())}mixin(e,i){this.ctx.scope.effect(()=>this._mixin(e,i))}trace(e){return ut(this.ctx,e)}bind(e){return new Proxy(e,{apply:W((i,n,r)=>i.apply(this.trace(n),r.map(s=>this.trace(s))),"apply")})}},W(tt,"ReflectService"),j(tt,"handler",{get:W((e,i,n)=>{if(typeof i!="string")return Reflect.get(e,i,n);if(Reflect.has(e,i))return ut(n,Reflect.get(e,i,n),!0);const[r,s]=tt.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[N.receiver]):(s.builtin||tt.checkInject(n,r,o),n.reflect.get(r)):(tt.checkInject(n,r,o),Reflect.get(e,r,n))},"get"),set:W((e,i,n,r)=>{if(typeof i!="string")return Reflect.set(e,i,n,r);const[s,o]=tt.resolveInject(e,i);return o?o.type==="accessor"?o.set?o.set.call(r,n,r[N.receiver]):!1:(r.reflect.set(s,n),!0):Reflect.set(e,s,n,r)},"set"),has:W((e,i)=>{if(typeof i!="string")return Reflect.has(e,i);if(Reflect.has(e,i))return!0;const[,n]=tt.resolveInject(e,i);return!!n},"has")}),tt),Br=Cf;function qr(t){return t!==null&&t!==!1&&t!==void 0}W(qr,"isBailed");var Of=(Ii=class{constructor(e){j(this,"isActive",!1);j(this,"_tasks",new Set);j(this,"_hooks",{});this.ctx=e,Oe(this,N.tracker,{associate:"lifecycle",property:"ctx"}),Oe(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),Oe(r,"name","event <dispose>"),()=>Mt(this.scope.disposables,r);if(n==="fork")return this.scope.runtime.forkables[o](r),this.scope.collect("event <fork>",()=>Mt(this.scope.runtime.forkables,r))}),Me.static,e.scope);for(const n of["info","error","warning"])Oe(this.on(`internal/${n}`,(r,...s)=>{this._hooks[`internal/${n}`].length>1}),Me.static,e.scope);Oe(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[N.filter](o.ctx)&&(o.updateStatus(),o.reset())}},{global:!0}),Me.static,e.scope),Oe(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[N.filter](o.ctx)&&o.start()}},{global:!0}),Me.static,e.scope);const i=W((n,r)=>{if(!n.runtime.plugin)return!1;for(const s in n.runtime.inject)if(r===Br.resolveInject(n.ctx,s)[0])return!0;return i(n.parent.scope,r)},"checkInject");Oe(this.on("internal/inject",function(n){return i(this.scope,n)},{global:!0}),Me.static,e.scope)}async flush(){for(;this._tasks.size;)await Promise.all(Array.from(this._tasks))}filterHooks(e,i){return i=ut(this.ctx,i),e.slice().filter(n=>{const r=i?.[Me.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(qr(i))return i}bail(...e){for(const i of this.dispatch("bail",e))if(qr(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()}},W(Ii,"Lifecycle"),Ii),If=Of,Hr=(si=class extends Error{constructor(e,i){super(i??si.Code[e]),this.code=e}},W(si,"CordisError"),si);(t=>{t.Code={INACTIVE_EFFECT:"cannot create effect on inactive context"}})(Hr||(Hr={}));var Yo=(Ai=class{constructor(e,i){j(this,"uid");j(this,"ctx");j(this,"disposables",[]);j(this,"error");j(this,"status",0);j(this,"isActive",!1);j(this,"context");j(this,"proxy");j(this,"acceptors",[]);j(this,"tasks",new Set);j(this,"hasError",!1);this.parent=e,this.config=i,this.uid=e.registry?e.registry.counter:0,this.ctx=this.context=e.extend({scope:this}),this.proxy=new Proxy({},{get:W((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 Hr("INACTIVE_EFFECT")}effect(e,i){this.assertActive();const n=Nr(e)?new e(this.ctx,i):e(this.ctx,i);let r=!1;const s=typeof n=="function"?n:n.dispose.bind(n),o=W((...a)=>{if(!r)return r=!0,Mt(this.disposables,o),s(...a)},"wrapped");return this.disposables.push(o),typeof n=="function"?o:(n.dispose=o,n)}collect(e,i){const n=Oe(()=>(Mt(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||!ge(this.ctx.get(e)))}reset(){this.isActive=!1,this.disposables=this.disposables.splice(0).filter(e=>{if(this.uid!==null&&e[Me.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),()=>Mt(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=W(c=>{const u=n[c]??(n[c]=!Qt(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:f}of this.acceptors){if(!c)l||(l=!f);else if(f)c?.forEach(m=>s.add(m));else{let m=!1;for(const g of c)m||(m=r(g));if(!m)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]}},W(Ai,"EffectScope"),Ai),Af=(Ti=class extends Yo{constructor(i,n,r,s){super(i,r);j(this,"dispose");this.runtime=n,this.dispose=Oe(i.scope.collect(`fork <${i.runtime.name}>`,()=>{this.uid=null,this.reset(),this.context.emit("internal/fork",this);const o=Mt(n.disposables,this.dispose);return Mt(n.children,this)&&!n.children.length&&i.registry.delete(n.plugin),o}),Me.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=Di(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()}},W(Ti,"ForkScope"),Ti),Go=(Ri=class extends Yo{constructor(i,n,r,s){super(i,r);j(this,"value");j(this,"runtime",this);j(this,"schema");j(this,"name");j(this,"inject",Object.create(null));j(this,"forkables",[]);j(this,"children",[]);j(this,"isReusable",!1);j(this,"isReactive",!1);j(this,"apply",W((i,n)=>{if(typeof this.plugin!="function")return this.plugin.apply(i,n);if(Nr(this.plugin)){const r=new this.plugin(i,n),s=r[Me.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 Af(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 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=Di(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()}},W(Ri,"MainScope"),Ri);function Xo(t){return t&&typeof t=="object"&&typeof t.apply=="function"}W(Xo,"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[N.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")}}W(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,W(e,"resolve")})(xe||(xe={}));var Tf=(Li=class{constructor(e,i){j(this,"_counter",0);j(this,"_internal",new Map);j(this,"context");this.ctx=e,Oe(this,N.tracker,{associate:"registry",property:"ctx"}),this.context=e;const n=new Go(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(Xo(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=Di(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 Go(this.ctx,e,i,n),this.set(e,r),r.fork(this.ctx,i,n))}},W(Li,"Registry"),Li),Rf=Tf,Me=(ve=class{static is(e){return!!e?.[ve.is]}static associate(e,i){return e}constructor(e){e=Di(this.constructor,e),this[N.store]=Object.create(null),this[N.isolate]=Object.create(null),this[N.internal]=Object.create(null),this[N.intercept]=Object.create(null);const i=new Proxy(this,Br.handler);i.root=i,i.reflect=new Br(i),i.registry=new Rf(i,e),i.lifecycle=new If(i);const n=W(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),Oe(i[r[s].key],"ctx",i))}}},"attach");return n(this[N.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,N.shadow)?.value,n=Object.assign(Object.create(ut(this,this)),e);return i?Object.assign(Object.create(n),{[N.shadow]:i}):n}isolate(e,i){const n=Object.create(this[N.isolate]);return n[e]=i??Symbol(e),this.extend({[N.isolate]:n})}intercept(e,i){const n=Object.create(this[N.intercept]);return n[e]=i,this.extend({[N.intercept]:n})}},W(ve,"Context"),j(ve,"store",N.store),j(ve,"events",N.events),j(ve,"static",N.static),j(ve,"filter",N.filter),j(ve,"expose",N.expose),j(ve,"isolate",N.isolate),j(ve,"internal",N.internal),j(ve,"intercept",N.intercept),j(ve,"origin","ctx"),j(ve,"current","ctx"),ve.is[Symbol.toPrimitive]=()=>Symbol.for("cordis.is"),ve.prototype[ve.is]=!0,ve);Me.prototype[Me.internal]=Object.create(null);var Pt=(Ge=class{constructor(...e){j(this,"ctx");j(this,"name");j(this,"config");let i,n,r,s;Me.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[N.provide]),r??(r=this.constructor[N.immediate]);let o=this;const a={associate:n,property:"ctx"};return o[N.invoke]&&(o=Fr(n,Mr(Object.getPrototypeOf(this),Function.prototype),a)),i?o.ctx=i:o[N.setup](),o.name=n,o.config=s,Oe(o,N.tracker,a),o.ctx.provide(n),o.ctx.runtime.name=n,r&&(i?o[N.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(){}[N.filter](e){return e[N.isolate][this.name]===this.ctx[N.isolate][this.name]}[N.setup](){this.ctx=new Me}[N.extend](e){let i;return this[Ge.invoke]?i=Fr(this.name,this,this[N.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}},W(Ge,"Service"),j(Ge,"setup",N.setup),j(Ge,"invoke",N.invoke),j(Ge,"extend",N.extend),j(Ge,"tracker",N.tracker),j(Ge,"provide",N.provide),j(Ge,"immediate",N.immediate),Ge),Lf=Object.defineProperty,Nf=Object.getOwnPropertyNames,Z=(t,e)=>Lf(t,"name",{value:e,configurable:!0}),Mf=(t,e)=>function(){return e||(0,t[Nf(t)[0]])((e={exports:{}}).exports,e),e.exports},Df=Mf({"src/index.ts"(t,e){var A;var i=Symbol.for("schemastery"),n=Symbol.for("ValidationError");globalThis.__schemastery_index__??(globalThis.__schemastery_index__=0);var r=(A=class extends TypeError{constructor(y,v){let x="$";for(const E of v.path||[])typeof E=="string"?x+="."+E:typeof E=="number"?x+="["+E+"]":typeof E=="symbol"&&(x+=`[Symbol(${E.toString()})]`);x.startsWith(".")&&(x=x.slice(1));super((x==="$"?"":`${x} `)+y);j(this,"name","ValidationError");this.options=v}static is(y){return!!y?.[n]}},Z(A,"ValidationError"),A);Object.defineProperty(r.prototype,n,{value:!0});var s=Z(function(b){const d=Z(function(y,v={}){return s.resolve(y,d,v)[0]},"schema");if(b.refs){const y=$t(b.refs,x=>new s(x)),v=Z(x=>y[x],"getRef");for(const x in y){const E=y[x];E.sKey=v(E.sKey),E.inner=v(E.inner),E.list=E.list&&E.list.map(v),E.dict=E.dict&&$t(E.dict,v)}return y[b.uid]}if(Object.assign(d,b),typeof d.callback=="string")try{d.callback=new Function("return "+d.callback)()}catch{}return Object.defineProperty(d,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(d,s.prototype),d.meta||(d.meta={}),d.toString=d.toString.bind(d),d},"Schema");s.prototype=Object.create(Function.prototype),s.prototype[i]=!0,s.ValidationError=r;var o;s.prototype.toJSON=Z(function(){var y;if(o)return o[y=this.uid]??(o[y]=JSON.parse(JSON.stringify({...this}))),this.uid;o={[this.uid]:{...this}},o[this.uid]=JSON.parse(JSON.stringify({...this}));const d={uid:this.uid,refs:o};return o=void 0,d},"toJSON"),s.prototype.set=Z(function(d,y){return this.dict[d]=y,this},"set"),s.prototype.push=Z(function(d){return this.list.push(d),this},"push");function a(b,d){const y=typeof b=="string"?{"":b}:{...b};for(const v in d){const x=d[v];x?.$description||x?.$desc?y[v]=x.$description||x.$desc:typeof x=="string"&&(y[v]=x)}return y}Z(a,"mergeDesc");function l(b){return b?.$value??b?.$inner}Z(l,"getInner");function c(b){return Bo(b??{},d=>!d.startsWith("$"))}Z(c,"extractKeys"),s.prototype.i18n=Z(function(d){const y=s(this),v=a(y.meta.description,d);return Object.keys(v).length&&(y.meta.description=v),y.dict&&(y.dict=$t(y.dict,(x,E)=>x.i18n($t(d,L=>l(L)?.[E]??L?.[E])))),y.list&&(y.list=y.list.map((x,E)=>x.i18n($t(d,(L={})=>Array.isArray(l(L))?l(L)[E]:Array.isArray(L)?L[E]:c(L))))),y.inner&&(y.inner=y.inner.i18n($t(d,x=>l(x)?l(x):c(x)))),y.sKey&&(y.sKey=y.sKey.i18n($t(d,x=>x?.$key))),y},"i18n"),s.prototype.extra=Z(function(d,y){const v=s(this);return v.meta={...v.meta,[d]:y},v},"extra");for(const b of["required","disabled","collapse","hidden","loose"])Object.assign(s.prototype,{[b](d=!0){const y=s(this);return y.meta={...y.meta,[b]:d},y}});s.prototype.deprecated=Z(function(){var y;const d=s(this);return(y=d.meta).badges||(y.badges=[]),d.meta.badges.push({text:"deprecated",type:"danger"}),d},"deprecated"),s.prototype.experimental=Z(function(){var y;const d=s(this);return(y=d.meta).badges||(y.badges=[]),d.meta.badges.push({text:"experimental",type:"warning"}),d},"experimental"),s.prototype.pattern=Z(function(d){const y=s(this),v=qo(d,["source","flags"]);return y.meta={...y.meta,pattern:v},y},"pattern"),s.prototype.simplify=Z(function(d){if(Qt(d,this.meta.default,this.type==="dict"))return null;if(ge(d))return d;if(this.type==="object"||this.type==="dict"){const y={};for(const v in d){const E=(this.type==="object"?this.dict[v]:this.inner)?.simplify(d[v]);(this.type==="dict"||!ge(E))&&(y[v]=E)}return Qt(y,this.meta.default,this.type==="dict")?null:y}else if(this.type==="array"||this.type==="tuple"){const y=[];return d.forEach((v,x)=>{const E=this.type==="array"?this.inner:this.list[x],L=E?E.simplify(v):v;y.push(L)}),y}else if(this.type==="intersect"){const y={};for(const v of this.list)Object.assign(y,v.simplify(d));return y}else if(this.type==="union")for(const y of this.list)try{return s.resolve(d,y,{}),y.simplify(d)}catch{}return d},"simplify"),s.prototype.toString=Z(function(d){return D[this.type]?.(this,d)??`Schema<${this.type}>`},"toString"),s.prototype.role=Z(function(b,d){const y=s(this);return y.meta={...y.meta,role:b,extra:d},y},"role");for(const b of["default","link","comment","description","max","min","step"])Object.assign(s.prototype,{[b](d){const y=s(this);return y.meta={...y.meta,[b]:d},y}});var u={};s.extend=Z(function(d,y){u[d]=y},"extend"),s.resolve=Z(function(d,y,v={},x=!1){if(!y)return[d];if(v.ignore?.(d,y))return[d];if(ge(d)&&y.type!=="lazy"){if(y.meta.required)throw new r("missing required value",v);let L=y,B=y.meta.default;for(;L?.type==="intersect"&&ge(B);)L=L.list[0],B=L?.meta.default;if(ge(B))return[d];d=En(B)}const E=u[y.type];if(!E)throw new r(`unsupported type "${y.type}"`,v);try{return E(d,y,v,x)}catch(L){if(!y.meta.loose)throw L;return[y.meta.default]}},"resolve"),s.from=Z(function(d){if(ge(d))return s.any();if(["string","number","boolean"].includes(typeof d))return s.const(d).required();if(d[i])return d;if(typeof d=="function")switch(d){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(d).required()}else throw new TypeError(`cannot infer schema from ${d}`)},"from"),s.lazy=Z(function(d){const y=Z(()=>(v.inner[i]||(v.inner=v.builder(),v.inner.meta={...v.meta,...v.inner.meta}),v.inner.toJSON()),"toJSON"),v=new s({type:"lazy",builder:d,inner:{toJSON:y}});return v},"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"),(d,y)=>{const v=new Date(d);if(isNaN(+v))throw new r(`invalid date "${d}"`,y);return v},!0)])},"date"),s.regExp=Z(function(d=""){return s.union([s.is(RegExp),s.transform(s.string().role("regexp",{flag:d}),(y,v)=>{try{return new RegExp(y,d)}catch(x){throw new r(x.message,v)}},!0)])},"regExp"),s.arrayBuffer=Z(function(d){return s.union([s.is(ArrayBuffer),s.is(SharedArrayBuffer),s.transform(s.any(),(y,v)=>{if(ct.isSource(y))return ct.fromSource(y);throw new r(`expected ArrayBufferSource but got ${y}`,v)},!0),...d?[s.transform(s.string(),(y,v)=>{try{return d==="base64"?ct.fromBase64(y):ct.fromHex(y)}catch(x){throw new r(x.message,v)}},!0)]:[]])},"arrayBuffer"),s.extend("lazy",(b,d,y,v)=>(d.inner[i]||(d.inner=d.builder(),d.inner.meta={...d.meta,...d.inner.meta}),s.resolve(b,d.inner,y,v))),s.extend("any",b=>[b]),s.extend("never",(b,d,y)=>{throw new r(`expected nullable but got ${b}`,y)}),s.extend("const",(b,{value:d},y)=>{if(Qt(b,d))return[d];throw new r(`expected ${d} but got ${b}`,y)});function f(b,d,y,v,x=!1){const{max:E=1/0,min:L=-1/0}=d;if(b>E)throw new r(`expected ${y} <= ${E} but got ${b}`,v);if(b<L&&!x)throw new r(`expected ${y} >= ${L} but got ${b}`,v)}Z(f,"checkWithinRange"),s.extend("string",(b,{meta:d},y)=>{if(typeof b!="string")throw new r(`expected string but got ${b}`,y);if(d.pattern){const v=new RegExp(d.pattern.source,d.pattern.flags);if(!v.test(b))throw new r(`expect string to match regexp ${v}`,y)}return f(b.length,d,"string length",y),[b]});function h(b,d){const y=b.toString();if(y.includes("e"))return b*Math.pow(10,d);const v=y.indexOf(".");if(v===-1)return b*Math.pow(10,d);const x=y.slice(v+1),E=y.slice(0,v);return x.length<=d?+(E+x.padEnd(d,"0")):+(E+x.slice(0,d)+"."+x.slice(d))}Z(h,"decimalShift");function m(b,d,y){if(y=Math.abs(y),!/^\d+\.\d+$/.test(y.toString()))return(b-d)%y===0;const v=y.toString().indexOf("."),x=y.toString().slice(v+1).length;return Math.abs(h(b,x)-h(d,x))%h(y,x)===0}Z(m,"isMultipleOf"),s.extend("number",(b,{meta:d},y)=>{if(typeof b!="number")throw new r(`expected number but got ${b}`,y);f(b,d,"number",y);const{step:v}=d;if(v&&!m(b,d.min??0,v))throw new r(`expected number multiple of ${v} but got ${b}`,y);return[b]}),s.extend("boolean",(b,d,y)=>{if(typeof b=="boolean")return[b];throw new r(`expected boolean but got ${b}`,y)}),s.extend("bitset",(b,{bits:d,meta:y},v)=>{let x=0,E=[];if(typeof b=="number"){x=b;for(const L in d)b&d[L]&&E.push(L)}else if(Array.isArray(b)){E=b;for(const L of E){if(typeof L!="string")throw new r(`expected string but got ${L}`,v);L in d&&(x|=d[L])}}else throw new r(`expected number or array but got ${b}`,v);return x===y.default?[x]:[x,E]}),s.extend("function",(b,d,y)=>{if(typeof b=="function")return[b];throw new r(`expected function but got ${b}`,y)}),s.extend("is",(b,{constructor:d},y)=>{if(typeof d=="function"){if(b instanceof d)return[b];throw new r(`expected ${d.name} but got ${b}`,y)}else{if(ge(b))throw new r(`expected ${d} but got ${b}`,y);let v=Object.getPrototypeOf(b);for(;v;){if(v.constructor?.name===d)return[b];v=Object.getPrototypeOf(v)}throw new r(`expected ${d} but got ${b}`,y)}});function g(b,d,y,v){try{const[x,E]=s.resolve(b[d],y,{...v,path:[...v.path||[],d]});return E!==void 0&&(b[d]=E),x}catch(x){if(!v?.autofix)throw x;return delete b[d],y.meta.default}}Z(g,"property"),s.extend("array",(b,{inner:d,meta:y},v)=>{if(!Array.isArray(b))throw new r(`expected array but got ${b}`,v);return f(b.length,y,"array length",v,!ge(d.meta.default)),[b.map((x,E)=>g(b,E,d,v))]}),s.extend("dict",(b,{inner:d,sKey:y},v,x)=>{if(!kn(b))throw new r(`expected object but got ${b}`,v);const E={};for(const L in b){let B;try{B=s.resolve(L,y,v)[0]}catch(Ce){if(x)continue;throw Ce}E[B]=g(b,L,d,v),b[B]=b[L],L!==B&&delete b[L]}return[E]}),s.extend("tuple",(b,{list:d},y,v)=>{if(!Array.isArray(b))throw new r(`expected array but got ${b}`,y);const x=d.map((E,L)=>g(b,L,E,y));return v?[x]:(x.push(...b.slice(d.length)),[x])});function k(b,d){for(const y in d)y in b||(b[y]=d[y])}Z(k,"merge"),s.extend("object",(b,{dict:d},y,v)=>{if(!kn(b))throw new r(`expected object but got ${b}`,y);const x={};for(const E in d){const L=g(b,E,d[E],y);(!ge(L)||E in b)&&(x[E]=L)}return v||k(x,b),[x]}),s.extend("union",(b,{list:d,toString:y},v,x)=>{for(const E of d)try{return s.resolve(b,E,v,x)}catch{}throw new r(`expected ${y()} but got ${JSON.stringify(b)}`,v)}),s.extend("intersect",(b,{list:d,toString:y},v,x)=>{if(!d.length)return[b];let E;for(const L of d){const B=s.resolve(b,L,v,!0)[0];if(!ge(B))if(ge(E))E=B;else{if(typeof E!=typeof B)throw new r(`expected ${y()} but got ${JSON.stringify(b)}`,v);if(typeof B=="object")k(E??(E={}),B);else if(E!==B)throw new r(`expected ${y()} but got ${JSON.stringify(b)}`,v)}}return!x&&kn(b)&&k(E,b),[E]}),s.extend("transform",(b,{inner:d,callback:y,preserve:v},x)=>{const[E,L=b]=s.resolve(b,d,x,!0);return v?[y(E)]:[y(E),y(L)]});var D={};function T(b,d,y){D[b]=y,Object.assign(s,{[b](...v){const x=new s({type:b});return d.forEach((E,L)=>{switch(E){case"sKey":x.sKey=v[L]??s.string();break;case"inner":x.inner=s.from(v[L]);break;case"list":x.list=v[L].map(s.from);break;case"dict":x.dict=$t(v[L],s.from);break;case"bits":{x.bits={};for(const B in v[L])typeof v[L][B]=="number"&&(x.bits[B]=v[L][B]);break}case"callback":{const B=x.callback=v[L];B.toJSON||(B.toJSON=()=>B.toString());break}case"constructor":{const B=x.constructor=v[L];typeof B=="function"&&(B.toJSON||(B.toJSON=()=>B.name));break}default:x[E]=v[L]}}),b==="object"||b==="dict"?x.meta.default={}:b==="array"||b==="tuple"?x.meta.default=[]:b==="bitset"&&(x.meta.default=0),x}})}Z(T,"defineMethod"),T("is",["constructor"],({constructor:b})=>typeof b=="function"?b.name:b),T("any",[],()=>"any"),T("never",[],()=>"never"),T("const",["value"],({value:b})=>typeof b=="string"?JSON.stringify(b):b),T("string",[],()=>"string"),T("number",[],()=>"number"),T("boolean",[],()=>"boolean"),T("bitset",["bits"],()=>"bitset"),T("function",[],()=>"function"),T("array",["inner"],({inner:b})=>`${b.toString(!0)}[]`),T("dict",["inner","sKey"],({inner:b,sKey:d})=>`{ [key: ${d.toString()}]: ${b.toString()} }`),T("tuple",["list"],({list:b})=>`[${b.map(d=>d.toString()).join(", ")}]`),T("object",["dict"],({dict:b})=>Object.keys(b).length===0?"{}":`{ ${Object.entries(b).map(([d,y])=>`${d}${y.meta.required?"":"?"}: ${y.toString()}`).join(", ")} }`),T("union",["list"],({list:b},d)=>{const y=b.map(({toString:v})=>v()).join(" | ");return d?`(${y})`:y}),T("intersect",["list"],({list:b})=>`${b.map(d=>d.toString(!0)).join(" & ")}`),T("transform",["inner","callback","preserve"],({inner:b},d)=>b.toString(d)),e.exports=s}});const Y=Df();/**
4
- * @inpageedit/logger
5
- *
6
- * Flexible, Extensible Console Logger with Colored Labels and Hierarchical Loggers
7
- *
8
- * @author dragon-fish <dragon-fish@qq.com>
9
- * @license MIT
10
- */var zr=(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))(zr||{});const Wr=globalThis||window,Kr=Symbol.for("__IPE_LOGGER_COLOR_MAP__");Wr[Kr]||(Wr[Kr]=new Map);const Vr=Wr[Kr];function Cn(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i),e=(e>>>0)*16777619;return e>>>0}const Jo=[[350,360],[0,15],[15,30],[200,230],[230,250],[250,280],[280,310],[310,330],[140,160],[160,180]];function jf(t,e){const i=Jo.length,n=Cn(t)%i,[r,s]=Jo[n],o=s-r,a=Cn(t+":"+e),l=r+a%(o||1),c=Cn(t+":s"),u=Cn(t+":l");let f,h;if(e==="name")f=62+c%18,h=30+u%12;else{const m=l>=0&&l<50||l>330&&l<360,g=l>=200&&l<=300;f=55+c%20,g?h=55+u%8:m?h=48+u%6:h=50+u%8,f<60&&(f+=5)}return`hsl(${l}, ${f}%, ${h}%)`}function On(t,e){if(e)return Vr.set(t,e),e;const i=Vr.get(t);if(i)return i;const n=t.startsWith("name:")?"name":"group",r=jf(t,n);return Vr.set(t,r),r}/**
11
- * @inpageedit/logger
12
- * Flexible, Extensible Console Logger with Colored Labels and Hierarchical Loggers
13
- *
14
- * @author dragon-fish <dragon-fish@qq.com>
15
- * @license MIT
16
- *
17
- * @example
18
- * ```ts
19
- * const logger = new Logger({ name: 'MyApp', level: LoggerLevel.debug })
20
- * // normal usage
21
- * logger.info('Application started')
22
- * // create sub-logger group
23
- * const apiLogger = logger.group('API', { color: '#f59e0b' })
24
- * apiLogger.warn('Deprecated API endpoint used')
25
- * // define custom level
26
- * logger.defineLevel('success', { level: LoggerLevel.info, label: '✅', method: 'info' })
27
- * logger.success('User created successfully')
28
- * ```
29
- */let Zo=class Ju{constructor(e={}){this._custom=i=>{if(!this._enabled(i.level))return ea;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&&On(`name:${this._name}`,this._nameColor),this._installBuiltinLevels();for(const i of Object.keys(this._dynamicLevels))this._installLevelGetter(i,this._dynamicLevels[i]);return Ff(this)}get level(){return this._levelRef.value}set level(e){this._levelRef.value=e}group(e,i){return e&&On(`group:${e}`,i?.color),new Ju({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=Uf[e];if(!this._enabled(i.level))return ea;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=On(`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;`,ta)}if(e&&(n+=` ${e}`),this._groupPath.length){const r=this._groupPath.join("/"),s=On(`group:${r}`);n+=` %c${r}%c`,i.push(`color:${s}; text-decoration: underline;`,ta)}return[n,i]}};const ea=()=>{},ta="color:inherit; background:transparent; text-decoration:none;",Uf={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 Ff(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 ia(t){return new Zo(t)}var Ke=(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))(Ke||{});let De=class Zu extends Error{constructor(i,n,r,s){super(n,s);j(this,"name","FexiosError");this.code=i,this.context=r}static is(i){return i?.constructor===Zu}},Bf=class ef extends De{constructor(i,n,r){super(n.statusText,i,void 0,r);j(this,"name","FexiosResponseError");this.response=n}static is(i){return i?.constructor===ef}};function qf(t,e=2048){if(!(t instanceof Uint8Array))throw new TypeError("Input must be a Uint8Array");if(t.length===0)return!0;const i=Math.min(Math.max(t.length,256),e),n=t.slice(0,i);if(Hf(n))return!1;const r=zf(n);if(r.nullByteRatio>.05||r.highByteRatio>.95)return!1;const s=["utf-8","utf-16le","utf-16be","iso-8859-1"];let o=-1,a=!1;for(const l of s)try{const c=new TextDecoder(l,{fatal:!0}).decode(n),u=Wf(c);u>o&&(o=u,a=u>.7)}catch{continue}return a}function Hf(t){if(t.length<4)return!1;const e=[[137,80,78,71],[255,216,255],[71,73,70],[37,80,68,70],[80,75,3,4],[80,75,5,6],[80,75,7,8],[127,69,76,70],[77,90],[202,254,186,190],[0,0,1,0],[82,73,70,70]];for(const i of e)if(t.length>=i.length){let n=!0;for(let r=0;r<i.length;r++)if(t[r]!==i[r]){n=!1;break}if(n)return!0}return!1}function zf(t){let e=0,i=0,n=0;for(const r of t)r===0&&e++,r>127&&i++,(r<32&&r!==9&&r!==10&&r!==13||r===127)&&n++;return{nullByteRatio:e/t.length,highByteRatio:i/t.length,controlCharRatio:n/t.length}}function Wf(t){if(t.length===0)return 1;let e=1,i=0;for(let r=0;r<t.length;r++){const s=t[r].charCodeAt(0);s>=32&&s<=126||s===9||s===10||s===13||s===32?i++:s>127&&s<65534?!Kf(s)&&!Vf(s)&&i++:e-=.1}const n=i/t.length;return e*=n,Qf(t)&&(e*=1.1),Math.max(0,Math.min(1,e))}function Kf(t){return t>=0&&t<=31||t>=127&&t<=159}function Vf(t){return t>=57344&&t<=63743||t>=983040&&t<=1048573||t>=1048576&&t<=1114109}function Qf(t){return[/\b\w+\b/,/[.!?]+\s/,/\s+/,/[a-zA-Z]{3,}/,/[\u4e00-\u9fa5]+/,/\d+/].some(e=>e.test(t))}function rt(t){if(typeof t!="object"||t===null||Object.prototype.toString.call(t)!=="[object Object]")return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}const Ui=(t,...e)=>{const i=r=>{if(Array.isArray(r))return r.slice();if(rt(r)){const s={};for(const o of Reflect.ownKeys(r))s[o]=i(r[o]);return s}return r},n=i(t);for(const r of e)if(r!=null)for(const s of Reflect.ownKeys(r)){const o=r[s];if(typeof o>"u")continue;const a=n[s];rt(a)&&rt(o)?n[s]=Ui(a,o):n[s]=i(o)}return n};let Fi=class{constructor(e,i,n){j(this,"ok");j(this,"status");j(this,"statusText");j(this,"headers");this.rawResponse=e,this.data=i,this.ok=e.ok,this.status=e.status,this.statusText=e.statusText,this.headers=e.headers,Object.entries(n||{}).forEach(([r,s])=>{this[r]=s})}};async function na(t,e,i){if(t.bodyUsed)throw new De(Ke.BODY_USED,"Response body has already been used or locked");const n=t.headers.get("content-type")||"",r=Number(t.headers.get("content-length"))||0,s=(a,l)=>l==="json"||a.startsWith("application/json"),o=(a,l,c)=>c==="blob"||a.startsWith("image/")&&!a.startsWith("image/svg")||a.startsWith("video/")||a.startsWith("audio/")||!qf(l);if((t.status===101||t.status===426||t.headers.get("upgrade"))&&typeof globalThis.WebSocket<"u"){const a=new WebSocket(t.url);return await new Promise((l,c)=>{a.onopen=l,a.onerror=c}),new Fi(t,a,{ok:!0,status:101,statusText:"Switching Protocols"})}else if(n.startsWith("text/event-stream")&&!["text","json"].includes(e||"")&&typeof globalThis.EventSource<"u"){const a=new EventSource(t.url);return await new Promise((l,c)=>{a.onopen=l,a.onerror=c}),new Fi(t,a)}else{if(e==="stream")return new Fi(t,t.body);{const a=t.clone().body?.getReader();if(!a)throw new De(Ke.NO_BODY_READER,"Failed to get ReadableStream from response body");let l=new Uint8Array;for(;;){const{done:u,value:f}=await a.read();if(u)break;if(f&&(l=new Uint8Array([...l,...f]),i&&r>0)){const h=Math.min(l.length/r,1);i(h,l)}}const c=new Fi(t,void 0);if(e==="arrayBuffer")return c.data=l.buffer,c;if(s(n,e))try{const u=new TextDecoder().decode(l);c.data=JSON.parse(u)}catch{}if(typeof c.data!="string"&&o(n,l,e)?c.data=new Blob([l],{type:t.headers.get("content-type")||void 0}):c.data=new TextDecoder().decode(l),typeof c.data=="string"&&e!=="text"){const u=c.data.trim(),f=u[0],h=u[u.length-1];if(f==="{"&&h==="}"||f==="["&&h==="]")try{c.data=JSON.parse(c.data)}catch{}}if(typeof c.data>"u"&&(c.data=l.length>0?l:void 0),c.ok)return c;throw new Bf(`Request failed with status code ${t.status}`,c)}}}var In;(t=>{t.makeSearchParams=r=>{if(!r)return new URLSearchParams;if(r instanceof URLSearchParams)return r;if(typeof r!="object"||r?.constructor!==Object)throw new TypeError("only plain object is supported");const s=new URLSearchParams,o=(c,u)=>{u!=null&&s.append(c,u)},a=(c,u)=>{u!=null&&s.set(c,u)},l=(c,u)=>{if(u!=null){if(Array.isArray(u)){for(const f of u)o(c,f?.toString());return}if(typeof u=="object"&&u.constructor===Object){for(const[f,h]of Object.entries(u)){if(h==null)continue;const m=f.endsWith("[]"),g=m?f.slice(0,-2):f,k=`${c}[${g}]`;if(m){const D=`${k}[]`;if(Array.isArray(h))for(const T of h)o(D,T?.toString());else typeof h=="object"&&h!==null&&h.constructor===Object?l(`${k}[]`,h):o(D,h?.toString())}else if(Array.isArray(h))for(const D of h)o(k,D?.toString());else typeof h=="object"&&h!==null&&h.constructor===Object?l(k,h):a(k,h?.toString())}return}a(c,u?.toString())}};for(const[c,u]of Object.entries(r))l(c,u);return s},t.makeQueryString=r=>(0,t.makeSearchParams)(r).toString(),t.makeURL=(r,s,o,a)=>{const l=typeof window<"u"&&window.location?.origin||"http://localhost",c=typeof r=="string"?new URL(r,a??l):new URL(r),u=(0,t.toQueryRecord)(c.searchParams),f=(0,t.mergeQueries)(u,s||{}),h=(0,t.makeSearchParams)(f);return c.search=h.toString(),c.hash=o||"",c},t.toQueryRecord=r=>{typeof r=="string"&&(r=(0,t.fromString)(r));const s={},o=l=>{if(!l.includes("["))return{path:[l],forceArray:!1};const c=[l.slice(0,l.indexOf("["))],u=/\[([^\]]*)\]/g;let f,h=!1,m=!1;for(;f=u.exec(l);)f[1]===""?(h=!0,m=!0):(c.push(f[1]),m=!1);return h&&m&&(c[c.length-1]=c[c.length-1]+"[]"),{path:c,forceArray:h}},a=(l,c,u,f)=>{let h=l;for(let m=0;m<c.length;m++){const g=c[m];m===c.length-1?f?h[g]===void 0?h[g]=[u]:Array.isArray(h[g])?h[g].push(u):h[g]=[h[g],u]:h[g]===void 0?h[g]=u:Array.isArray(h[g])?h[g].push(u):h[g]=[h[g],u]:((h[g]===void 0||typeof h[g]!="object"||Array.isArray(h[g]))&&(h[g]={}),h=h[g])}};for(const[l,c]of r.entries()){const{path:u,forceArray:f}=o(String(l));a(s,u,c?.toString(),f)}return s},t.fromString=r=>{const s=r.trim();if(!s)return new URLSearchParams;if(s.startsWith("?"))return new URLSearchParams(s.slice(1));const o=s.indexOf("?");if(o>=0){const a=s.indexOf("#",o+1),l=s.slice(o+1,a>=0?a:void 0);return new URLSearchParams(l)}return new URLSearchParams(s)},t.mergeQueries=(r,...s)=>{const o=e(i(r));for(const a of s)a!=null&&n(o,i(a));return o};function e(r){if(Array.isArray(r))return r.map(e);if(rt(r)){const s={};for(const[o,a]of Object.entries(r))s[o]=e(a);return s}if(r instanceof Map){const s={};for(const[o,a]of r.entries())s[o]=e(a);return s}return r}function i(r){if(!r)return{};if(r instanceof URLSearchParams||r instanceof FormData||r instanceof Map)return(0,t.toQueryRecord)(r);if(typeof r=="string")return(0,t.toQueryRecord)((0,t.fromString)(r));if(rt(r))return r;throw new TypeError(`unsupported type transformation, got: ${Object.prototype.toString.call(r)}`)}function n(r,s){for(const[o,a]of Object.entries(s)){if(a===void 0)continue;if(a===null){delete r[o];continue}const l=r[o];rt(l)&&rt(a)?n(l,a):r[o]=e(a)}}})(In||(In={}));const ra=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};ra.prototype=Object.create(Function.prototype);var Bi;(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(rt(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,...i)=>{const n=e instanceof Headers?new Headers(e):(0,t.makeHeaders)(e),r=s=>{for(const[o,a]of Object.entries(s))if(a!==void 0){if(a===null){n.delete(o);continue}if(Array.isArray(a)){n.delete(o);for(const l of a)l!=null&&n.append(o,String(l))}else n.set(o,String(a))}};for(const s of i){if(s==null)continue;if(s instanceof Headers){s.forEach((a,l)=>{n.set(l,a)});continue}if(rt(s)){r(s);continue}const o=(0,t.toHeaderRecord)(s);for(const[a,l]of Object.entries(o)){n.delete(a);for(const c of l)n.append(a,c)}}return n}})(Bi||(Bi={}));let Qr=(ue=class extends ra{constructor(i={}){super("request");j(this,"baseConfigs");j(this,"hooks",[]);j(this,"mergeQueries",In.mergeQueries);j(this,"mergeHeaders",Bi.mergeHeaders);j(this,"interceptors",{request:this.createInterceptor("beforeRequest"),response:this.createInterceptor("afterResponse")});j(this,"create",ue.create);j(this,"_plugins",new Map);j(this,"checkIsPlainObject",rt);j(this,"mergeQuery",this.mergeQueries);this.baseConfigs=Ui(ue.DEFAULT_CONFIGS,i),ue.ALL_METHODS.forEach(n=>this.createMethodShortcut(n.toLowerCase()))}async request(i,n){let r=n=n||{};if(typeof i=="string"||i instanceof URL?r.url=i.toString():typeof i=="object"&&(r=Ui(i,r)),r=await this.emit("beforeInit",r,{shouldAdjustRequestParams:!0,shouldHandleShortCircuitResponse:!0}),r[ue.FINAL_SYMBOL])return r;if(ue.METHODS_WITHOUT_BODY.includes(r.method?.toLocaleLowerCase())&&r.body)throw new De(Ke.BODY_NOT_ALLOWED,`Request method "${r.method}" does not allow body`);if(r=await this.emit("beforeRequest",r,{shouldAdjustRequestParams:!0,shouldHandleShortCircuitResponse:!0,preAdjust:!0,requestOptionsOverridesURLSearchParams:!0,preRequestOptionsOverridesURLSearchParams:!0,postRequestOptionsOverridesURLSearchParams:!0}),r[ue.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),!Bi.makeHeaders(n.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,{shouldAdjustRequestParams:!0,shouldHandleShortCircuitResponse:!0,preAdjust:!0,postRequestOptionsOverridesURLSearchParams:!0}),r[ue.FINAL_SYMBOL])return r;const a=r.abortController||globalThis.AbortController?new AbortController:void 0,l=r.baseURL||this.baseConfigs.baseURL||globalThis.location?.href||"http://localhost",c=new URL(r.url.toString(),l),u=In.makeURL(c,r.query,c.hash).toString(),f=new Request(u,{method:r.method||"GET",credentials:r.credentials,cache:r.cache,mode:r.mode,headers:Bi.mergeHeaders(this.baseConfigs.headers,r.headers||{},o),body:r.body,signal:a?.signal});if(r.rawRequest=f,r=await this.emit("beforeActualFetch",r,{shouldHandleShortCircuitResponse:!0}),r[ue.FINAL_SYMBOL])return r;const h=r.timeout||this.baseConfigs.timeout||60*1e3;if(r.url.startsWith("ws"))try{const g=new WebSocket(r.url);return await new Promise((k,D)=>{const T=setTimeout(()=>{D(new De(Ke.TIMEOUT,`WebSocket connection timed out after ${h}ms`,r))},h);g.onopen=()=>{clearTimeout(T),k()},g.onerror=A=>{clearTimeout(T),D(new De(Ke.NETWORK_ERROR,"WebSocket connection failed",r))},g.onclose=A=>{A.code!==1e3&&(clearTimeout(T),D(new De(Ke.NETWORK_ERROR,`WebSocket closed with code ${A.code}`,r)))}}),r.rawResponse=new Response,r.response=new Fi(r.rawResponse,g,{ok:!0,status:101,statusText:"Switching Protocols"}),r.data=g,r.headers=new Headers,this.emit("afterResponse",r)}catch(g){throw g instanceof De?g:new De(Ke.NETWORK_ERROR,`WebSocket creation failed: ${g}`,r)}let m;try{a&&(m=setTimeout(()=>{a.abort()},h));const g=await(n.fetch||this.baseConfigs.fetch||globalThis.fetch)(r.rawRequest).catch(k=>{throw m&&clearTimeout(m),a?.signal.aborted?new De(Ke.TIMEOUT,`Request timed out after ${h}ms`,r):new De(Ke.NETWORK_ERROR,k.message,r)});return m&&clearTimeout(m),r.rawResponse=g,r.response=await na(g,r.responseType,(k,D)=>{n?.onProgress?.(k,D)}),r.data=r.response.data,r.headers=r.response.headers,this.emit("afterResponse",r)}catch(g){throw m&&clearTimeout(m),g}}normalizeContext(i,n={}){const r=i,s=r.baseURL||this.baseConfigs.baseURL||globalThis.location?.href||"http://localhost",o=new URL(s,globalThis.location?.href||"http://localhost"),a=new URL(r.url.toString(),o),l=!!r[ue.NORMALIZED_SYMBOL];r.baseURL=o?o.origin:a.origin;let c;l?c=n.requestOptionsOverridesURLSearchParams?this.mergeQueries({},a.search,r.query):this.mergeQueries({},r.query,a.search):(c=n.requestOptionsOverridesURLSearchParams?this.mergeQueries(o?.search||"",this.baseConfigs.query,a.search,r.query):this.mergeQueries(o?.search||"",this.baseConfigs.query,r.query,a.search),r[ue.NORMALIZED_SYMBOL]=!0),r.query=c;const u=new URL(a);return u.search="",r.url=u.toString(),r}async emit(i,n,r={}){const s=this.hooks.filter(o=>o.event===i);if(r?.shouldAdjustRequestParams&&r?.preAdjust)try{n=this.normalizeContext(n,{requestOptionsOverridesURLSearchParams:r.preRequestOptionsOverridesURLSearchParams})}catch{}try{let o=0;for(const a of s){const l=`${i}#${a.action.name||`anonymous#${o}`}`,c=Symbol("FEXIOS_HOOK_CONTEXT");n[c]=c;const u=n.url;let f="";try{const m=this.mergeQueries({},n.query||{});f=JSON.stringify(m)}catch{}let h=await a.action.call(this,n);if(h===void 0&&(h=n),h===!1)throw new De(Ke.ABORTED_BY_HOOK,`Request aborted by hook "${l}"`,n);if(h instanceof Response){const m=h,g={...n,rawResponse:m},k=await na(m,n.responseType,(D,T)=>{n.onProgress?.(D,T)});if(g.response=k,g.data=k.data,g.headers=k.headers,i!=="afterResponse"){const D=await this.emit("afterResponse",g);return D[ue.FINAL_SYMBOL]=!0,D}else return g[ue.FINAL_SYMBOL]=!0,g}else if(typeof h=="object"&&h[c]===c)n=h;else{const m=globalThis["".concat("console")];try{throw new De(Ke.HOOK_CONTEXT_CHANGED,`Hook "${l}" should return the original FexiosContext or return false to abort the request, but got "${h}".`)}catch(g){m.warn(g.stack||g)}}if(r?.shouldAdjustRequestParams)try{const m=n.baseURL||this.baseConfigs.baseURL||globalThis.location?.href||"http://localhost",g=new URL(n.url.toString(),m);let k={};if(f)try{k=JSON.parse(f)}catch{}const D=n.query||{},T=this.mergeQueries(k,g.search,D);n.query=T;const A=new URL(g);A.search="",n.url=A.toString()}catch{}delete n[c],o++}}catch(o){return Promise.reject(o)}return n}on(i,n,r=!1){if(typeof n!="function")throw new De(Ke.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)=>(ue.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 ue(Ui(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 ue(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 ue)return n}return this}},j(ue,"FINAL_SYMBOL",Symbol("FEXIOS_FINAL_CONTEXT")),j(ue,"NORMALIZED_SYMBOL",Symbol("FEXIOS_NORMALIZED_QUERY")),j(ue,"DEFAULT_CONFIGS",{baseURL:"",timeout:60*1e3,credentials:"same-origin",headers:{},query:{},responseType:void 0,fetch:globalThis.fetch}),j(ue,"ALL_METHODS",["get","post","put","patch","delete","head","options","trace"]),j(ue,"METHODS_WITHOUT_BODY",["get","head","options","trace"]),ue);/**
30
- * Fexios
31
- * @desc Fetch based HTTP client with similar API to axios for browser and Node.js
32
- *
33
- * @license MIT
34
- * @author dragon-fish <dragon-fish@qq.com>
35
- */const Yf=Qr.create,sa=Yf();/* v8 ignore else -- @preserve */typeof globalThis<"u"?globalThis.fexios=sa:typeof window<"u"&&(window.fexios=sa);var An;(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(rt(n))return Object.entries(n).forEach(([o,a])=>{const l=e(a);l!=null&&s.append(o,l)}),s}t.normalizeBody=i})(An||(An={}));var qi=(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))(qi||{});class je 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)}}let li=class tf extends Error{constructor(e,i){super(),this.errors=e,this.cause=i,this.name="MediaWikiApiError",this.errors=tf.normalizeErrors(e),this.message=e.map(n=>n.text).filter(Boolean).join(`
36
- `),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=li.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(li.is(s))return s.isBadTokenError();{const o=n(s);return new li(o).isBadTokenError()}}t.isBadTokenError=r})(je||(je={}));const oa=Symbol.for("__FEXIOS_SAIKOU__");/**
37
- * FexiosSaikou
38
- *
39
- * A pre-configured Fexios instance with MediaWiki-friendly defaults:
40
- * - MediaWiki-specific request/response params normalization
41
- * - built-in token management
42
- * - error handling
43
- *
44
- * @author dragon-fish <dragon-fish@qq.com>
45
- * @license MIT
46
- *
47
- * @param {string|URL} payload create a new FexiosSaikou instance with the given baseURL
48
- * @param {Fexios} payload or make the given Fexios instance a FexiosSaikou instance
49
- */function aa(t){const e=t instanceof Qr?t:new Qr({baseURL:t instanceof URL?t.toString():String(t),responseType:"json"});return e[oa]||(Reflect.defineProperty(e,oa,{get:()=>!0,enumerable:!1,configurable:!1}),e._tokens=new Map,e.on("afterResponse",i=>{const{data:n,rawRequest:r}=i,s=r?.headers.get("x-mw-token-name");s&&je.isBadTokenError(n)&&e._tokens.delete(s);const o=n?.query?.tokens;o&&typeof o=="object"&&Object.entries(o).forEach(([l,c])=>{typeof c=="string"&&e._tokens.set(l.replace(/token$/i,"").toLowerCase(),c)});const a=n?.login?.token;return typeof a=="string"&&e._tokens.set("login",a),i}),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=An.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=An.normalizeBody(i.query)||{},i)),e.on("beforeRequest",i=>{const n=new URL(i.url),r=n.searchParams;if(globalThis.location&&(!r.has("origin")&&location.origin!==n.origin?(r.set("origin",location.origin),e.baseConfigs.credentials="include",e.baseConfigs.mode="cors"):location.origin===n.origin&&(r.delete("origin"),e.baseConfigs.credentials=void 0,e.baseConfigs.mode=void 0)),n.searchParams.has("origin")){const s=encodeURIComponent(n.searchParams.get("origin")||"").replace(/\./g,"%2E");i.query={},n.searchParams.delete("origin"),i.url=`${n}${n.search?"&":"?"}origin=${s}`}return i})),e}const Yt=(t,...e)=>{const i=s=>Object.prototype.toString.call(s)==="[object Object]",n=s=>{if(Array.isArray(s))return s.slice();if(i(s)){const o={};for(const a of Reflect.ownKeys(s))o[a]=n(s[a]);return o}return s},r=n(t);for(const s of e)if(s!=null)for(const o of Reflect.ownKeys(s)){const a=s[o];if(typeof a>"u")continue;const l=r[o];i(l)&&i(a)?r[o]=Yt(l,a):r[o]=n(a)}return r},Gf=(t,e,i)=>{let n={...la.DEFAULT_CONFIGS};if(typeof t=="string"?n=Yt(n,{baseURL:t,fexiosConfigs:e||{},defaultParams:i||{}}):typeof t=="object"&&t!==null&&(n=Yt(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},Xf=()=>{},Jf=async(t,e)=>{let i=0;const{retry:n=3,onRetry:r=Xf,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")};/**
50
- * WikiSaikou Core class
51
- * @internal You **SHOULD NOT** use this class directly, instead, use the `MediaWikiApi` class.
52
- * @author dragon-fish <dragon-fish@qq.com>
53
- * @license MIT
54
- */const Hi=class{constructor(e,i,n){this.version="7.1.2",this.token=this.getToken;const r=this.config=Gf(e,i,n);this.request=aa(r.baseURL)}setBaseURL(e){return this.config.baseURL=e,this.request.baseConfigs.baseURL=e,this}async get(e,i){return this.runRequestWithApiErrorMapping(()=>this.request.get("",Yt({},this.config.fexiosConfigs,{query:Yt(this.config.defaultParams,e)},i)))}async post(e,i){return this.runRequestWithApiErrorMapping(()=>this.request.post("",e,Yt({},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&&je.includesMediaWikiApiError(i)?new li(je.extractMediaWikiApiErrors(i),i):i}}throwIfApiError(e){const i=je.extractMediaWikiApiErrors(e);if(i.length>0)throw new li(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 je(qi.TOKEN_RETRY_LIMIT_EXCEEDED,"The limit of the number of times to automatically re-acquire the token has been exceeded");let l=0;return Jf(async()=>{const c=await this.getToken(e,o||l>0);try{const u=await this.post({[r]:c,...i},Yt(a||{},{headers:{"x-mw-token-name":e}}));if(je.isBadTokenError(u.data))throw u;return u}catch(u){throw je.isBadTokenError(u)||u?.ok===!1||li.is(u)?u:new je(qi.HTTP_ERROR,"Network/transport or SDK-internal error (not a MediaWiki API error)",u)}},{retry:s,onRetry:(c,u)=>{l=u+1},shouldRetry:c=>je.isBadTokenError(c)||c?.ok===!1}).catch(c=>{throw je.isBadTokenError(c)||c?.ok===!1?new je(qi.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}};Hi.INIT_DEFAULT_PARAMS={action:"query",errorformat:"plaintext",format:"json",formatversion:2},Hi.DEFAULT_CONFIGS={baseURL:void 0,fexiosConfigs:{responseType:"json"},defaultParams:Hi.INIT_DEFAULT_PARAMS,throwOnApiError:!1},Hi.createRequestHandler=aa;let la=Hi;/**
55
- * WikiSaikou
56
- * @description Standalone MediaWiki API SDK with `mw.Api`-like API in any environments
57
- * @author Dragon-Fish <dragon-fish@qq.com>
58
- * @license MIT
59
- */let Zf=class extends la{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 je(qi.LOGIN_FAILED,r.data.clientlogin.message,r)}};class ed{constructor(e,i={}){this.ctx=e,location?.href&&i?.baseURL?.toString()?.startsWith("/")&&(i.baseURL=new URL(i.baseURL,location.origin));const n=new Zf({baseURL:i.baseURL.toString(),fexiosConfigs:{headers:{"x-api-user-agent":`InPageEdit-NEXT ${e.version}`,...i.headers},...i},throwOnApiError:!0});e.set("api",n)}}var td=Object.create,Yr=Object.defineProperty,id=Object.getOwnPropertyDescriptor,ca=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ua=t=>{throw TypeError(t)},nd=(t,e,i)=>e in t?Yr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,rd=(t,e)=>Yr(t,"name",{value:e,configurable:!0}),sd=t=>[,,,td(t?.[ca("metadata")]??null)],od=["class","method","getter","setter","accessor","field","value","get","set"],fa=t=>t!==void 0&&typeof t!="function"?ua("Function expected"):t,ad=(t,e,i,n,r)=>({kind:od[t],name:e,metadata:n,addInitializer:s=>i._?ua("Already initialized"):r.push(fa(s||null))}),ld=(t,e)=>nd(e,ca("metadata"),t[3]),cd=(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},ud=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(r=r.prototype,c<5&&(c>3||!u)&&id(r,i));rd(r,i);for(var g=n.length-1;g>=0;g--)l=ad(c,i,a={},t[3],h),o=(0,n[g])(r,l),a._=1,fa(o)&&(r=o);return ld(t,r),m&&Yr(r,i,m),u?c^4?s:m:r},da,Gr,ha;da=[xe(["wiki","wikiTitle"])];class Tn extends(ha=Pt){constructor(i){super(i,"currentPage",!1);Ni(this,qe);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 nt(this,qe,Uo).call(this),nt(this,qe,nf).call(this),window.addEventListener("popstate",nt(this,qe,Fo).bind(this)),this.logger.info("initialized",this.wikiTitle)}stop(){window.removeEventListener("popstate",nt(this,qe,Fo).bind(this))}get params(){return this.url.searchParams}get canonicalUrl(){const i=document.querySelector('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"}}qe=new WeakSet,Uo=async function(){await nt(this,qe,sf).call(this),await nt(this,qe,rf).call(this)},nf=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},Fo=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 nt(this,qe,Uo).call(this),this.logger.info("location changed",r,this.wikiTitle))},rf=async function(){const n=this.wikiTitle?.getMainDBKey()===this.ctx.wiki.mainPageName;return Reflect.defineProperty(this,"isMainPage",{get:()=>n}),n},sf=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},Gr=sd(ha),Tn=ud(Gr,0,"CurrentPageService",da,Tn),cd(Gr,1,Tn);class fd extends Pt{constructor(e){super(e,"resourceLoader",!0),this.ctx=e}stop(){}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,f])=>{typeof f>"u"||f===!1||f===null?l.removeAttribute(u):l.setAttribute(u,f)}),(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)})}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 Rn=Object.keys;function dd(t){return typeof t=="boolean"}function hd(t){return t&&typeof t.nodeType=="number"}function Xr(t){return typeof t=="string"}function pa(t){return typeof t=="number"}function Gt(t){return typeof t=="object"?t!==null:zi(t)}function zi(t){return typeof t=="function"}function pd(t){return!!(t&&t.isComponent)}function md(t){return Gt(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function Jr(t,e){if(t)for(const i of Rn(t))e(t[i],i)}function gd(t){return Gt(t)&&"current"in t}const Zr={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 yd(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const bd=["Webkit","ms","Moz","O"];Rn(Zr).forEach(t=>{bd.forEach(e=>{Zr[yd(e,t)]=0})});const wd=Symbol.for("jsx-dom:type");var ma=function(t){return t.ShadowRoot="ShadowRoot",t}(ma||{});function vd(t){return t!=null&&t[wd]===ma.ShadowRoot}const _d="http://www.w3.org/2000/svg",xd="http://www.w3.org/1999/xlink",Sd="http://www.w3.org/XML/1998/namespace";function ga(t){return!dd(t)&&t!=null}function es(t){return Array.isArray(t)?t.map(es).filter(Boolean).join(" "):Gt(t)?Symbol.iterator in t?es(Array.from(t)):Rn(t).filter(e=>t[e]).join(" "):ga(t)?""+t:""}const kd={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},Ed=/^(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 Ct(t){const e=document.createDocumentFragment();return Ln(t.children,e),e}function $d(t,e,i){e={...e,children:i};const n=new t(e),r=n.render();return"ref"in e&&ts(e.ref,n),r}function p(t,e){let{children:i,...n}=e;!n.namespaceURI&&kd[t]===0&&(n={...n,namespaceURI:_d});let r;if(Xr(t)){if(r=n.namespaceURI?document.createElementNS(n.namespaceURI,t):document.createElement(t),Od(n,r),Ln(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;ts(n.ref,r)}else if(zi(t))Gt(t.defaultProps)&&(n={...t.defaultProps,...n}),r=pd(t)?$d(t,n,i):t({...n,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return r}function ts(t,e){gd(t)?t.current=e:zi(t)&&t(e)}function Ln(t,e){if(md(t))Pd(t,e);else if(Xr(t)||pa(t))is(document.createTextNode(t),e);else if(t===null)is(document.createComment(""),e);else if(hd(t))is(t,e);else if(vd(t)){const i=e.attachShadow(t.attr);Ln(t.children,i),ts(t.ref,i)}}function Pd(t,e){for(const i of[...t])Ln(i,e);return e}function is(t,e){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}function Nn(t,e){return t.replace(/[A-Z]/g,i=>e+i.toLowerCase())}function ya(t,e){e==null||e===!1||(Array.isArray(e)?e.forEach(i=>ya(t,i)):Xr(e)?t.setAttribute("style",e):Gt(e)&&Jr(e,(i,n)=>{n.indexOf("-")===0?t.style.setProperty(n,i):pa(i)&&Zr[n]!==0?t.style[n]=i+"px":t.style[n]=i}))}function Cd(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":ba(i,xd,Nn(t,":"),e);return;case"xmlnsXlink":ci(i,Nn(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":ba(i,Sd,Nn(t,":"),e);return}switch(t){case"htmlFor":ci(i,"for",e);return;case"dataset":Jr(e,(n,r)=>{n!=null&&(i.dataset[r]=n)});return;case"innerHTML":case"innerText":case"textContent":ga(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":Gt(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":zi(e)?e(i):ci(i,"class",es(e));return;case"ref":case"namespaceURI":return;case"style":ya(i,e);return;case"on":case"onCapture":Jr(e,(n,r)=>{i.addEventListener(r,n,t==="onCapture")});return}if(zi(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 Gt(e)?i[t]=e:e===!0?ci(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!Ed.test(t)?ci(i,Nn(t,"-"),e):ci(i,t,e))}function ci(t,e,i){t.setAttribute(e,i)}function ba(t,e,i,n){t.setAttributeNS(e,i,n)}function Od(t,e){for(const i of Rn(t))Cd(i,t[i],e);return e}const Mn=Object.keys;function Id(t){return typeof t=="boolean"}function Ad(t){return t&&typeof t.nodeType=="number"}function ns(t){return typeof t=="string"}function wa(t){return typeof t=="number"}function Xt(t){return typeof t=="object"?t!==null:Wi(t)}function Wi(t){return typeof t=="function"}function Td(t){return!!(t&&t.isComponent)}function Rd(t){return Xt(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function rs(t,e){if(t)for(const i of Mn(t))e(t[i],i)}function Ld(t){return Xt(t)&&"current"in t}const ss={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 Nd(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const Md=["Webkit","ms","Moz","O"];Mn(ss).forEach(t=>{Md.forEach(e=>{ss[Nd(e,t)]=0})});const Dd=Symbol.for("jsx-dom:type");var va=function(t){return t.ShadowRoot="ShadowRoot",t}(va||{});function jd(t){return t!=null&&t[Dd]===va.ShadowRoot}const Ud="http://www.w3.org/2000/svg",Fd="http://www.w3.org/1999/xlink",Bd="http://www.w3.org/XML/1998/namespace";function _a(t){return!Id(t)&&t!=null}function os(t){return Array.isArray(t)?t.map(os).filter(Boolean).join(" "):Xt(t)?Symbol.iterator in t?os(Array.from(t)):Mn(t).filter(e=>t[e]).join(" "):_a(t)?""+t:""}const qd={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},Hd=/^(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 zd(t){const e=document.createDocumentFragment();return Dn(t.children,e),e}function Wd(t,e,i){e={...e,children:i};const n=new t(e),r=n.render();return"ref"in e&&as(e.ref,n),r}function pe(t,e){let{children:i,...n}=e;!n.namespaceURI&&qd[t]===0&&(n={...n,namespaceURI:Ud});let r;if(ns(t)){if(r=n.namespaceURI?document.createElementNS(n.namespaceURI,t):document.createElement(t),Qd(n,r),Dn(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;as(n.ref,r)}else if(Wi(t))Xt(t.defaultProps)&&(n={...t.defaultProps,...n}),r=Td(t)?Wd(t,n,i):t({...n,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return r}function as(t,e){Ld(t)?t.current=e:Wi(t)&&t(e)}function Dn(t,e){if(Rd(t))Kd(t,e);else if(ns(t)||wa(t))ls(document.createTextNode(t),e);else if(t===null)ls(document.createComment(""),e);else if(Ad(t))ls(t,e);else if(jd(t)){const i=e.attachShadow(t.attr);Dn(t.children,i),as(t.ref,i)}}function Kd(t,e){for(const i of[...t])Dn(i,e);return e}function ls(t,e){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}function jn(t,e){return t.replace(/[A-Z]/g,i=>e+i.toLowerCase())}function xa(t,e){e==null||e===!1||(Array.isArray(e)?e.forEach(i=>xa(t,i)):ns(e)?t.setAttribute("style",e):Xt(e)&&rs(e,(i,n)=>{n.indexOf("-")===0?t.style.setProperty(n,i):wa(i)&&ss[n]!==0?t.style[n]=i+"px":t.style[n]=i}))}function Vd(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":Sa(i,Fd,jn(t,":"),e);return;case"xmlnsXlink":ui(i,jn(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":Sa(i,Bd,jn(t,":"),e);return}switch(t){case"htmlFor":ui(i,"for",e);return;case"dataset":rs(e,(n,r)=>{n!=null&&(i.dataset[r]=n)});return;case"innerHTML":case"innerText":case"textContent":_a(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":Xt(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":Wi(e)?e(i):ui(i,"class",os(e));return;case"ref":case"namespaceURI":return;case"style":xa(i,e);return;case"on":case"onCapture":rs(e,(n,r)=>{i.addEventListener(r,n,t==="onCapture")});return}if(Wi(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 Xt(e)?i[t]=e:e===!0?ui(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!Hd.test(t)?ui(i,jn(t,"-"),e):ui(i,t,e))}function ui(t,e,i){t.setAttribute(e,i)}function Sa(t,e,i,n){t.setAttributeNS(e,i,n)}function Qd(t,e){for(const i of Mn(t))Vd(i,t[i],e);return e}var cs=(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))(cs||{});let Yd=0;const ka=t=>`${t}-${++Yd}`;function Ki(t){return t instanceof Node?t:document.createTextNode(String(t))}function Ot(t,e){if(!t)throw new Error(`${e??"Element"} not found`);return t}function Ea(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 Ae(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 Gd=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/i.test(navigator.platform),$a=["ctrl","alt","shift","meta"];function Xd(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(Gd?"meta":"ctrl");continue}a==="esc"&&(a="escape"),a==="return"&&(a="enter"),(a==="space"||a==="spacebar")&&(a="space"),n=a}const s=$a.filter(o=>i.includes(o));return!n||n===""?s.length?s.join("+"):null:s.length?`${s.join("+")}+${n}`:n}function Jd(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=$a.filter(s=>e.includes(s));return r.length?`${r.join("+")}+${n}`:n}class Zd{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 Ue=new Zd,yn=class yn{constructor(e={}){this.backdropId=ka("ipe-modal-backdrop"),this.modalId=ka("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=cs,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={...yn.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=Ae("div",{className:"ipe-modal-backdrop",attrs:{id:this.backdropId,"data-modal-id":this.modalId}}));const n=Ae("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 m=window.pageYOffset||document.documentElement.scrollTop,g=window.pageXOffset||document.documentElement.scrollLeft,k=window.innerWidth;n.style.top=`${m+60}px`,this.once("modal.show",()=>{n.style.left=`${g+k/2-n.offsetWidth/2}px`})}const r=Ae("div",{className:`ipe-modal-modal__window size--${this.options.sizeClass||"auto"} plugin--${this.pluginName}`});r.modal=this;const s=Ae("div",{className:"ipe-modal-modal__header"}),o=`${this.modalId}-title`,a=Ae("h2",{className:"ipe-modal-modal__title",attrs:{id:o,role:"heading","aria-level":"2"}});n.setAttribute("aria-labelledby",o);const l=Ae("div",{className:"ipe-modal-modal__icons"});if(this.options.closeIcon){const m=Ae("button",{className:"ipe-modal-modal__close",attrs:{type:"button","aria-label":"Close"},html:"&times;"});m.addEventListener("click",()=>{let g=!0;typeof this.options.onClickClose=="function"?this.options.onClickClose(this)===!1&&(g=!1):this.options.onClickClose===!1&&(g=!1),g&&this.close()}),l.appendChild(m)}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=Ae("div",{className:"ipe-modal-modal__content"}),u=Ae("div",{className:"ipe-modal-modal__footer"}),f=Ae("div",{className:"ipe-modal-modal__buttons ipe-modal-modal__buttons--left"}),h=Ae("div",{className:"ipe-modal-modal__buttons ipe-modal-modal__buttons--right"});return u.append(f,h),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=f,this.$buttonsRight=h,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",m=>{this.options.outSideClose&&m.target===i&&this.close()}),this.options.draggable&&r.addEventListener("pointerdown",m=>{m.target&&r.contains(m.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()&&Ue.lockBodyScroll(),requestAnimationFrame(()=>{this.$backdrop?.classList.add("is-open"),this.$modal.classList.add("is-open"),this.applyAnimation(!0),this.focusFirst()}),document.addEventListener("keydown",this.onKeyDown),Ue.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 f=()=>{c.removeEventListener(u,f),a()};c.addEventListener(u,f,{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=Jt.indexOf(this);e!==-1&&Jt.splice(e,1)}else this.$backdrop?.parentElement&&this.$backdrop.parentElement.removeChild(this.$backdrop),this.$modal?.parentElement&&this.$modal.parentElement.removeChild(this.$modal),Ue.remove(this),this.shouldUnlockBodyOnClose()&&Ue.unlockBodyScroll();return this.isOpen=!1,this.lastFocused?.focus?.(),this.emit("modal.destroy"),this._isDestroyed=!0,this}get$backdrop(){return this.$backdrop}get$modal(){return Ot(this.$modal,"modal")}get$window(){return Ot(this.$window,"window")}get$header(){return Ot(this.$header,"header")}get$title(){return Ot(this.$title,"title")}get$content(){return Ot(this.$content,"content")}get$icons(){return Ot(this.$icons,"icons")}get$buttons(e){return e==="leftButtons"?Ot(this.$buttonsLeft,"leftButtons"):e==="rightButtons"?Ot(this.$buttonsRight,"rightButtons"):Ot(this.$footer,"buttons")}setTitle(e){const i=this.get$title();return i.innerHTML="",i.append(Ki(e)),this}setContent(e,i="replace"){const n=this.get$content();return i==="replace"?(n.innerHTML="",n.append(Ki(e))):i==="append"?n.append(Ki(e)):n.prepend(Ki(e)),this}setIcons(e){const i=this.get$icons();i.innerHTML="";for(const n of e){const r=Ae("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"?Ae("a"):Ae("button",{attrs:{type:"button"}});e.id&&(n.id=e.id),n.className=`ipe-modal-btn ${e.className??""}`.trim();const r=Ki(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=Xd(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=Ea(e);i.length?i[0].focus():e.focus({preventScroll:!0})}onKeyDown(e){if(Ue.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=Ea(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=Jd(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 Ue.remove(this),Ue.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:!Ue.stack.some(e=>e!==this&&e.options.backdrop!==!1&&e.options.bodyScroll===!1)}shouldUnlockBodyOnClose(){return this.options.backdrop===!1||this.options.bodyScroll!==!1?!1:!Ue.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=eh(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),Jt.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=Ue.top();return s?.close(),s}const i=typeof e=="string"?e:e.id,n=Ue.stack.find(s=>s.modalId===i);if(n)return n.close(),n;const r=Jt.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 Ue.closeAll(e,i),[...Jt].forEach(s=>{const o=s.modalId,a=r.size?r.has(s.pluginName):!0,l=n.has(o);a&&!l&&s.close()}),Ue.top()??new yn}static removeAll(){Ue.removeAll(),[...Jt].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 pe("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:[pe("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),pe("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 pe("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:[pe("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),pe("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 pe("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:[pe("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),pe("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 pe("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:[pe("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),pe("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 pe("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:[pe("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),pe("path",{d:"M12 11v.01"}),pe("path",{d:"M8 11v.01"}),pe("path",{d:"M16 11v.01"}),pe("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 pe("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:[pe("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),pe("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&&[...Jt].forEach(f=>f.close()),typeof i.title>"u"){const f=e||"Notification";i.title=f[0].toUpperCase()+f.slice(1).toLowerCase()}const r=i.icon??this.getDefaultNotifyIcon(e);r&&(r instanceof Element&&r.classList.add("ipe-modal-notify-icon"),i.title=pe(zd,{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=(f,h)=>{n?.(!0,h,f),h.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=(f,h)=>{n?.(!1,h,f),h.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"})}};yn.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 us=yn;const Jt=[];function eh(t="top right"){const e="ipe-modal-toast-container",i=`${e}-${t.replace(/[\s-\.|\/]+/g,"-")}`;let n=document.getElementById(i);return n||(n=Ae("div",{className:`${e} ${t}`,attrs:{id:i,"data-position":t}}),document.body.appendChild(n)),n}const th={ipe_progress:"_ipe_progress_so6hn_1"},jt=t=>{const e=t.indeterminate??!0,i=p("div",{class:`${th.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 Se extends us{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(p("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:p(jt,{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 ih{constructor(e){this.ctx=e,this.IPEModal=Se,this.IPEModalEvent=cs,this.show=Se.show.bind(Se),this.createObject=Se.createObject.bind(Se),this.close=Se.close.bind(Se),this.closeAll=Se.closeAll.bind(Se),this.removeAll=Se.removeAll.bind(Se),this.dialog=Se.dialog.bind(Se),this.confirm=Se.confirm.bind(Se),this.notify=Se.notify.bind(Se),e.set("modal",this),e.on("dispose",()=>{Se.closeAll()})}}const Pa=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},Ca=(t,e,i)=>{const n=typeof t=="string"?new URL(t,window?.location?.origin):new URL(t),r=new URLSearchParams(n.search),s=Pa(e);for(const[o,a]of s.entries())r.set(o,a);return n.search=r.toString(),n.hash="",n};var nh=Object.create,fs=Object.defineProperty,rh=Object.getOwnPropertyDescriptor,Oa=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ia=t=>{throw TypeError(t)},sh=(t,e,i)=>e in t?fs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,oh=(t,e)=>fs(t,"name",{value:e,configurable:!0}),ah=t=>[,,,nh(t?.[Oa("metadata")]??null)],lh=["class","method","getter","setter","accessor","field","value","get","set"],Aa=t=>t!==void 0&&typeof t!="function"?Ia("Function expected"):t,ch=(t,e,i,n,r)=>({kind:lh[t],name:e,metadata:n,addInitializer:s=>i._?Ia("Already initialized"):r.push(Aa(s||null))}),uh=(t,e)=>sh(e,Oa("metadata"),t[3]),fh=(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},dh=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(r=r.prototype,c<5&&(c>3||!u)&&rh(r,i));oh(r,i);for(var g=n.length-1;g>=0;g--)l=ch(c,i,a={},t[3],h),o=(0,n[g])(r,l),a._=1,Aa(o)&&(r=o);return uh(t,r),m&&fs(r,i,m),u?c^4?s:m:r},Ta,ds,Ra;Ta=[xe(["api","storage"])];class Un extends(Ra=Pt){constructor(e){super(e,"wiki",!1),this.ctx=e,this._data={},this.CACHE_VERSION=3,this.CACHE_TTL={siteinfo:1e3*60*60*24*3,userinfo:1e3*60*30},this.QUERY_DATA={siteinfo:{meta:"siteinfo",siprop:"general|specialpagealiases|namespacealiases|namespaces|magicwords"},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.createDatabse("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.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=>{e.preferences.registerCustomConfig("WikiMetadataService",Y.object({WikiMetadataService:Y.const(p("div",{children:[p("h3",{children:"Wiki Informations"}),p("ul",{children:[p("li",{children:[p("strong",{children:"Site:"})," ",this.general.sitename," (",this.landingPageUrl,")"]}),p("li",{children:[p("strong",{children:"User"}),": ",this.userInfo.name," (ID: ",this.userInfo.id,")"]}),p("li",{children:[p("strong",{children:"Groups"}),": ",this.userGroups.join(", ")||"None"]})]}),p("div",{children:[p("p",{style:{fontStyle:"italic"},children:"If the information shown above is incorrect (for example, the user is not you), click the button below."}),p("button",{className:"btn danger",onClick:i=>{i.preventDefault(),Promise.all(Object.keys(this.QUERY_DATA).map(n=>this.invalidateCache(n))).then(()=>{window.location.reload()})},children:"🧹 Clear caches & Reload"})]})]})).role("raw-html")}).description("WikiMetadataService"),"general")}),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)}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 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 Ca(this.siteInfo.general.base,e).toString()}getUrl(e,i){const n=Pa(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}}ds=ah(Ra),Un=dh(ds,0,"WikiMetadataService",Ta,Un),fh(ds,1,Un);var ye;(t=>{function e(d){return new Promise((y,v)=>{d.onsuccess=()=>y(d.result),d.onerror=()=>v(d.error)})}t.promisifyRequest=e;const i=new Map,n=new Map;function r(d,y){const v=(n.get(d)??Promise.resolve()).then(y,y);return n.set(d,v.catch(()=>{})),v}function s(d){return new Promise(y=>setTimeout(y,d+Math.floor(Math.random()*8)))}function o(d){if(!(d instanceof DOMException))return!1;const y=d.name,v=String(d?.message??"");return y==="InvalidStateError"||y==="TransactionInactiveError"||y==="NotFoundError"||y==="AbortError"&&/versionchange|closing|internal/i.test(v)}function a(d){const y=i.get(d);if(y)return y;const v=new Promise((x,E)=>{const L=indexedDB.open(d);L.onupgradeneeded=()=>{},L.onsuccess=()=>{const B=L.result;B.onversionchange=()=>{try{B.close()}finally{i.delete(d)}},x(B)},L.onerror=()=>E(L.error),L.onblocked=()=>{}});return i.set(d,v),v}t.openDatabase=a;async function l(d){const y=i.get(d);if(y)try{(await y).close()}finally{i.delete(d)}}t.closeDatabase=l;async function c(){const d=Array.from(i.keys());await Promise.all(d.map(l))}t.closeAllDatabases=c;async function u(d){await l(d),await new Promise((y,v)=>{const x=indexedDB.deleteDatabase(d);x.onsuccess=()=>y(),x.onerror=()=>v(x.error),x.onblocked=()=>{}})}t.deleteDatabase=u;async function f(d,y,v={}){return r(d,async()=>{let x=await a(d);const E=!x.objectStoreNames.contains(y),L=!E&&v.indexes&&v.indexes.length>0;if(!E&&!L)return x;const B=x.version+1;x.close();const Ce=new Promise((Ne,Ee)=>{const we=indexedDB.open(d,B);we.onupgradeneeded=()=>{const he=we.result;let ae;if(he.objectStoreNames.contains(y)?ae=we.transaction.objectStore(y):ae=he.createObjectStore(y,{keyPath:v.keyPath??void 0,autoIncrement:!!v.autoIncrement}),v.indexes&&v.indexes.length>0)for(const{name:le,keyPath:G,options:it}of v.indexes)ae.indexNames.contains(le)||ae.createIndex(le,G,it)},we.onsuccess=()=>{const he=we.result;he.onversionchange=()=>{try{he.close()}finally{i.delete(d)}},Ne(he)},we.onerror=()=>Ee(we.error),we.onblocked=()=>{}});return i.set(d,Ce),Ce})}t.ensureStore=f;async function h(d,y,v={}){return await f(d,y,v),{dbName:d,storeName:y,getDb:()=>a(d)}}t.createStore=h;async function m(d,y,v,x={}){const{dbName:E,storeName:L}=d,B=x.attempts??2,Ce=x.baseDelayMs??16;let Ne;for(let Ee=0;Ee<=B;Ee++)try{Ee===0&&await f(E,L);const we=await a(E);let he;try{he=we.transaction(L,y)}catch(G){if(o(G)&&Ee<B){await l(E),await s(Ce*(1<<Ee)),Ne=G;continue}throw G}const ae=he.objectStore(L),le=new Promise((G,it)=>{he.oncomplete=()=>G(),he.onerror=()=>it(he.error),he.onabort=()=>it(he.error)});try{const G=await v(ae);return await le,G}catch(G){if(o(G)&&Ee<B){try{he.abort()}catch{}await l(E),await s(Ce*(1<<Ee)),Ne=G;continue}try{he.abort()}catch{}throw G}}catch(we){if(o(we)&&Ee<B){await l(E),await s(Ce*(1<<Ee)),Ne=we;continue}throw we}throw Ne}t.withObjectStore=m;async function g(d,y){return m(d,"readonly",async v=>{const x=v.get(y);return e(x)})}t.get=g;async function k(d,y,v){return m(d,"readwrite",async x=>{const E=x.put(v,y);await e(E)})}t.set=k;async function D(d,y){return m(d,"readwrite",async v=>{const x=v.delete(y);await e(x)})}t.del=D;async function T(d){return m(d,"readwrite",async y=>{const v=y.clear();await e(v)})}t.clear=T;function A(d,y=100){return{[Symbol.asyncIterator](){let v=[],x=!1,E;const L=async()=>{x||(v=[],await m(d,"readonly",async B=>{const Ce=E===void 0?void 0:IDBKeyRange.lowerBound(E,!0);await new Promise((Ne,Ee)=>{let we=0;const he=B.openCursor(Ce,"next");he.onsuccess=()=>{const ae=he.result;if(!ae||we>=y){Ne();return}v.push([ae.key,ae.value]),E=ae.key,we++,ae.continue()},he.onerror=()=>Ee(he.error)}),v.length===0&&(x=!0)}))};return{async next(){return v.length===0&&!x&&await L(),v.length===0?{value:void 0,done:!0}:{value:v.shift(),done:!1}}}}}}t.entries=A;function b(d,y=200){const v=A(d,y);return{[Symbol.asyncIterator](){const x=v[Symbol.asyncIterator]();return{async next(){const E=await x.next();return E.done?{value:void 0,done:!0}:{value:E.value[0],done:!1}}}}}}t.keys=b})(ye||(ye={}));/**
60
- * IDB Plus
61
- *
62
- * 🗄️ Minimal Promise based IndexedDB Wrapper with Map-like API
63
- *
64
- * @author dragon-fish <dragon-fish@qq.com>
65
- * @license MIT
66
- */class hh{constructor(e,i,n={}){j(this,"iterBatch");j(this,"retry");j(this,"inlineKey");j(this,"idbStoreHandle");this.dbName=e,this.storeName=i,this.iterBatch=(n.iterBatch??100)|0,this.retry=n.retry,this.inlineKey=!!n.ensure?.keyPath,this.idbStoreHandle=ye.createStore(e,i,n.ensure??{})}async get(e){const i=await this.idbStoreHandle;return ye.get(i,e)}async set(e,i){const n=await this.idbStoreHandle;return this.inlineKey?ye.withObjectStore(n,"readwrite",async r=>{const s=r.put(i);await ye.promisifyRequest(s)},this.retry):ye.set(n,e,i)}async delete(e){const i=await this.idbStoreHandle;return ye.del(i,e)}async clear(){const e=await this.idbStoreHandle;return ye.clear(e)}async has(e){const i=await this.idbStoreHandle;return ye.withObjectStore(i,"readonly",async n=>{const r=n.count(e);return await ye.promisifyRequest(r)>0},this.retry)}async count(){const e=await this.idbStoreHandle;return ye.withObjectStore(e,"readonly",async i=>{const n=i.count();return ye.promisifyRequest(n)},this.retry)}entries(){const e=this;return{[Symbol.asyncIterator](){let i=null;return{async next(){if(!i){const n=await e.idbStoreHandle;i=ye.entries(n,e.iterBatch)[Symbol.asyncIterator]()}return await i.next()}}}}}keys(){const e=this;return{[Symbol.asyncIterator](){let i=null;return{async next(){if(!i){const n=await e.idbStoreHandle;i=ye.keys(n,e.iterBatch)[Symbol.asyncIterator]()}return await i.next()}}}}}values(){const e=this;return{[Symbol.asyncIterator](){const i=e.entries()[Symbol.asyncIterator]();return{async next(){const n=await i.next();return n.done?{value:void 0,done:!0}:{value:n.value[1],done:!1}}}}}}[Symbol.asyncIterator](){return this.entries()[Symbol.asyncIterator]()}async forEach(e){for await(const[i,n]of this.entries())await e(n,i,this)}async setMany(e){const i=await this.idbStoreHandle;await ye.withObjectStore(i,"readwrite",async n=>{for await(const[r,s]of La(e)){const o=this.inlineKey?n.put(s):n.put(s,r);await ye.promisifyRequest(o)}},this.retry)}async deleteMany(e){const i=await this.idbStoreHandle;await ye.withObjectStore(i,"readwrite",async n=>{for await(const r of La(e)){const s=n.delete(r);await ye.promisifyRequest(s)}},this.retry)}async tx(e,i){const n=await this.idbStoreHandle;return ye.withObjectStore(n,e,i,this.retry)}async close(){await ye.closeDatabase(this.dbName)}}function La(t){return t[Symbol.asyncIterator]?t:{async*[Symbol.asyncIterator](){for(const e of t)yield e}}}class ph{constructor(e,i,n=1/0,r){this.dbName=e,this.storeName=i,this.ttl=n,this.version=r,this.db=new hh(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)}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){if(i===null||typeof i>"u")return this.delete(e);const n={time:Date.now(),value:i,version:this.version};return await this.db.set(e,n),n}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 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=="number"&&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 mh extends Pt{constructor(e){super(e,"storage",!1)}createDatabse(e,i,n){return new ph("InPageEdit",e,i,n)}}var Je=(t=>(t.preferences="preferences",t.watch="watch",t.unwatch="unwatch",t.nochange="nochange",t))(Je||{});function gh(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)}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{text:o,prependtext:a,appendtext:l,summary:c="",watchlist:u=Je.preferences,section:f}=r;return this.api.postWithEditToken({action:"edit",title:this.title,starttimestamp:this.pageInfo.touched,basetimestamp:this.revisions[0]?.timestamp,text:o,prependtext:a,appendtext:l,summary:c,watchlist:u,section:f,...s})}async createOnly(r,s){return this.edit(r,{createonly:1,...s})}async delete(r,s){return this.api.postWithEditToken({action:"delete",pageid:this.pageInfo.pageid,reason:r,...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 No=class No extends Pt{constructor(e){super(e,"wikiPage",!0),this.ctx=e,this.WikiPage=gh(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)}};No.inject=["api"];let hs=No;const Na=new WeakMap,ft={toDBKey:t=>t.replace(/ /g,"_"),toNormalText:t=>t.replace(/_/g," "),ensureCase:(t,e)=>e==="first-letter"?t.charAt(0).toUpperCase()+t.slice(1):t},fi={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=fi.normalizeSpecialPageName(s);n.set(o,s);for(const a of r.aliases){i.set(a,s);const l=fi.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=fi.normalizeSpecialPageName(i);return e.byNormalized.get(r)??null}},st={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=st.normalizeNamespaceText(o.name),c=st.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=st.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=st.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 yh(t){var s,o;const e=Na.get(t);if(e)return e;const i=st.buildIndex(t),n=fi.buildSpecialPageIndex(t),a=class a{constructor(c,u){Ni(this,s);Ni(this,o);if(this.newTitle=a.create.bind(a),this.toText=this.getPrefixedText.bind(this),this.toString=this.getPrefixedDBKey.bind(this),We(this,s,c||""),We(this,o,u??0),u===void 0?this.fixNSByTitle():this.stripNamespaceFromTitle(),this.getMainText()==="")throw new Error("Invalid title")}static create(c,u){return new a(c,u)}fixNSByTitle(){const c=J(this,s).indexOf(":");if(c===-1)return;if(c===0){We(this,s,J(this,s).substring(1));return}const u=J(this,s).substring(0,c),f=J(this,s).substring(c+1),h=st.findNamespaceId(u,a._namespaceIndex);h!==null&&(We(this,s,f),We(this,o,h))}stripNamespaceFromTitle(){const c=J(this,s).indexOf(":");if(c===-1)return;if(c===0){We(this,s,J(this,s).substring(1));return}const u=J(this,s).substring(0,c),f=J(this,s).substring(c+1);st.findNamespaceId(u,a._namespaceIndex)!==null&&We(this,s,f)}getNamespaceInfo(){return a._meta.namespaces[J(this,o)]??st.getDefaultNamespaceInfo(J(this,o))}getMainDBKey(){const c=this.getNamespaceInfo();if(J(this,o)===-1){const u=fi.findSpecialPageRealName(J(this,s),a._specialPageIndex);if(u){const f=J(this,s).includes("/")?J(this,s).substring(J(this,s).indexOf("/")):"",h=u+f;return ft.ensureCase(ft.toDBKey(h),c.case)}}return ft.ensureCase(ft.toDBKey(J(this,s)),c.case)}getMainText(){const c=this.getNamespaceInfo();if(J(this,o)===-1){const u=fi.findSpecialPageRealName(J(this,s),a._specialPageIndex);if(u){const f=J(this,s).includes("/")?J(this,s).substring(J(this,s).indexOf("/")):"",h=u+f;return ft.ensureCase(ft.toNormalText(h),c.case)}}return ft.ensureCase(ft.toNormalText(J(this,s)),c.case)}getMainRootText(){return this.getMainText().split("/")[0]}getPrefixedDBKey(){return J(this,o)===0?this.getMainDBKey():`${this.getNamespaceDBKey()}:${this.getMainDBKey()}`}getPrefixedText(){return J(this,o)===0?this.getMainText():`${this.getNamespaceText()}:${this.getMainText()}`}getNamespaceId(){return J(this,o)}getNamespaceText(){return this.getNamespaceInfo().name??""}getNamespaceDBKey(){const c=this.getNamespaceInfo();return ft.ensureCase(ft.toDBKey(this.getNamespaceText()),c.case)}getSubjectPage(){if(st.isTalkPage(J(this,o))){const c=J(this,o)-1;return new a(J(this,s),c)}return this}getTalkPage(){if(st.isTalkPage(J(this,o)))return this;if(J(this,o)<0)return null;const c=J(this,o)+1;return a._meta.namespaces[c.toString()]?new a(J(this,s),c):null}getURL(c){const u=a._meta.general.articlepath,f=this.getPrefixedDBKey(),h=u.replace("$1",f),m=new URL(h,location.origin);return c&&(c instanceof URLSearchParams?c:new URLSearchParams(c)).forEach((k,D)=>{m.searchParams.set(D,k)}),m}setTitle(c){return We(this,s,c),We(this,o,0),this.fixNSByTitle(),this}setMainText(c){return We(this,s,c),this}setNamespaceText(c){const u=st.findNamespaceId(c,a._namespaceIndex);return u!==null&&We(this,o,u),this}setNamespaceId(c){return We(this,o,c),this}equals(c){return typeof c=="string"&&(c=new a(c)),this.getPrefixedDBKey()===c.getPrefixedDBKey()}isSpecial(c){if(J(this,o)!==-1)return!1;const u=new a(c,-1);return this.getMainRootText()===u.getMainRootText()}toJSON(){return{ns:J(this,o),text:this.getMainText(),title:this.getPrefixedText(),url:this.getURL().toString(),isSpecial:J(this,o)<0}}};s=new WeakMap,o=new WeakMap,a._meta=t,a._namespaceIndex=i,a._specialPageIndex=n;let r=a;return Na.set(t,r),r}const bn=class bn 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=yh(this.ctx.wiki.siteInfo)}newTitle(e,i){return new this.Title(e,i)}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}=ne();this._cachedTitles.set(`${a}:${o}`,l);try{const{wikiPage:f}=await this.ctx.useScope(["wikiPage"]);let h=null;if(a==="pageid")h=await f.newFromPageId(o);else if(a==="revid")h=await f.newFromRevision(o);else throw new Error(`Invalid kind: ${a}`);c(this.newTitle(h.title))}catch(f){this._cachedTitles.delete(`${a}:${o}`),u(f)}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:!bn.REG_SKIPPED_HREF.test(e)}parseWikiLink(e){if(!e||typeof e=="string"&&!this.validateHrefAttr(e))return null;const i=Ca(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(m){return this.logger.error("parseLink",i,m),""}})();c.endsWith("index.php")&&(c="");let u,f,h;if(l)h=l;else if(a)f=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:f,revId:h,url:i,params:n,hash:r,action:s}}};bn.inject=["wiki"],bn.REG_SKIPPED_HREF=/^(#|javascript:|vbscript:|file:)/i;let ps=bn;const bh=t=>typeof t=="function";async function wh(t){return bh(t)?await t():t}var vh=Object.create,ms=Object.defineProperty,_h=Object.getOwnPropertyDescriptor,Ma=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Da=t=>{throw TypeError(t)},xh=(t,e,i)=>e in t?ms(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Sh=(t,e)=>ms(t,"name",{value:e,configurable:!0}),kh=t=>[,,,vh(t?.[Ma("metadata")]??null)],Eh=["class","method","getter","setter","accessor","field","value","get","set"],ja=t=>t!==void 0&&typeof t!="function"?Da("Function expected"):t,$h=(t,e,i,n,r)=>({kind:Eh[t],name:e,metadata:n,addInitializer:s=>i._?Da("Already initialized"):r.push(ja(s||null))}),Ph=(t,e)=>xh(e,Ma("metadata"),t[3]),Ch=(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},Oh=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(r=r.prototype,c<5&&(c>3||!u)&&_h(r,i));Sh(r,i);for(var g=n.length-1;g>=0;g--)l=$h(c,i,a={},t[3],h),o=(0,n[g])(r,l),a._=1,ja(o)&&(r=o);return Ph(t,r),m&&ms(r,i,m),u?c^4?s:m:r},Ua,gs,Fa;Ua=[xe(["storage"])];class Fn extends(Fa=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.createDatabse("preferences",1/0)}get logger(){return this.ctx.logger("PREFERENCES")}async start(){this.defineCategory({name:"general",label:"General",description:"General settings"}),this.defineCategory({name:"edit",label:"Editing",description:"Settings related to editing content"})}async get(e,i){i??(i=()=>{const r=this.getDefaultValue(e);return this.logger.debug(e,`(fallback value: ${r})`),r});const n=await this.db.get(e,void 0);return n!==null?n:await wh(i)}getDefaultValue(e){var i;return(i=this._defaultPreferences)[e]??(i[e]=this.loadDefaultConfigs()[e])}set(e,i){const n=this.getDefaultValue(e);return i===n?this.db.delete(e):this.db.set(e,i)}async setMany(e){const i=this.loadDefaultConfigs(),n=Object.fromEntries(Object.entries(e).filter(([r,s])=>{const o=i[r];return s!==void 0&&s!==o}));return await Promise.all(Object.entries(n).map(([r,s])=>this.set(r,s))),n}async getAll(){const e=this.loadDefaultConfigs();for await(const[i,n]of this.db.entries())i!=="_touched"&&(e[i]=n.value);return 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){return this.customRegistries.push({name:e,schema:i,category:n}),this}getConfigRegistries(e){return Array.from(this.ctx.registry.entries()).map(([i])=>i===null?{name:"@root",schema:hi?.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)}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}}gs=kh(Fa),Fn=Oh(gs,0,"PreferencesService",Ua,Fn),Ch(gs,1,Fn);var di=(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.HOME_URL="https://www.ipe.wiki/",t.UPDATE_LOGS_URL="https://www.ipe.wiki/changelogs/",t))(di||{});/**
67
- * ✏️ InPageEdit NEXT
68
- *
69
- * 🚀 Modular, Extensible Supercharged Plugin for MediaWiki
70
- *
71
- * @author dragon-fish <dragon-fish@qq.com>
72
- * @license MIT
73
- * @see https://github.com/inpageedit/inpageedit-next
74
- * @see https://www.ipe.wiki/
75
- */const wn=class wn extends Me{constructor(i){super({name:"InPageEdit"});Ni(this,_t);this.version="0.11.1",this.Endpoints=di,this.schema=Y,this.config=Ui(wn.DEFAULT_CONFIG,i),this.logger=ia({name:"IPE",color:"#33aaff",level:this.config.logLevel}),nt(this,_t,of).call(this),nt(this,_t,lf).call(this),nt(this,_t,cf).call(this)}async useScope(i){const{promise:n,resolve:r}=ne();return this.inject(i,s=>{r(s)}),n}};_t=new WeakSet,of=async function(){this.plugin(ed,this.config.apiConfigs),this.plugin(Tn),this.plugin(fd),this.plugin(ih),this.plugin(Fn),this.plugin(mh),this.plugin(Un),this.plugin(hs),this.plugin(ps),nt(this,_t,af).call(this,["api","currentPage","resourceLoader","modal","preferences","storage","wikiPage","wikiTitle","wiki","getUrl","getSciprtUrl","getMainpageUrl"])},af=function(i){if(typeof i=="string"&&(i=[i]),!Array.isArray(i)||i.length===0)return this;for(const n of i){const r=this[wn.internal][n];r?.type==="service"&&(r.builtin=!0)}return this},lf=async function(){[Promise.resolve().then(()=>zh).then(({PluginAnalytics:n})=>n),Promise.resolve().then(()=>tp).then(({PluginInArticleLinks:n})=>n),Promise.resolve().then(()=>ty).then(({PluginPreferencesUI:n})=>n),Promise.resolve().then(()=>gy).then(({PluginQuickEdit:n})=>n),Promise.resolve().then(()=>Py).then(({PluginQuickDelete:n})=>n),Promise.resolve().then(()=>jy).then(({PluginQuickMove:n})=>n),Promise.resolve().then(()=>Yy).then(({PluginQuickPreview:n})=>n),Promise.resolve().then(()=>db).then(({PluginQuickDiff:n})=>n),Promise.resolve().then(()=>hb).then(({PluginQuickRedirect:n})=>n),Promise.resolve().then(()=>kb).then(({PluginToolbox:n})=>n)].forEach(async n=>{this.plugin(await n)})},cf=async function(){this.inject(["resourceLoader"],i=>{})},wn.DEFAULT_CONFIG={apiConfigs:{},legacyPreferences:{},logLevel:zr.info,autoloadStyles:!0};let hi=wn;function Ba(t){return t.charAt(0).toLowerCase()+t.slice(1)}function Ih(t){return Ba(t).replace(/_/g,"-").replace(/.[A-Z]+/g,e=>e[0]+"-"+e.slice(1).toLowerCase())}function Ah(t){return Ba(t).replace(/-/g,"_").replace(/.[A-Z]+/g,e=>e[0]+"_"+e.slice(1).toLowerCase())}const Ir=class Ir{constructor(e,i=void 0,n){Ni(this,vn);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){We(this,vn,Ah(e).toUpperCase())}get name(){return J(this,vn)}get logger(){return this.ctx.logger(this.name)}};vn=new WeakMap,Ir.inject=[],Ir.reusable=!1;let Ve=Ir;window.RLQ||(window.RLQ=[]),window.__IPE_MODULES__||(window.__IPE_MODULES__=[]),Rh("InPageEdit#autoload",()=>{const t=qa();t&&Th({baseURL:t,CoreClass:hi})});async function Th(t={baseURL:qa(),CoreClass:hi}){const{baseURL:e,CoreClass: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.InPageEdit=i,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(`
1
+ (function(Q,re){typeof exports=="object"&&typeof module<"u"?re(exports):typeof define=="function"&&define.amd?define(["exports"],re):(Q=typeof globalThis<"u"?globalThis:Q||self,re(Q.InPageEditBundle={}))})(this,(function(Q){"use strict";var Xw=Object.defineProperty;var kf=Q=>{throw TypeError(Q)};var Jw=(Q,re,we)=>re in Q?Xw(Q,re,{enumerable:!0,configurable:!0,writable:!0,value:we}):Q[re]=we;var U=(Q,re,we)=>Jw(Q,typeof re!="symbol"?re+"":re,we),ea=(Q,re,we)=>re.has(Q)||kf("Cannot "+we);var X=(Q,re,we)=>(ea(Q,re,"read from private field"),we?we.call(Q):re.get(Q)),Fi=(Q,re,we)=>re.has(Q)?kf("Cannot add the same private member more than once"):re instanceof WeakSet?re.add(Q):re.set(Q,we),ze=(Q,re,we,z)=>(ea(Q,re,"write to private field"),z?z.call(Q,we):re.set(Q,we),we),nt=(Q,re,we)=>(ea(Q,re,"access private method"),we);var rt,Li,fi,Ni,Mi,Di,ji,be,Ye,ae,Be,ta,If,ia,Af,Of,_t,Rf,Tf,Lf,Nf,Pr,Gt,di;const re=()=>{let t,e;return{promise:new Promise((r,n)=>{t=r,e=n}),resolve:t,reject:e}};Promise.withResolvers||(Promise.withResolvers=re);var we=Object.defineProperty,z=(t,e)=>we(t,"name",{value:e,configurable:!0});function Mf(){}z(Mf,"noop");function me(t){return t==null}z(me,"isNullable");function Df(t){return!me(t)}z(Df,"isNonNullable");function Or(t){return t&&typeof t=="object"&&!Array.isArray(t)}z(Or,"isPlainObject");function ra(t,e){return Object.fromEntries(Object.entries(t).filter(([i,r])=>e(i,r)))}z(ra,"filterKeys");function $t(t,e){return Object.fromEntries(Object.entries(t).map(([i,r])=>[i,e(r,i)]))}z($t,"mapValues");function na(t,e,i){if(!e)return{...t};const r={};for(const n of e)(i||t[n]!==void 0)&&(r[n]=t[n]);return r}z(na,"pick");function jf(t,e){if(!e)return{...t};const i={...t};for(const r of e)Reflect.deleteProperty(i,r);return i}z(jf,"omit");function Pe(t,e,i){return Object.defineProperty(t,e,{writable:!0,value:i,enumerable:!1})}z(Pe,"defineProperty");function Uf(t,e){return e.every(i=>t.includes(i))}z(Uf,"contain");function Ff(t,e){return t.filter(i=>e.includes(i))}z(Ff,"intersection");function Bf(t,e){return t.filter(i=>!e.includes(i))}z(Bf,"difference");function qf(t,e){return Array.from(new Set([...t,...e]))}z(qf,"union");function Hf(t){return[...new Set(t)]}z(Hf,"deduplicate");function Mt(t,e){const i=t?.indexOf(e);return i>=0?(t.splice(i,1),!0):!1}z(Mt,"remove");function zf(t){return Array.isArray(t)?t:me(t)?[]:[t]}z(zf,"makeArray");function Dt(t,e){return arguments.length===1?i=>Dt(t,i):t in globalThis&&e instanceof globalThis[t]||Object.prototype.toString.call(e).slice(8,-1)===t}z(Dt,"is");function Bi(t){return Dt("ArrayBuffer",t)||Dt("SharedArrayBuffer",t)}z(Bi,"isArrayBufferLike");function sa(t){return Bi(t)||ArrayBuffer.isView(t)}z(sa,"isArrayBufferSource");var ft;(t=>{t.is=Bi,t.isSource=sa;function e(o){return ArrayBuffer.isView(o)?o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength):o}t.fromSource=e,z(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,z(i,"toBase64");function r(o){return typeof Buffer<"u"?e(Buffer.from(o,"base64")):Uint8Array.from(atob(o),a=>a.charCodeAt(0))}t.fromBase64=r,z(r,"fromBase64");function n(o){return typeof Buffer<"u"?Buffer.from(o).toString("hex"):Array.from(new Uint8Array(o),a=>a.toString(16).padStart(2,"0")).join("")}t.toHex=n,z(n,"toHex");function s(o){if(typeof Buffer<"u")return e(Buffer.from(o,"hex"));const a=o.length%2===0?o:o.slice(0,o.length-1),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,z(s,"fromHex")})(ft||(ft={})),ft.fromBase64,ft.toBase64,ft.fromHex,ft.toHex;function Rr(t,e=new Map){if(!t||typeof t!="object")return t;if(Dt("Date",t))return new Date(t.valueOf());if(Dt("RegExp",t))return new RegExp(t.source,t.flags);if(Bi(t))return t.slice(0);if(ArrayBuffer.isView(t))return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);const i=e.get(t);if(i)return i;if(Array.isArray(t)){const n=[];return e.set(t,n),t.forEach((s,o)=>{n[o]=Reflect.apply(Rr,null,[s,e])}),n}const r=Object.create(Object.getPrototypeOf(t));e.set(t,r);for(const n of Reflect.ownKeys(t)){const s={...Reflect.getOwnPropertyDescriptor(t,n)};"value"in s&&(s.value=Reflect.apply(Rr,null,[s.value,e])),Reflect.defineProperty(r,n,s)}return r}z(Rr,"clone");function Qt(t,e,i){if(t===e||!i&&me(t)&&me(e))return!0;if(typeof t!=typeof e||typeof t!="object"||!t||!e)return!1;function r(n,s){return n(t)?n(e)?s(t,e):!1:n(e)?!1:void 0}return z(r,"check"),r(Array.isArray,(n,s)=>n.length===s.length&&n.every((o,a)=>Qt(o,s[a])))??r(Dt("Date"),(n,s)=>n.valueOf()===s.valueOf())??r(Dt("RegExp"),(n,s)=>n.source===s.source&&n.flags===s.flags)??r(Bi,(n,s)=>{if(n.byteLength!==s.byteLength)return!1;const o=new Uint8Array(n),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(n=>Qt(t[n],e[n],i))}z(Qt,"deepEqual");function Kf(t){return t.charAt(0).toUpperCase()+t.slice(1)}z(Kf,"capitalize");function Wf(t){return t.charAt(0).toLowerCase()+t.slice(1)}z(Wf,"uncapitalize");function Vf(t){return t.replace(/[_-][a-z]/g,e=>e.slice(1).toUpperCase())}z(Vf,"camelCase");function Gn(t,e,i){const r=[];let n=0;for(let s=0;s<t.length;s++){const o=t.charCodeAt(s);if(o>=65&&o<=90){if(n===1){const a=t.charCodeAt(s+1);a>=97&&a<=122&&r.push(i),r.push(o+32)}else n!==0&&r.push(i),r.push(o+32);n=1}else o>=97&&o<=122?(r.push(o),n=2):e.includes(o)?(n!==0&&r.push(i),n=0):r.push(o)}return String.fromCharCode(...r)}z(Gn,"tokenize");function Gf(t){return Gn(t,[45,95],45)}z(Gf,"paramCase");function Yf(t){return Gn(t,[45,95],95)}z(Yf,"snakeCase");function Qf(t){return typeof t!="string"?`[${t.toString()}]`:/^[a-z_$][\w$]*$/i.test(t)?`.${t}`:`[${JSON.stringify(t)}]`}z(Qf,"formatProperty");function oa(t){return t.replace(/\/$/,"")}z(oa,"trimSlash");function Xf(t){return t.startsWith("/")||(t="/"+t),oa(t)}z(Xf,"sanitize");var aa;(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(m){e=m}t.setTimezoneOffset=i,z(i,"setTimezoneOffset");function r(){return e}t.getTimezoneOffset=r,z(r,"getTimezoneOffset");function n(m=new Date,d){return typeof m=="number"&&(m=new Date(m)),d===void 0&&(d=e),Math.floor((m.valueOf()/t.minute-d)/1440)}t.getDateNumber=n,z(n,"getDateNumber");function s(m,d){const _=new Date(m*t.day);return d===void 0&&(d=e),new Date(+_+d*t.minute)}t.fromDateNumber=s,z(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(m=>`(${o}${m})?`).join("")}$`);function l(m){const d=a.exec(m);return d?(parseFloat(d[1])*t.week||0)+(parseFloat(d[2])*t.day||0)+(parseFloat(d[3])*t.hour||0)+(parseFloat(d[4])*t.minute||0)+(parseFloat(d[5])*t.second||0):0}t.parseTime=l,z(l,"parseTime");function c(m){const d=l(m);return d?m=Date.now()+d:/^\d{1,2}(:\d{1,2}){1,2}$/.test(m)?m=`${new Date().toLocaleDateString()}-${m}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(m)&&(m=`${new Date().getFullYear()}-${m}`),m?new Date(m):new Date}t.parseDate=c,z(c,"parseDate");function u(m){const d=Math.abs(m);return d>=t.day-t.hour/2?Math.round(m/t.day)+"d":d>=t.hour-t.minute/2?Math.round(m/t.hour)+"h":d>=t.minute-t.second/2?Math.round(m/t.minute)+"m":d>=t.second?Math.round(m/t.second)+"s":m+"ms"}t.format=u,z(u,"format");function f(m,d=2){return m.toString().padStart(d,"0")}t.toDigits=f,z(f,"toDigits");function h(m,d=new Date){return m.replace("yyyy",d.getFullYear().toString()).replace("yy",d.getFullYear().toString().slice(2)).replace("MM",f(d.getMonth()+1)).replace("dd",f(d.getDate())).replace("hh",f(d.getHours())).replace("mm",f(d.getMinutes())).replace("ss",f(d.getSeconds())).replace("SSS",f(d.getMilliseconds(),3))}t.template=h,z(h,"template")})(aa||(aa={}));var Jf=Object.defineProperty,K=(t,e)=>Jf(t,"name",{value:e,configurable:!0}),M={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")},Zf=function*(){}.constructor,la=async function*(){}.constructor;function Yn(t){return!(!t.prototype||t instanceof Zf||la!==Function&&t instanceof la)}K(Yn,"isConstructor");function qi(t,e){const i=t.Config||t.schema;return i&&t.schema!==!1&&(e=i(e)),e??{}}K(qi,"resolveConfig");function ca(t){return[Map,Set,Date,Promise].some(e=>t instanceof e)}K(ca,"isUnproxyable");function Qn(t,e){if(t===Object.prototype)return e;const i=Object.create(Qn(Object.getPrototypeOf(t),e));for(const r of Reflect.ownKeys(t))Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r));return i}K(Qn,"joinPrototype");function Xn(t){return t&&(typeof t=="object"||typeof t=="function")}K(Xn,"isObject");function dt(t,e,i){if(!Xn(e))return e;if(Object.hasOwn(e,M.shadow))return Object.getPrototypeOf(e);const r=e[M.tracker];return r?Lr(t,e,r,i):e}K(dt,"getTraceable");function Hi(t,e){return e?new Proxy(t,{get:K((i,r,n)=>r in e&&r!=="constructor"?Reflect.get(e,r,n):Reflect.get(i,r,n),"get"),set:K((i,r,n,s)=>r in e&&r!=="constructor"?Reflect.set(e,r,n,s):Reflect.set(i,r,n,s),"set")}):t}K(Hi,"withProps");function Tr(t,e,i){return Hi(t,Object.defineProperty(Object.create(null),e,{value:i,writable:!1}))}K(Tr,"withProp");function Jn(t,e,i,r){if(!i)return r;const n=Reflect.getOwnPropertyDescriptor(e,i)?.value;return n?Tr(r,i,t.extend({[M.shadow]:n})):r}K(Jn,"createShadow");function ua(t,e,i,r){return new Proxy(e,{apply:K((n,s,o)=>(s===i&&(s=r),o=o.map(a=>typeof a!="function"||a[M.original]?a:new Proxy(a,{get:K((l,c,u)=>{if(c===M.original)return l;const f=Reflect.get(l,c,u);return c==="toString"&&f===Function.prototype.toString?function(...h){return Reflect.apply(f,this===u?l:this,h)}:f},"get"),apply:K((l,c,u)=>Reflect.apply(l,dt(t,c),u.map(f=>dt(t,f))),"apply"),construct:K((l,c,u)=>Reflect.construct(l,c.map(f=>dt(t,f)),u),"construct")})),dt(t,Reflect.apply(n,s,o))),"apply")})}K(ua,"createShadowMethod");function Lr(t,e,i,r){t[M.shadow]&&(t=Object.getPrototypeOf(t));const n=new Proxy(e,{get:K((s,o,a)=>{if(o===M.original)return s;if(o===i.property)return t;if(typeof o=="symbol")return Reflect.get(s,o,a);if(i.associate&&t[M.internal][`${i.associate}.${o}`])return Reflect.get(t,`${i.associate}.${o}`,Tr(t,M.receiver,a));const l=Jn(t,s,i.property,a),c=Reflect.get(s,o,l),u=c?.[M.tracker];return u?Lr(t,c,u):!r&&typeof c=="function"?ua(t,c,a,l):c},"get"),set:K((s,o,a,l)=>{if(o===M.original||o===i.property)return!1;if(typeof o=="symbol")return Reflect.set(s,o,a,l);if(i.associate&&t[M.internal][`${i.associate}.${o}`])return Reflect.set(t,`${i.associate}.${o}`,a,Tr(t,M.receiver,l));const c=Jn(t,s,i.property,l);return Reflect.set(s,o,a,c)},"set"),apply:K((s,o,a)=>Zn(n,s,o,a),"apply")});return n}K(Lr,"createTraceable");function Zn(t,e,i,r){return e[M.invoke]?e[M.invoke].apply(t,r):Reflect.apply(e,i,r)}K(Zn,"applyTraceable");function es(t,e,i){const r=K(function(...n){const s=Lr(r.ctx,r,i);return Zn(s,r,this,n)},"self");return Pe(r,"name",t),Object.setPrototypeOf(r,e)}K(es,"createCallable");var ed=(rt=class{constructor(e){this.ctx=e,Pe(this,M.tracker,{associate:"reflect",property:"ctx"}),this._mixin("reflect",["get","set","provide","accessor","mixin","alias"]),this._mixin("scope",["config","runtime","effect","collect","accept","decline"]),this._mixin("registry",["using","inject","plugin"]),this._mixin("lifecycle",["on","once","parallel","emit","serial","bail","start","stop"])}static resolveInject(e,i){let r=e[M.internal][i];for(;r?.type==="alias";)i=r.name,r=e[M.internal][i];return[i,r]}static checkInject(e,i,r){if(e=e[M.shadow]??e,["prototype","then","registry","lifecycle"].includes(i)||i[0]==="$"||i[0]==="_"||!e.runtime.plugin||e.bail(e,"internal/inject",i))return;const n=r.stack.split(`
2
+ `);n.splice(1,1),r.stack=n.join(`
3
+ `),e.emit(e,"internal/warning",r)}get(e){if(this.ctx[M.internal][e]?.type!=="service")return;const r=this.ctx[M.isolate][e],n=this.ctx[M.store][r]?.value;return dt(this.ctx,n)}set(e,i){this.provide(e);const r=this.ctx[M.isolate][e],n=this.ctx[M.store][r]?.value;i??(i=void 0);let s=K(()=>{},"dispose");if(n===i)return s;if(!me(i)&&!me(n))throw new Error(`service ${e} has been registered`);const o=this.ctx;me(i)||(s=o.effect(()=>()=>{o.set(e,void 0)})),ca(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[M.filter]=l=>o[M.isolate][e]===l[M.isolate][e],o.emit(a,"internal/before-service",e,i),o[M.store][r]={value:i,source:o},o.emit(a,"internal/service",e,n),s}provide(e,i,r){const n=this.ctx.root[M.internal];if(e in n)return;const s=Symbol(e);n[e]={type:"service",builtin:r},this.ctx.root[M.isolate][e]=s,Xn(i)&&(this.ctx[M.store][s]={value:i,source:null},Pe(i,M.tracker,{associate:e,property:"ctx"}))}_accessor(e,i){const r=this.ctx.root[M.internal];return e in r?()=>{}:(r[e]={type:"accessor",...i},()=>delete this.ctx.root[M.isolate][e])}accessor(e,i){this.ctx.scope.effect(()=>this._accessor(e,i))}alias(e,i){const r=this.ctx.root[M.internal];if(!(e in r))for(const n of i)r[n]||(r[n]={type:"alias",name:e})}_mixin(e,i){const r=Array.isArray(i)?i.map(o=>[o,o]):Object.entries(i),n=typeof e=="string"?o=>o[e]:()=>e,s=r.map(([o,a])=>this._accessor(a,{get(l){const c=n(this);if(me(c))return c;const u=l?Hi(l,c):c,f=Reflect.get(c,o,u);return typeof f!="function"?f:f.bind(u??c)},set(l,c){const u=n(this),f=c?Hi(c,u):u;return Reflect.set(u,o,l,f)}}));return()=>s.forEach(o=>o())}mixin(e,i){this.ctx.scope.effect(()=>this._mixin(e,i))}trace(e){return dt(this.ctx,e)}bind(e){return new Proxy(e,{apply:K((i,r,n)=>i.apply(this.trace(r),n.map(s=>this.trace(s))),"apply")})}},K(rt,"ReflectService"),U(rt,"handler",{get:K((e,i,r)=>{if(typeof i!="string")return Reflect.get(e,i,r);if(Reflect.has(e,i))return dt(r,Reflect.get(e,i,r),!0);const[n,s]=rt.resolveInject(e,i),o=new Error(`property ${n} is not registered, declare it as \`inject\` to suppress this warning`);return s?s.type==="accessor"?s.get.call(r,r[M.receiver]):(s.builtin||rt.checkInject(r,n,o),r.reflect.get(n)):(rt.checkInject(r,n,o),Reflect.get(e,n,r))},"get"),set:K((e,i,r,n)=>{if(typeof i!="string")return Reflect.set(e,i,r,n);const[s,o]=rt.resolveInject(e,i);return o?o.type==="accessor"?o.set?o.set.call(n,r,n[M.receiver]):!1:(n.reflect.set(s,r),!0):Reflect.set(e,s,r,n)},"set"),has:K((e,i)=>{if(typeof i!="string")return Reflect.has(e,i);if(Reflect.has(e,i))return!0;const[,r]=rt.resolveInject(e,i);return!!r},"has")}),rt),ts=ed;function is(t){return t!==null&&t!==!1&&t!==void 0}K(is,"isBailed");var td=(Li=class{constructor(e){U(this,"isActive",!1);U(this,"_tasks",new Set);U(this,"_hooks",{});this.ctx=e,Pe(this,M.tracker,{associate:"lifecycle",property:"ctx"}),Pe(this.on("internal/listener",function(r,n,s){const o=s.prepend?"unshift":"push";if(r==="ready")return this.lifecycle.isActive?(this.scope.ensure(async()=>n()),()=>!1):void 0;if(r==="dispose")return this.scope.disposables[o](n),Pe(n,"name","event <dispose>"),()=>Mt(this.scope.disposables,n);if(r==="fork")return this.scope.runtime.forkables[o](n),this.scope.collect("event <fork>",()=>Mt(this.scope.runtime.forkables,n))}),Le.static,e.scope);for(const r of["info","error","warning"])Pe(this.on(`internal/${r}`,(n,...s)=>{this._hooks[`internal/${r}`].length>1}),Le.static,e.scope);Pe(this.on("internal/before-service",function(r){for(const n of this.registry.values()){if(!n.inject[r]?.required)continue;const s=n.isReusable?n.children:[n];for(const o of s)this[M.filter](o.ctx)&&(o.updateStatus(),o.reset())}},{global:!0}),Le.static,e.scope),Pe(this.on("internal/service",function(r){for(const n of this.registry.values()){if(!n.inject[r]?.required)continue;const s=n.isReusable?n.children:[n];for(const o of s)this[M.filter](o.ctx)&&o.start()}},{global:!0}),Le.static,e.scope);const i=K((r,n)=>{if(!r.runtime.plugin)return!1;for(const s in r.runtime.inject)if(n===ts.resolveInject(r.ctx,s)[0])return!0;return i(r.parent.scope,n)},"checkInject");Pe(this.on("internal/inject",function(r){return i(this.scope,r)},{global:!0}),Le.static,e.scope)}async flush(){for(;this._tasks.size;)await Promise.all(Array.from(this._tasks))}filterHooks(e,i){return i=dt(this.ctx,i),e.slice().filter(r=>{const n=i?.[Le.filter];return r.global||!n||n.call(i,r.ctx)})}*dispatch(e,i){const r=typeof i[0]=="object"||typeof i[0]=="function"?i.shift():null,n=i.shift();n!=="internal/event"&&this.emit("internal/event",e,n,i,r);for(const s of this.filterHooks(this._hooks[n]||[],r))yield s.callback.apply(r,i)}async parallel(...e){await Promise.all(this.dispatch("emit",e))}emit(...e){Array.from(this.dispatch("emit",e))}async serial(...e){for await(const i of this.dispatch("serial",e))if(is(i))return i}bail(...e){for(const i of this.dispatch("bail",e))if(is(i))return i}register(e,i,r,n){const s=n.prepend?"unshift":"push";return i[s]({ctx:this.ctx,callback:r,...n}),this.ctx.state.collect(e,()=>this.unregister(i,r))}unregister(e,i){const r=e.findIndex(n=>n.callback===i);if(r>=0)return e.splice(r,1),!0}on(e,i,r){var a;typeof r!="object"&&(r={prepend:r}),this.ctx.scope.assertActive(),i=this.ctx.reflect.bind(i);const n=this.bail(this.ctx,"internal/listener",e,i,r);if(n)return n;const s=(a=this._hooks)[e]||(a[e]=[]),o=typeof e=="string"?`event <${e}>`:"event (Symbol)";return this.register(o,s,i,r)}once(e,i,r){const n=this.on(e,function(...s){return n(),i.apply(this,s)},r);return n}async start(){this.isActive=!0;const e=this._hooks.ready||[];for(;e.length;){const{ctx:i,callback:r}=e.shift();i.scope.ensure(async()=>r())}await this.flush()}async stop(){this.isActive=!1,this.ctx.scope.reset()}},K(Li,"Lifecycle"),Li),id=td,rs=(fi=class extends Error{constructor(e,i){super(i??fi.Code[e]),this.code=e}},K(fi,"CordisError"),fi);(t=>{t.Code={INACTIVE_EFFECT:"cannot create effect on inactive context"}})(rs||(rs={}));var fa=(Ni=class{constructor(e,i){U(this,"uid");U(this,"ctx");U(this,"disposables",[]);U(this,"error");U(this,"status",0);U(this,"isActive",!1);U(this,"context");U(this,"proxy");U(this,"acceptors",[]);U(this,"tasks",new Set);U(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:K((r,n)=>Reflect.get(this.config,n),"get")})}get _config(){return this.runtime.isReactive?this.proxy:this.config}assertActive(){if(!(this.uid!==null||this.isActive))throw new rs("INACTIVE_EFFECT")}effect(e,i){this.assertActive();const r=Yn(e)?new e(this.ctx,i):e(this.ctx,i);let n=!1;const s=typeof r=="function"?r:r.dispose.bind(r),o=K((...a)=>{if(!n)return n=!0,Mt(this.disposables,o),s(...a)},"wrapped");return this.disposables.push(o),typeof r=="function"?o:(r.dispose=o,r)}collect(e,i){const r=Pe(()=>(Mt(this.disposables,r),i()),"name",e);return this.disposables.push(r),r}restart(){this.reset(),this.error=null,this.hasError=!1,this.status=0,this.start()}_getStatus(){return this.uid===null?4:this.hasError?3:this.tasks.size?1:this.ready?2:0}updateStatus(e){const i=this.status;e?.(),this.status=this._getStatus(),i!==this.status&&this.context.emit("internal/status",this,i)}ensure(e){const i=e().catch(r=>{this.context.emit(this.ctx,"internal/error",r),this.cancel(r)}).finally(()=>{this.updateStatus(()=>this.tasks.delete(i)),this.context.events._tasks.delete(i)});this.updateStatus(()=>this.tasks.add(i)),this.context.events._tasks.add(i)}cancel(e){this.error=e,this.updateStatus(()=>this.hasError=!0),this.reset()}get ready(){return Object.entries(this.runtime.inject).every(([e,i])=>!i.required||!me(this.ctx.get(e)))}reset(){this.isActive=!1,this.disposables=this.disposables.splice(0).filter(e=>{if(this.uid!==null&&e[Le.static]===this)return!0;(async()=>e())().catch(i=>{this.context.emit(this.ctx,"internal/error",i)})})}init(e){this.config?this.start():this.cancel(e)}start(){if(!this.ready||this.isActive||this.uid===null)return!0;this.isActive=!0,this.updateStatus(()=>this.hasError=!1)}accept(...e){const r={keys:Array.isArray(e[0])?e.shift():null,callback:e[0],...e[1]};return this.effect(()=>(this.acceptors.push(r),r.immediate&&r.callback?.(this.config),()=>Mt(this.acceptors,r)))}decline(e){return this.accept(e,()=>!0)}checkUpdate(e,i){if(i||!this.config)return[!0,!0];if(i===!1)return[!1,!1];const r=Object.create(null),n=K(c=>{const u=r[c]??(r[c]=!Qt(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:f}of this.acceptors){if(!c)l||(l=!f);else if(f)c?.forEach(m=>s.add(m));else{let m=!1;for(const d of c)m||(m=n(d));if(!m)continue}u?.(e)&&(a=!0)}for(const c in{...this.config,...e})if(l!==!1&&!(c in r)&&!s.has(c)){const u=n(c);l===null&&(a||(a=u))}return[o,a]}},K(Ni,"EffectScope"),Ni),rd=(Mi=class extends fa{constructor(i,r,n,s){super(i,n);U(this,"dispose");this.runtime=r,this.dispose=Pe(i.scope.collect(`fork <${i.runtime.name}>`,()=>{this.uid=null,this.reset(),this.context.emit("internal/fork",this);const o=Mt(r.disposables,this.dispose);return Mt(r.children,this)&&!r.children.length&&i.registry.delete(r.plugin),o}),Le.static,r),r.children.push(this),r.disposables.push(this.dispose),this.context.emit("internal/fork",this),this.init(s)}start(){if(super.start())return!0;for(const i of this.runtime.forkables)this.ensure(async()=>i(this.context,this._config))}update(i,r){const n=this.config,s=this.runtime.isForkable?this:this.runtime;if(s.config!==n)return;let o;try{o=qi(this.runtime.plugin,i)}catch(c){return this.context.emit("internal/error",c),this.cancel(c)}const[a,l]=s.checkUpdate(o,r);this.context.emit("internal/before-update",this,i),this.config=o,s.config=o,a&&this.context.emit("internal/update",this,n),l&&s.restart()}},K(Mi,"ForkScope"),Mi),da=(Di=class extends fa{constructor(i,r,n,s){super(i,n);U(this,"value");U(this,"runtime",this);U(this,"schema");U(this,"name");U(this,"inject",Object.create(null));U(this,"forkables",[]);U(this,"children",[]);U(this,"isReusable",!1);U(this,"isReactive",!1);U(this,"apply",K((i,r)=>{if(typeof this.plugin!="function")return this.plugin.apply(i,r);if(Yn(this.plugin)){const n=new this.plugin(i,r),s=n[Le.expose];return s&&i.set(s,n),n.fork&&this.forkables.push(n.fork.bind(n)),n}else return this.plugin(i,r)},"apply"));this.plugin=r,r?(this.setup(),this.init(s)):(this.name="root",this.isActive=!0)}get isForkable(){return this.forkables.length>0}fork(i,r,n){return new rd(i,this,r,n)}dispose(){return this.uid=null,this.reset(),this.context.emit("internal/runtime",this),!0}setup(){const{name:i}=this.plugin;i&&i!=="apply"&&(this.name=i),this.schema=this.plugin.Config||this.plugin.schema,this.inject=ve.resolve(this.plugin.using||this.plugin.inject),this.isReusable=this.plugin.reusable,this.isReactive=this.plugin.reactive,this.context.emit("internal/runtime",this),this.isReusable&&this.forkables.push(this.apply)}reset(){super.reset();for(const i of this.children)i.reset()}start(){if(super.start())return!0;!this.isReusable&&this.plugin&&this.ensure(async()=>this.value=this.apply(this.ctx,this._config));for(const i of this.children)i.start()}update(i,r){if(this.isForkable){const 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 n=this.config;let s;try{s=qi(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,r),l=this.children.find(c=>c.config===n);this.config=s,l&&(this.context.emit("internal/before-update",l,i),l.config=s,o&&this.context.emit("internal/update",l,n)),a&&this.restart()}},K(Di,"MainScope"),Di);function ha(t){return t&&typeof t=="object"&&typeof t.apply=="function"}K(ha,"isApplicable");function ve(t){return function(e,i){if(i.kind==="class")e.inject=t;else if(i.kind==="method")i.addInitializer(function(){const r=this[M.tracker]?.property;if(!r)throw new Error("missing context tracker");this[r].inject(t,n=>{e.call(Hi(this,{[r]:n}))})});else throw new Error("@Inject can only be used on class or class methods")}}K(ve,"Inject"),(t=>{function e(i){if(!i)return{};if(Array.isArray(i))return Object.fromEntries(i.map(o=>[o,{required:!0}]));const{required:r,optional:n,...s}=i;return Array.isArray(r)&&Object.assign(s,Object.fromEntries(r.map(o=>[o,{required:!0}]))),Array.isArray(n)&&Object.assign(s,Object.fromEntries(n.map(o=>[o,{required:!1}]))),s}t.resolve=e,K(e,"resolve")})(ve||(ve={}));var nd=(ji=class{constructor(e,i){U(this,"_counter",0);U(this,"_internal",new Map);U(this,"context");this.ctx=e,Pe(this,M.tracker,{associate:"registry",property:"ctx"}),this.context=e;const r=new da(e,null,i);e.scope=r,r.ctx=e,this.set(null,r)}get counter(){return++this._counter}get size(){return this._internal.size}resolve(e,i=!1){if(e===null||typeof e=="function")return e;if(ha(e))return e.apply;if(i)throw new Error('invalid plugin, expect function or object with an "apply" method, received '+typeof e)}get(e){const i=this.resolve(e);return i&&this._internal.get(i)}has(e){const i=this.resolve(e);return!!i&&this._internal.has(i)}set(e,i){const r=this.resolve(e);this._internal.set(r,i)}delete(e){const i=this.resolve(e),r=i&&this._internal.get(i);if(r)return this._internal.delete(i),r.dispose(),r}keys(){return this._internal.keys()}values(){return this._internal.values()}entries(){return this._internal.entries()}forEach(e){return this._internal.forEach(e)}using(e,i){return this.inject(e,i)}inject(e,i){return this.plugin({inject:e,apply:i,name:i.name})}plugin(e,i,r){if(this.resolve(e,!0),this.ctx.scope.assertActive(),!r)try{i=qi(e,i)}catch(s){this.context.emit(this.ctx,"internal/error",s),r=s,i=null}let n=this.get(e);return n?(n.isForkable||this.context.emit(this.ctx,"internal/warning",new Error(`duplicate plugin detected: ${e.name}`)),n.fork(this.ctx,i,r)):(n=new da(this.ctx,e,i,r),this.set(e,n),n.fork(this.ctx,i,r))}},K(ji,"Registry"),ji),sd=nd,Le=(be=class{static is(e){return!!e?.[be.is]}static associate(e,i){return e}constructor(e){e=qi(this.constructor,e),this[M.store]=Object.create(null),this[M.isolate]=Object.create(null),this[M.internal]=Object.create(null),this[M.intercept]=Object.create(null);const i=new Proxy(this,ts.handler);i.root=i,i.reflect=new ts(i),i.registry=new sd(i,e),i.lifecycle=new id(i);const r=K(n=>{if(n){r(Object.getPrototypeOf(n));for(const s of Object.getOwnPropertyNames(n)){const o=n[s].prototype?.constructor;o&&(i[n[s].key]=new o(i,e),Pe(i[n[s].key],"ctx",i))}}},"attach");return r(this[M.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,M.shadow)?.value,r=Object.assign(Object.create(dt(this,this)),e);return i?Object.assign(Object.create(r),{[M.shadow]:i}):r}isolate(e,i){const r=Object.create(this[M.isolate]);return r[e]=i??Symbol(e),this.extend({[M.isolate]:r})}intercept(e,i){const r=Object.create(this[M.intercept]);return r[e]=i,this.extend({[M.intercept]:r})}},K(be,"Context"),U(be,"store",M.store),U(be,"events",M.events),U(be,"static",M.static),U(be,"filter",M.filter),U(be,"expose",M.expose),U(be,"isolate",M.isolate),U(be,"internal",M.internal),U(be,"intercept",M.intercept),U(be,"origin","ctx"),U(be,"current","ctx"),be.is[Symbol.toPrimitive]=()=>Symbol.for("cordis.is"),be.prototype[be.is]=!0,be);Le.prototype[Le.internal]=Object.create(null);var Pt=(Ye=class{constructor(...e){U(this,"ctx");U(this,"name");U(this,"config");let i,r,n,s;Le.is(e[0])?(i=e[0],typeof e[1]=="string"?(r=e[1],n=e[2]):s=e[1]):s=e[0],r??(r=this.constructor[M.provide]),n??(n=this.constructor[M.immediate]);let o=this;const a={associate:r,property:"ctx"};return o[M.invoke]&&(o=es(r,Qn(Object.getPrototypeOf(this),Function.prototype),a)),i?o.ctx=i:o[M.setup](),o.name=r,o.config=s,Pe(o,M.tracker,a),o.ctx.provide(r),o.ctx.runtime.name=r,n&&(i?o[M.expose]=r:o.ctx.set(r,o)),o.ctx.on("ready",async()=>{await Promise.resolve(),await o.start(),n||o.ctx.set(r,o)}),o.ctx.on("dispose",()=>o.stop()),o}start(){}stop(){}[M.filter](e){return e[M.isolate][this.name]===this.ctx[M.isolate][this.name]}[M.setup](){this.ctx=new Le}[M.extend](e){let i;return this[Ye.invoke]?i=es(this.name,this,this[M.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}},K(Ye,"Service"),U(Ye,"setup",M.setup),U(Ye,"invoke",M.invoke),U(Ye,"extend",M.extend),U(Ye,"tracker",M.tracker),U(Ye,"provide",M.provide),U(Ye,"immediate",M.immediate),Ye),od=Object.defineProperty,ad=Object.getOwnPropertyNames,J=(t,e)=>od(t,"name",{value:e,configurable:!0}),ld=(t,e)=>function(){return e||(0,t[ad(t)[0]])((e={exports:{}}).exports,e),e.exports},cd=ld({"src/index.ts"(t,e){var x;var i=Symbol.for("schemastery"),r=Symbol.for("ValidationError");globalThis.__schemastery_index__??(globalThis.__schemastery_index__=0);var n=(x=class extends TypeError{constructor(w,S){let C="$";for(const T of S.path||[])typeof T=="string"?C+="."+T:typeof T=="number"?C+="["+T+"]":typeof T=="symbol"&&(C+=`[Symbol(${T.toString()})]`);C.startsWith(".")&&(C=C.slice(1));super((C==="$"?"":`${C} `)+w);U(this,"name","ValidationError");this.options=S}static is(w){return!!w?.[r]}},J(x,"ValidationError"),x);Object.defineProperty(n.prototype,r,{value:!0});var s=J(function(y){const g=J(function(w,S={}){return s.resolve(w,g,S)[0]},"schema");if(y.refs){const w=$t(y.refs,C=>new s(C)),S=J(C=>w[C],"getRef");for(const C in w){const T=w[C];T.sKey=S(T.sKey),T.inner=S(T.inner),T.list=T.list&&T.list.map(S),T.dict=T.dict&&$t(T.dict,S)}return w[y.uid]}if(Object.assign(g,y),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=n;var o;s.prototype.toJSON=J(function(){var w;if(o)return o[w=this.uid]??(o[w]=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=J(function(g,w){return this.dict[g]=w,this},"set"),s.prototype.push=J(function(g){return this.list.push(g),this},"push");function a(y,g){const w=typeof y=="string"?{"":y}:{...y};for(const S in g){const C=g[S];C?.$description||C?.$desc?w[S]=C.$description||C.$desc:typeof C=="string"&&(w[S]=C)}return w}J(a,"mergeDesc");function l(y){return y?.$value??y?.$inner}J(l,"getInner");function c(y){return ra(y??{},g=>!g.startsWith("$"))}J(c,"extractKeys"),s.prototype.i18n=J(function(g){const w=s(this),S=a(w.meta.description,g);return Object.keys(S).length&&(w.meta.description=S),w.dict&&(w.dict=$t(w.dict,(C,T)=>C.i18n($t(g,B=>l(B)?.[T]??B?.[T])))),w.list&&(w.list=w.list.map((C,T)=>C.i18n($t(g,(B={})=>Array.isArray(l(B))?l(B)[T]:Array.isArray(B)?B[T]:c(B))))),w.inner&&(w.inner=w.inner.i18n($t(g,C=>l(C)?l(C):c(C)))),w.sKey&&(w.sKey=w.sKey.i18n($t(g,C=>C?.$key))),w},"i18n"),s.prototype.extra=J(function(g,w){const S=s(this);return S.meta={...S.meta,[g]:w},S},"extra");for(const y of["required","disabled","collapse","hidden","loose"])Object.assign(s.prototype,{[y](g=!0){const w=s(this);return w.meta={...w.meta,[y]:g},w}});s.prototype.deprecated=J(function(){var w;const g=s(this);return(w=g.meta).badges||(w.badges=[]),g.meta.badges.push({text:"deprecated",type:"danger"}),g},"deprecated"),s.prototype.experimental=J(function(){var w;const g=s(this);return(w=g.meta).badges||(w.badges=[]),g.meta.badges.push({text:"experimental",type:"warning"}),g},"experimental"),s.prototype.pattern=J(function(g){const w=s(this),S=na(g,["source","flags"]);return w.meta={...w.meta,pattern:S},w},"pattern"),s.prototype.simplify=J(function(g){if(Qt(g,this.meta.default,this.type==="dict"))return null;if(me(g))return g;if(this.type==="object"||this.type==="dict"){const w={};for(const S in g){const T=(this.type==="object"?this.dict[S]:this.inner)?.simplify(g[S]);(this.type==="dict"||!me(T))&&(w[S]=T)}return Qt(w,this.meta.default,this.type==="dict")?null:w}else if(this.type==="array"||this.type==="tuple"){const w=[];return g.forEach((S,C)=>{const T=this.type==="array"?this.inner:this.list[C],B=T?T.simplify(S):S;w.push(B)}),w}else if(this.type==="intersect"){const w={};for(const S of this.list)Object.assign(w,S.simplify(g));return w}else if(this.type==="union")for(const w of this.list)try{return s.resolve(g,w,{}),w.simplify(g)}catch{}return g},"simplify"),s.prototype.toString=J(function(g){return k[this.type]?.(this,g)??`Schema<${this.type}>`},"toString"),s.prototype.role=J(function(y,g){const w=s(this);return w.meta={...w.meta,role:y,extra:g},w},"role");for(const y of["default","link","comment","description","max","min","step"])Object.assign(s.prototype,{[y](g){const w=s(this);return w.meta={...w.meta,[y]:g},w}});var u={};s.extend=J(function(g,w){u[g]=w},"extend"),s.resolve=J(function(g,w,S={},C=!1){if(!w)return[g];if(S.ignore?.(g,w))return[g];if(me(g)&&w.type!=="lazy"){if(w.meta.required)throw new n("missing required value",S);let B=w,Y=w.meta.default;for(;B?.type==="intersect"&&me(Y);)B=B.list[0],Y=B?.meta.default;if(me(Y))return[g];g=Rr(Y)}const T=u[w.type];if(!T)throw new n(`unsupported type "${w.type}"`,S);try{return T(g,w,S,C)}catch(B){if(!w.meta.loose)throw B;return[w.meta.default]}},"resolve"),s.from=J(function(g){if(me(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=J(function(g){const w=J(()=>(S.inner[i]||(S.inner=S.builder(),S.inner.meta={...S.meta,...S.inner.meta}),S.inner.toJSON()),"toJSON"),S=new s({type:"lazy",builder:g,inner:{toJSON:w}});return S},"lazy"),s.natural=J(function(){return s.number().step(1).min(0)},"natural"),s.percent=J(function(){return s.number().step(.01).min(0).max(1).role("slider")},"percent"),s.date=J(function(){return s.union([s.is(Date),s.transform(s.string().role("datetime"),(g,w)=>{const S=new Date(g);if(isNaN(+S))throw new n(`invalid date "${g}"`,w);return S},!0)])},"date"),s.regExp=J(function(g=""){return s.union([s.is(RegExp),s.transform(s.string().role("regexp",{flag:g}),(w,S)=>{try{return new RegExp(w,g)}catch(C){throw new n(C.message,S)}},!0)])},"regExp"),s.arrayBuffer=J(function(g){return s.union([s.is(ArrayBuffer),s.is(SharedArrayBuffer),s.transform(s.any(),(w,S)=>{if(ft.isSource(w))return ft.fromSource(w);throw new n(`expected ArrayBufferSource but got ${w}`,S)},!0),...g?[s.transform(s.string(),(w,S)=>{try{return g==="base64"?ft.fromBase64(w):ft.fromHex(w)}catch(C){throw new n(C.message,S)}},!0)]:[]])},"arrayBuffer"),s.extend("lazy",(y,g,w,S)=>(g.inner[i]||(g.inner=g.builder(),g.inner.meta={...g.meta,...g.inner.meta}),s.resolve(y,g.inner,w,S))),s.extend("any",y=>[y]),s.extend("never",(y,g,w)=>{throw new n(`expected nullable but got ${y}`,w)}),s.extend("const",(y,{value:g},w)=>{if(Qt(y,g))return[g];throw new n(`expected ${g} but got ${y}`,w)});function f(y,g,w,S,C=!1){const{max:T=1/0,min:B=-1/0}=g;if(y>T)throw new n(`expected ${w} <= ${T} but got ${y}`,S);if(y<B&&!C)throw new n(`expected ${w} >= ${B} but got ${y}`,S)}J(f,"checkWithinRange"),s.extend("string",(y,{meta:g},w)=>{if(typeof y!="string")throw new n(`expected string but got ${y}`,w);if(g.pattern){const S=new RegExp(g.pattern.source,g.pattern.flags);if(!S.test(y))throw new n(`expect string to match regexp ${S}`,w)}return f(y.length,g,"string length",w),[y]});function h(y,g){const w=y.toString();if(w.includes("e"))return y*Math.pow(10,g);const S=w.indexOf(".");if(S===-1)return y*Math.pow(10,g);const C=w.slice(S+1),T=w.slice(0,S);return C.length<=g?+(T+C.padEnd(g,"0")):+(T+C.slice(0,g)+"."+C.slice(g))}J(h,"decimalShift");function m(y,g,w){if(w=Math.abs(w),!/^\d+\.\d+$/.test(w.toString()))return(y-g)%w===0;const S=w.toString().indexOf("."),C=w.toString().slice(S+1).length;return Math.abs(h(y,C)-h(g,C))%h(w,C)===0}J(m,"isMultipleOf"),s.extend("number",(y,{meta:g},w)=>{if(typeof y!="number")throw new n(`expected number but got ${y}`,w);f(y,g,"number",w);const{step:S}=g;if(S&&!m(y,g.min??0,S))throw new n(`expected number multiple of ${S} but got ${y}`,w);return[y]}),s.extend("boolean",(y,g,w)=>{if(typeof y=="boolean")return[y];throw new n(`expected boolean but got ${y}`,w)}),s.extend("bitset",(y,{bits:g,meta:w},S)=>{let C=0,T=[];if(typeof y=="number"){C=y;for(const B in g)y&g[B]&&T.push(B)}else if(Array.isArray(y)){T=y;for(const B of T){if(typeof B!="string")throw new n(`expected string but got ${B}`,S);B in g&&(C|=g[B])}}else throw new n(`expected number or array but got ${y}`,S);return C===w.default?[C]:[C,T]}),s.extend("function",(y,g,w)=>{if(typeof y=="function")return[y];throw new n(`expected function but got ${y}`,w)}),s.extend("is",(y,{constructor:g},w)=>{if(typeof g=="function"){if(y instanceof g)return[y];throw new n(`expected ${g.name} but got ${y}`,w)}else{if(me(y))throw new n(`expected ${g} but got ${y}`,w);let S=Object.getPrototypeOf(y);for(;S;){if(S.constructor?.name===g)return[y];S=Object.getPrototypeOf(S)}throw new n(`expected ${g} but got ${y}`,w)}});function d(y,g,w,S){try{const[C,T]=s.resolve(y[g],w,{...S,path:[...S.path||[],g]});return T!==void 0&&(y[g]=T),C}catch(C){if(!S?.autofix)throw C;return delete y[g],w.meta.default}}J(d,"property"),s.extend("array",(y,{inner:g,meta:w},S)=>{if(!Array.isArray(y))throw new n(`expected array but got ${y}`,S);return f(y.length,w,"array length",S,!me(g.meta.default)),[y.map((C,T)=>d(y,T,g,S))]}),s.extend("dict",(y,{inner:g,sKey:w},S,C)=>{if(!Or(y))throw new n(`expected object but got ${y}`,S);const T={};for(const B in y){let Y;try{Y=s.resolve(B,w,S)[0]}catch(Yt){if(C)continue;throw Yt}T[Y]=d(y,B,g,S),y[Y]=y[B],B!==Y&&delete y[B]}return[T]}),s.extend("tuple",(y,{list:g},w,S)=>{if(!Array.isArray(y))throw new n(`expected array but got ${y}`,w);const C=g.map((T,B)=>d(y,B,T,w));return S?[C]:(C.push(...y.slice(g.length)),[C])});function _(y,g){for(const w in g)w in y||(y[w]=g[w])}J(_,"merge"),s.extend("object",(y,{dict:g},w,S)=>{if(!Or(y))throw new n(`expected object but got ${y}`,w);const C={};for(const T in g){const B=d(y,T,g[T],w);(!me(B)||T in y)&&(C[T]=B)}return S||_(C,y),[C]}),s.extend("union",(y,{list:g,toString:w},S,C)=>{for(const T of g)try{return s.resolve(y,T,S,C)}catch{}throw new n(`expected ${w()} but got ${JSON.stringify(y)}`,S)}),s.extend("intersect",(y,{list:g,toString:w},S,C)=>{if(!g.length)return[y];let T;for(const B of g){const Y=s.resolve(y,B,S,!0)[0];if(!me(Y))if(me(T))T=Y;else{if(typeof T!=typeof Y)throw new n(`expected ${w()} but got ${JSON.stringify(y)}`,S);if(typeof Y=="object")_(T??(T={}),Y);else if(T!==Y)throw new n(`expected ${w()} but got ${JSON.stringify(y)}`,S)}}return!C&&Or(y)&&_(T,y),[T]}),s.extend("transform",(y,{inner:g,callback:w,preserve:S},C)=>{const[T,B=y]=s.resolve(y,g,C,!0);return S?[w(T)]:[w(T),w(B)]});var k={};function E(y,g,w){k[y]=w,Object.assign(s,{[y](...S){const C=new s({type:y});return g.forEach((T,B)=>{switch(T){case"sKey":C.sKey=S[B]??s.string();break;case"inner":C.inner=s.from(S[B]);break;case"list":C.list=S[B].map(s.from);break;case"dict":C.dict=$t(S[B],s.from);break;case"bits":{C.bits={};for(const Y in S[B])typeof S[B][Y]=="number"&&(C.bits[Y]=S[B][Y]);break}case"callback":{const Y=C.callback=S[B];Y.toJSON||(Y.toJSON=()=>Y.toString());break}case"constructor":{const Y=C.constructor=S[B];typeof Y=="function"&&(Y.toJSON||(Y.toJSON=()=>Y.name));break}default:C[T]=S[B]}}),y==="object"||y==="dict"?C.meta.default={}:y==="array"||y==="tuple"?C.meta.default=[]:y==="bitset"&&(C.meta.default=0),C}})}J(E,"defineMethod"),E("is",["constructor"],({constructor:y})=>typeof y=="function"?y.name:y),E("any",[],()=>"any"),E("never",[],()=>"never"),E("const",["value"],({value:y})=>typeof y=="string"?JSON.stringify(y):y),E("string",[],()=>"string"),E("number",[],()=>"number"),E("boolean",[],()=>"boolean"),E("bitset",["bits"],()=>"bitset"),E("function",[],()=>"function"),E("array",["inner"],({inner:y})=>`${y.toString(!0)}[]`),E("dict",["inner","sKey"],({inner:y,sKey:g})=>`{ [key: ${g.toString()}]: ${y.toString()} }`),E("tuple",["list"],({list:y})=>`[${y.map(g=>g.toString()).join(", ")}]`),E("object",["dict"],({dict:y})=>Object.keys(y).length===0?"{}":`{ ${Object.entries(y).map(([g,w])=>`${g}${w.meta.required?"":"?"}: ${w.toString()}`).join(", ")} }`),E("union",["list"],({list:y},g)=>{const w=y.map(({toString:S})=>S()).join(" | ");return g?`(${w})`:w}),E("intersect",["list"],({list:y})=>`${y.map(g=>g.toString(!0)).join(" & ")}`),E("transform",["inner","callback","preserve"],({inner:y},g)=>y.toString(g)),e.exports=s}});const L=cd();var ns=(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))(ns||{});const ss=globalThis||window,os=Symbol.for("__IPE_LOGGER_COLOR_MAP__");ss[os]||(ss[os]=new Map);const as=ss[os];function Nr(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i),e=(e>>>0)*16777619;return e>>>0}const pa=[[350,360],[0,15],[15,30],[200,230],[230,250],[250,280],[280,310],[310,330],[140,160],[160,180]];function ud(t,e){const i=pa.length,r=Nr(t)%i,[n,s]=pa[r],o=s-n,a=Nr(t+":"+e),l=n+a%(o||1),c=Nr(t+":s"),u=Nr(t+":l");let f,h;if(e==="name")f=62+c%18,h=30+u%12;else{const m=l>=0&&l<50||l>330&&l<360,d=l>=200&&l<=300;f=55+c%20,d?h=55+u%8:m?h=48+u%6:h=50+u%8,f<60&&(f+=5)}return`hsl(${l}, ${f}%, ${h}%)`}function Mr(t,e){if(e)return as.set(t,e),e;const i=as.get(t);if(i)return i;const r=t.startsWith("name:")?"name":"group",n=ud(t,r);return as.set(t,n),n}let ma=class Ef{constructor(e={}){this._custom=i=>{if(!this._enabled(i.level))return ga;const[r,n]=this._prefix(i.label);return this._consoleMethod(i.method).bind(console,r,...n)},this._name=e.name,this._nameColor=e.color,this._groupPath=e._groupPath?[...e._groupPath]:[],this._dynamicLevels={...e._dynamicLevels},this._levelRef=e._levelRef??{value:e.level??1},this._name&&Mr(`name:${this._name}`,this._nameColor),this._installBuiltinLevels();for(const i of Object.keys(this._dynamicLevels))this._installLevelGetter(i,this._dynamicLevels[i]);return dd(this)}get level(){return this._levelRef.value}set level(e){this._levelRef.value=e}group(e,i){return e&&Mr(`group:${e}`,i?.color),new Ef({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=fd[e];if(!this._enabled(i.level))return ga;const[r,n]=this._prefix(i.label);return this._consoleMethod(e).bind(console,r,...n)}_consoleMethod(e){return(console[e]||console.log).bind(console)}_enabled(e){return e>=this._levelRef.value&&this._levelRef.value!==4}_prefix(e){const i=[];let r="";if(this._name){const n=Mr(`name:${this._name}`,this._nameColor);r+=`%c${this._name}%c`,i.push(`background:${n}; color:#fff; padding:1px 4px; border-radius:2px; font-weight:700;`,ya)}if(e&&(r+=` ${e}`),this._groupPath.length){const n=this._groupPath.join("/"),s=Mr(`group:${n}`);r+=` %c${n}%c`,i.push(`color:${s}; text-decoration: underline;`,ya)}return[r,i]}};const ga=()=>{},ya="color:inherit; background:transparent; text-decoration:none;",fd={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 dd(t){const e=function(i,r){return t.group(i,r)};return new Proxy(e,{get(i,r,n){return t[r]},set(i,r,n){return t[r]=n,!0},apply(i,r,n){return t.group(n[0],n[1])},has(i,r){return r in t}})}function ba(t){return new ma(t)}var Ke=(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))(Ke||{});let Ne=class $f extends Error{constructor(i,r,n,s){super(r,s);U(this,"name","FexiosError");this.code=i,this.context=n}static is(i){return i?.constructor===$f}},hd=class Pf extends Ne{constructor(i,r,n){super(r.statusText,i,void 0,n);U(this,"name","FexiosResponseError");this.response=r}static is(i){return i?.constructor===Pf}};function pd(t,e=2048){if(!(t instanceof Uint8Array))throw new TypeError("Input must be a Uint8Array");if(t.length===0)return!0;const i=Math.min(Math.max(t.length,256),e),r=t.slice(0,i);if(md(r))return!1;const n=gd(r);if(n.nullByteRatio>.05||n.highByteRatio>.95)return!1;const s=["utf-8","utf-16le","utf-16be","iso-8859-1"];let o=-1,a=!1;for(const l of s)try{const c=new TextDecoder(l,{fatal:!0}).decode(r),u=yd(c);u>o&&(o=u,a=u>.7)}catch{continue}return a}function md(t){if(t.length<4)return!1;const e=[[137,80,78,71],[255,216,255],[71,73,70],[37,80,68,70],[80,75,3,4],[80,75,5,6],[80,75,7,8],[127,69,76,70],[77,90],[202,254,186,190],[0,0,1,0],[82,73,70,70]];for(const i of e)if(t.length>=i.length){let r=!0;for(let n=0;n<i.length;n++)if(t[n]!==i[n]){r=!1;break}if(r)return!0}return!1}function gd(t){let e=0,i=0,r=0;for(const n of t)n===0&&e++,n>127&&i++,(n<32&&n!==9&&n!==10&&n!==13||n===127)&&r++;return{nullByteRatio:e/t.length,highByteRatio:i/t.length,controlCharRatio:r/t.length}}function yd(t){if(t.length===0)return 1;let e=1,i=0;for(let n=0;n<t.length;n++){const s=t[n].charCodeAt(0);s>=32&&s<=126||s===9||s===10||s===13||s===32?i++:s>127&&s<65534?!bd(s)&&!wd(s)&&i++:e-=.1}const r=i/t.length;return e*=r,vd(t)&&(e*=1.1),Math.max(0,Math.min(1,e))}function bd(t){return t>=0&&t<=31||t>=127&&t<=159}function wd(t){return t>=57344&&t<=63743||t>=983040&&t<=1048573||t>=1048576&&t<=1114109}function vd(t){return[/\b\w+\b/,/[.!?]+\s/,/\s+/,/[a-zA-Z]{3,}/,/[\u4e00-\u9fa5]+/,/\d+/].some(e=>e.test(t))}function st(t){if(typeof t!="object"||t===null||Object.prototype.toString.call(t)!=="[object Object]")return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}const zi=(t,...e)=>{const i=n=>{if(Array.isArray(n))return n.slice();if(st(n)){const s={};for(const o of Reflect.ownKeys(n))s[o]=i(n[o]);return s}return n},r=i(t);for(const n of e)if(n!=null)for(const s of Reflect.ownKeys(n)){const o=n[s];if(typeof o>"u")continue;const a=r[s];st(a)&&st(o)?r[s]=zi(a,o):r[s]=i(o)}return r};let Ki=class{constructor(e,i,r){U(this,"ok");U(this,"status");U(this,"statusText");U(this,"headers");this.rawResponse=e,this.data=i,this.ok=e.ok,this.status=e.status,this.statusText=e.statusText,this.headers=e.headers,Object.entries(r||{}).forEach(([n,s])=>{this[n]=s})}};async function wa(t,e,i){if(t.bodyUsed)throw new Ne(Ke.BODY_USED,"Response body has already been used or locked");const r=t.headers.get("content-type")||"",n=Number(t.headers.get("content-length"))||0,s=(a,l)=>l==="json"||a.startsWith("application/json"),o=(a,l,c)=>c==="blob"||a.startsWith("image/")&&!a.startsWith("image/svg")||a.startsWith("video/")||a.startsWith("audio/")||!pd(l);if((t.status===101||t.status===426||t.headers.get("upgrade"))&&typeof globalThis.WebSocket<"u"){const a=new WebSocket(t.url);return await new Promise((l,c)=>{a.onopen=l,a.onerror=c}),new Ki(t,a,{ok:!0,status:101,statusText:"Switching Protocols"})}else if(r.startsWith("text/event-stream")&&!["text","json"].includes(e||"")&&typeof globalThis.EventSource<"u"){const a=new EventSource(t.url);return await new Promise((l,c)=>{a.onopen=l,a.onerror=c}),new Ki(t,a)}else{if(e==="stream")return new Ki(t,t.body);{const a=t.clone().body?.getReader();if(!a)throw new Ne(Ke.NO_BODY_READER,"Failed to get ReadableStream from response body");let l=new Uint8Array;for(;;){const{done:u,value:f}=await a.read();if(u)break;if(f&&(l=new Uint8Array([...l,...f]),i&&n>0)){const h=Math.min(l.length/n,1);i(h,l)}}const c=new Ki(t,void 0);if(e==="arrayBuffer")return c.data=l.buffer,c;if(s(r,e))try{const u=new TextDecoder().decode(l);c.data=JSON.parse(u)}catch{}if(typeof c.data!="string"&&o(r,l,e)?c.data=new Blob([l],{type:t.headers.get("content-type")||void 0}):c.data=new TextDecoder().decode(l),typeof c.data=="string"&&e!=="text"){const u=c.data.trim(),f=u[0],h=u[u.length-1];if(f==="{"&&h==="}"||f==="["&&h==="]")try{c.data=JSON.parse(c.data)}catch{}}if(typeof c.data>"u"&&(c.data=l.length>0?l:void 0),c.ok)return c;throw new hd(`Request failed with status code ${t.status}`,c)}}}var Dr;(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 s=new URLSearchParams,o=(c,u)=>{u!=null&&s.append(c,u)},a=(c,u)=>{u!=null&&s.set(c,u)},l=(c,u)=>{if(u!=null){if(Array.isArray(u)){for(const f of u)o(c,f?.toString());return}if(typeof u=="object"&&u.constructor===Object){for(const[f,h]of Object.entries(u)){if(h==null)continue;const m=f.endsWith("[]"),d=m?f.slice(0,-2):f,_=`${c}[${d}]`;if(m){const k=`${_}[]`;if(Array.isArray(h))for(const E of h)o(k,E?.toString());else typeof h=="object"&&h!==null&&h.constructor===Object?l(`${_}[]`,h):o(k,h?.toString())}else if(Array.isArray(h))for(const k of h)o(_,k?.toString());else typeof h=="object"&&h!==null&&h.constructor===Object?l(_,h):a(_,h?.toString())}return}a(c,u?.toString())}};for(const[c,u]of Object.entries(n))l(c,u);return s},t.makeQueryString=n=>(0,t.makeSearchParams)(n).toString(),t.makeURL=(n,s,o,a)=>{const l=typeof window<"u"&&window.location?.origin||"http://localhost",c=typeof n=="string"?new URL(n,a??l):new URL(n),u=(0,t.toQueryRecord)(c.searchParams),f=(0,t.mergeQueries)(u,s||{}),h=(0,t.makeSearchParams)(f);return c.search=h.toString(),c.hash=o||"",c},t.toQueryRecord=n=>{typeof n=="string"&&(n=(0,t.fromString)(n));const s={},o=l=>{if(!l.includes("["))return{path:[l],forceArray:!1};const c=[l.slice(0,l.indexOf("["))],u=/\[([^\]]*)\]/g;let f,h=!1,m=!1;for(;f=u.exec(l);)f[1]===""?(h=!0,m=!0):(c.push(f[1]),m=!1);return h&&m&&(c[c.length-1]=c[c.length-1]+"[]"),{path:c,forceArray:h}},a=(l,c,u,f)=>{let h=l;for(let m=0;m<c.length;m++){const d=c[m];m===c.length-1?f?h[d]===void 0?h[d]=[u]:Array.isArray(h[d])?h[d].push(u):h[d]=[h[d],u]:h[d]===void 0?h[d]=u:Array.isArray(h[d])?h[d].push(u):h[d]=[h[d],u]:((h[d]===void 0||typeof h[d]!="object"||Array.isArray(h[d]))&&(h[d]={}),h=h[d])}};for(const[l,c]of n.entries()){const{path:u,forceArray:f}=o(String(l));a(s,u,c?.toString(),f)}return s},t.fromString=n=>{const s=n.trim();if(!s)return new URLSearchParams;if(s.startsWith("?"))return new URLSearchParams(s.slice(1));const o=s.indexOf("?");if(o>=0){const a=s.indexOf("#",o+1),l=s.slice(o+1,a>=0?a:void 0);return new URLSearchParams(l)}return new URLSearchParams(s)},t.mergeQueries=(n,...s)=>{const o=e(i(n));for(const a of s)a!=null&&r(o,i(a));return o};function e(n){if(Array.isArray(n))return n.map(e);if(st(n)){const s={};for(const[o,a]of Object.entries(n))s[o]=e(a);return s}if(n instanceof Map){const s={};for(const[o,a]of n.entries())s[o]=e(a);return s}return n}function i(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(st(n))return n;throw new TypeError(`unsupported type transformation, got: ${Object.prototype.toString.call(n)}`)}function r(n,s){for(const[o,a]of Object.entries(s)){if(a===void 0)continue;if(a===null){delete n[o];continue}const l=n[o];st(l)&&st(a)?r(l,a):n[o]=e(a)}}})(Dr||(Dr={}));const va=function(t){const e=this.constructor.prototype,i=Reflect.get(e,t,e);function r(...n){return Reflect.apply(i,r,n)}Reflect.setPrototypeOf(r,e);for(const n of Reflect.ownKeys(i)){const s=Reflect.getOwnPropertyDescriptor(i,n);s&&Reflect.defineProperty(r,n,s)}return r};va.prototype=Object.create(Function.prototype);var Wi;(t=>{t.makeHeaders=e=>{if(!e)return new Headers;if(e instanceof Headers)return new Headers(e);const i=new Headers;if(e instanceof Map){for(const[r,n]of e.entries())if(n!=null)if(Array.isArray(n))for(const s of n)s!=null&&i.append(r,String(s));else i.append(r,String(n));return i}if(st(e)){for(const[r,n]of Object.entries(e))if(n!=null)if(Array.isArray(n))for(const s of n)s!=null&&i.append(r,String(s));else i.append(r,String(n));return i}throw new TypeError("only plain object, Map/ReadonlyMap, or Headers is supported")},t.toHeaderRecord=e=>{if(e instanceof Headers){const i={};return e.forEach((r,n)=>{i[n]=i[n]?[...i[n],r]:[r]}),i}if(e instanceof Map){const i={};for(const[r,n]of e.entries())if(n!=null)if(Array.isArray(n)){const s=n.filter(o=>o!=null).map(o=>String(o));s.length&&(i[r]=(i[r]??[]).concat(s))}else{const s=String(n);i[r]=i[r]?[...i[r],s]:[s]}return i}throw new TypeError(`unsupported type transformation, got: ${Object.prototype.toString.call(e)}`)},t.mergeHeaders=(e,...i)=>{const r=e instanceof Headers?new Headers(e):(0,t.makeHeaders)(e),n=s=>{for(const[o,a]of Object.entries(s))if(a!==void 0){if(a===null){r.delete(o);continue}if(Array.isArray(a)){r.delete(o);for(const l of a)l!=null&&r.append(o,String(l))}else r.set(o,String(a))}};for(const s of i){if(s==null)continue;if(s instanceof Headers){s.forEach((a,l)=>{r.set(l,a)});continue}if(st(s)){n(s);continue}const o=(0,t.toHeaderRecord)(s);for(const[a,l]of Object.entries(o)){r.delete(a);for(const c of l)r.append(a,c)}}return r}})(Wi||(Wi={}));let ls=(ae=class extends va{constructor(i={}){super("request");U(this,"baseConfigs");U(this,"hooks",[]);U(this,"mergeQueries",Dr.mergeQueries);U(this,"mergeHeaders",Wi.mergeHeaders);U(this,"interceptors",{request:this.createInterceptor("beforeRequest"),response:this.createInterceptor("afterResponse")});U(this,"create",ae.create);U(this,"_plugins",new Map);U(this,"checkIsPlainObject",st);U(this,"mergeQuery",this.mergeQueries);this.baseConfigs=zi(ae.DEFAULT_CONFIGS,i),ae.ALL_METHODS.forEach(r=>this.createMethodShortcut(r.toLowerCase()))}async request(i,r){let n=r=r||{};if(typeof i=="string"||i instanceof URL?n.url=i.toString():typeof i=="object"&&(n=zi(i,n)),n=await this.emit("beforeInit",n,{shouldAdjustRequestParams:!0,shouldHandleShortCircuitResponse:!0}),n[ae.FINAL_SYMBOL])return n;if(ae.METHODS_WITHOUT_BODY.includes(n.method?.toLocaleLowerCase())&&n.body)throw new Ne(Ke.BODY_NOT_ALLOWED,`Request method "${n.method}" does not allow body`);if(n=await this.emit("beforeRequest",n,{shouldAdjustRequestParams:!0,shouldHandleShortCircuitResponse:!0,preAdjust:!0,requestOptionsOverridesURLSearchParams:!0,preRequestOptionsOverridesURLSearchParams:!0,postRequestOptionsOverridesURLSearchParams:!0}),n[ae.FINAL_SYMBOL])return n;let s;const o={};if(typeof n.body<"u"&&n.body!==null&&(n.body instanceof Blob||n.body instanceof FormData||n.body instanceof URLSearchParams?s=n.body:typeof n.body=="object"&&n.body!==null?(s=JSON.stringify(n.body),n.headers=this.mergeHeaders(n.headers,{"Content-Type":"application/json"})):s=n.body),!Wi.makeHeaders(r.headers||{}).get("content-type")&&s&&(s instanceof FormData||s instanceof URLSearchParams?o["content-type"]=null:typeof s=="string"&&typeof n.body=="object"?o["content-type"]="application/json":s instanceof Blob&&(o["content-type"]=s.type||"application/octet-stream")),n.body=s,n=await this.emit("afterBodyTransformed",n,{shouldAdjustRequestParams:!0,shouldHandleShortCircuitResponse:!0,preAdjust:!0,postRequestOptionsOverridesURLSearchParams:!0}),n[ae.FINAL_SYMBOL])return n;const a=n.abortController||globalThis.AbortController?new AbortController:void 0,l=n.baseURL||this.baseConfigs.baseURL||globalThis.location?.href||"http://localhost",c=new URL(n.url.toString(),l),u=Dr.makeURL(c,n.query,c.hash).toString(),f=new Request(u,{method:n.method||"GET",credentials:n.credentials,cache:n.cache,mode:n.mode,headers:Wi.mergeHeaders(this.baseConfigs.headers,n.headers||{},o),body:n.body,signal:a?.signal});if(n.rawRequest=f,n=await this.emit("beforeActualFetch",n,{shouldHandleShortCircuitResponse:!0}),n[ae.FINAL_SYMBOL])return n;const h=n.timeout||this.baseConfigs.timeout||60*1e3;if(n.url.startsWith("ws"))try{const d=new WebSocket(n.url);return await new Promise((_,k)=>{const E=setTimeout(()=>{k(new Ne(Ke.TIMEOUT,`WebSocket connection timed out after ${h}ms`,n))},h);d.onopen=()=>{clearTimeout(E),_()},d.onerror=x=>{clearTimeout(E),k(new Ne(Ke.NETWORK_ERROR,"WebSocket connection failed",n))},d.onclose=x=>{x.code!==1e3&&(clearTimeout(E),k(new Ne(Ke.NETWORK_ERROR,`WebSocket closed with code ${x.code}`,n)))}}),n.rawResponse=new Response,n.response=new Ki(n.rawResponse,d,{ok:!0,status:101,statusText:"Switching Protocols"}),n.data=d,n.headers=new Headers,this.emit("afterResponse",n)}catch(d){throw d instanceof Ne?d:new Ne(Ke.NETWORK_ERROR,`WebSocket creation failed: ${d}`,n)}let m;try{a&&(m=setTimeout(()=>{a.abort()},h));const d=await(r.fetch||this.baseConfigs.fetch||globalThis.fetch)(n.rawRequest).catch(_=>{throw m&&clearTimeout(m),a?.signal.aborted?new Ne(Ke.TIMEOUT,`Request timed out after ${h}ms`,n):new Ne(Ke.NETWORK_ERROR,_.message,n)});return m&&clearTimeout(m),n.rawResponse=d,n.response=await wa(d,n.responseType,(_,k)=>{r?.onProgress?.(_,k)}),n.data=n.response.data,n.headers=n.response.headers,this.emit("afterResponse",n)}catch(d){throw m&&clearTimeout(m),d}}normalizeContext(i,r={}){const n=i,s=n.baseURL||this.baseConfigs.baseURL||globalThis.location?.href||"http://localhost",o=new URL(s,globalThis.location?.href||"http://localhost"),a=new URL(n.url.toString(),o),l=!!n[ae.NORMALIZED_SYMBOL];n.baseURL=o?o.origin:a.origin;let c;l?c=r.requestOptionsOverridesURLSearchParams?this.mergeQueries({},a.search,n.query):this.mergeQueries({},n.query,a.search):(c=r.requestOptionsOverridesURLSearchParams?this.mergeQueries(o?.search||"",this.baseConfigs.query,a.search,n.query):this.mergeQueries(o?.search||"",this.baseConfigs.query,n.query,a.search),n[ae.NORMALIZED_SYMBOL]=!0),n.query=c;const u=new URL(a);return u.search="",n.url=u.toString(),n}async emit(i,r,n={}){const s=this.hooks.filter(o=>o.event===i);if(n?.shouldAdjustRequestParams&&n?.preAdjust)try{r=this.normalizeContext(r,{requestOptionsOverridesURLSearchParams:n.preRequestOptionsOverridesURLSearchParams})}catch{}try{let o=0;for(const a of s){const l=`${i}#${a.action.name||`anonymous#${o}`}`,c=Symbol("FEXIOS_HOOK_CONTEXT");r[c]=c;const u=r.url;let f="";try{const m=this.mergeQueries({},r.query||{});f=JSON.stringify(m)}catch{}let h=await a.action.call(this,r);if(h===void 0&&(h=r),h===!1)throw new Ne(Ke.ABORTED_BY_HOOK,`Request aborted by hook "${l}"`,r);if(h instanceof Response){const m=h,d={...r,rawResponse:m},_=await wa(m,r.responseType,(k,E)=>{r.onProgress?.(k,E)});if(d.response=_,d.data=_.data,d.headers=_.headers,i!=="afterResponse"){const k=await this.emit("afterResponse",d);return k[ae.FINAL_SYMBOL]=!0,k}else return d[ae.FINAL_SYMBOL]=!0,d}else if(typeof h=="object"&&h[c]===c)r=h;else{const m=globalThis["".concat("console")];try{throw new Ne(Ke.HOOK_CONTEXT_CHANGED,`Hook "${l}" should return the original FexiosContext or return false to abort the request, but got "${h}".`)}catch(d){m.warn(d.stack||d)}}if(n?.shouldAdjustRequestParams)try{const m=r.baseURL||this.baseConfigs.baseURL||globalThis.location?.href||"http://localhost",d=new URL(r.url.toString(),m);let _={};if(f)try{_=JSON.parse(f)}catch{}const k=r.query||{},E=this.mergeQueries(_,d.search,k);r.query=E;const x=new URL(d);x.search="",r.url=x.toString()}catch{}delete r[c],o++}}catch(o){return Promise.reject(o)}return r}on(i,r,n=!1){if(typeof r!="function")throw new Ne(Ke.INVALID_HOOK_CALLBACK,`Hook should be a function, but got "${typeof r}"`);return this.hooks[n?"unshift":"push"]({event:i,action:r}),this}off(i,r){return i==="*"||!i?this.hooks=this.hooks.filter(n=>n.action!==r):this.hooks=this.hooks.filter(n=>n.event!==i||n.action!==r),this}createInterceptor(i){return{handlers:()=>this.hooks.filter(r=>r.event===i).map(r=>r.action),use:(r,n=!1)=>this.on(i,r,n),clear:()=>{this.hooks=this.hooks.filter(r=>r.event!==i)}}}createMethodShortcut(i){return Reflect.defineProperty(this,i,{get:()=>(r,n,s)=>(ae.METHODS_WITHOUT_BODY.includes(i.toLocaleLowerCase())?s=n:(s=s||{},s.body=n),this.request(r,{...s,method:i}))}),this}extends(i){const r=new ae(zi(this.baseConfigs,i));return r.hooks=[...this.hooks],r._plugins=new Map(this._plugins),r._plugins.forEach(async n=>{await r.plugin(n)}),r}static create(i){return new ae(i)}async plugin(i){if(typeof i?.name=="string"&&typeof i?.install=="function"){if(this._plugins.has(i.name))return this;const r=await i.install(this);if(this._plugins.set(i.name,i),r instanceof ae)return r}return this}},U(ae,"FINAL_SYMBOL",Symbol("FEXIOS_FINAL_CONTEXT")),U(ae,"NORMALIZED_SYMBOL",Symbol("FEXIOS_NORMALIZED_QUERY")),U(ae,"DEFAULT_CONFIGS",{baseURL:"",timeout:60*1e3,credentials:"same-origin",headers:{},query:{},responseType:void 0,fetch:globalThis.fetch}),U(ae,"ALL_METHODS",["get","post","put","patch","delete","head","options","trace"]),U(ae,"METHODS_WITHOUT_BODY",["get","head","options","trace"]),ae);const _d=ls.create,_a=_d();typeof globalThis<"u"?globalThis.fexios=_a:typeof window<"u"&&(window.fexios=_a);var jr;(t=>{function e(r){return Array.isArray(r)?r.join("|"):typeof r=="boolean"||r===null?r?"1":void 0:typeof r=="number"?""+r:r}t.normalizeParamValue=e;function i(r){const n=o=>o&&(o instanceof URLSearchParams||o instanceof FormData);if(r==null)return;const s=new FormData;if(n(r))return r.forEach((o,a)=>{const l=e(o);l!=null&&s.append(a,l)}),s;if(st(r))return Object.entries(r).forEach(([o,a])=>{const l=e(a);l!=null&&s.append(o,l)}),s}t.normalizeBody=i})(jr||(jr={}));var Vi=(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))(Vi||{});let Me=class extends Error{constructor(e,i="",r){super(),this.code=e,this.message=i,this.cause=r,this.name="WikiSaikouError"}static is(e,i){return e instanceof this&&(i===void 0||e.code===i)}},mi=class Cf extends Error{constructor(e,i){super(),this.errors=e,this.cause=i,this.name="MediaWikiApiError",this.errors=Cf.normalizeErrors(e),this.message=e.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(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 r(s).length>0}t.includesMediaWikiApiError=i,t.normalizeMwApiErrors=mi.normalizeErrors;function r(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=r;function n(s){if(mi.is(s))return s.isBadTokenError();{const o=r(s);return new mi(o).isBadTokenError()}}t.isBadTokenError=n})(Me||(Me={}));const xa=Symbol.for("__FEXIOS_SAIKOU__");function Sa(t){const e=t instanceof ls?t:new ls({baseURL:t instanceof URL?t.toString():String(t),responseType:"json"});return e[xa]||(Reflect.defineProperty(e,xa,{get:()=>!0,enumerable:!1,configurable:!1}),e._tokens=new Map,e.on("afterResponse",i=>{const{data:r,rawRequest:n}=i,s=n?.headers.get("x-mw-token-name");s&&Me.isBadTokenError(r)&&e._tokens.delete(s);const o=r?.query?.tokens;o&&typeof o=="object"&&Object.entries(o).forEach(([l,c])=>{typeof c=="string"&&e._tokens.set(l.replace(/token$/i,"").toLowerCase(),c)});const a=r?.login?.token;return typeof a=="string"&&e._tokens.set("login",a),i}),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 r=i.body=jr.normalizeBody(i.body),n=new URLSearchParams(i.query);return r.has("format")&&n.delete("format"),r.has("formatversion")&&n.delete("formatversion"),r.has("action")&&n.delete("action"),r.has("origin")&&(n.set("origin",""+r.get("origin")),r.delete("origin")),i.query=Object.fromEntries(n.entries()),i}),e.on("beforeInit",i=>(i.query=jr.normalizeBody(i.query)||{},i)),e.on("beforeRequest",i=>{const r=new URL(i.url),n=r.searchParams;if(globalThis.location&&(!n.has("origin")&&location.origin!==r.origin?(n.set("origin",location.origin),e.baseConfigs.credentials="include",e.baseConfigs.mode="cors"):location.origin===r.origin&&(n.delete("origin"),e.baseConfigs.credentials=void 0,e.baseConfigs.mode=void 0)),r.searchParams.has("origin")){const s=encodeURIComponent(r.searchParams.get("origin")||"").replace(/\./g,"%2E");i.query={},r.searchParams.delete("origin"),i.url=`${r}${r.search?"&":"?"}origin=${s}`}return i})),e}const Xt=(t,...e)=>{const i=s=>Object.prototype.toString.call(s)==="[object Object]",r=s=>{if(Array.isArray(s))return s.slice();if(i(s)){const o={};for(const a of Reflect.ownKeys(s))o[a]=r(s[a]);return o}return s},n=r(t);for(const s of e)if(s!=null)for(const o of Reflect.ownKeys(s)){const a=s[o];if(typeof a>"u")continue;const l=n[o];i(l)&&i(a)?n[o]=Xt(l,a):n[o]=r(a)}return n},xd=(t,e,i)=>{let r={...ka.DEFAULT_CONFIGS};if(typeof t=="string"?r=Xt(r,{baseURL:t,fexiosConfigs:e||{},defaultParams:i||{}}):typeof t=="object"&&t!==null&&(r=Xt(r,t)),!r.baseURL&&typeof window=="object"&&window.mediaWiki){const{wgServer:n,wgScriptPath:s}=window.mediaWiki?.config?.get(["wgServer","wgScriptPath"])||{};typeof n=="string"&&typeof s=="string"&&(r.baseURL=`${n}${s}/api.php`)}if(typeof r.baseURL!="string")throw new Error("baseURL is required");return r},Sd=()=>{},kd=async(t,e)=>{let i=0;const{retry:r=3,onRetry:n=Sd,shouldRetry:s=()=>!0}=e;let o;do try{return await t()}catch(a){if(o=a,s(a,i))n(a,i),i++;else throw a}while(i<r);throw o||new Error("Retry failed")};const Gi=class{constructor(e,i,r){this.version="7.1.2",this.token=this.getToken;const n=this.config=xd(e,i,r);this.request=Sa(n.baseURL)}setBaseURL(e){return this.config.baseURL=e,this.request.baseConfigs.baseURL=e,this}async get(e,i){return this.runRequestWithApiErrorMapping(()=>this.request.get("",Xt({},this.config.fexiosConfigs,{query:Xt(this.config.defaultParams,e)},i)))}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&&Me.includesMediaWikiApiError(i)?new mi(Me.extractMediaWikiApiErrors(i),i):i}}throwIfApiError(e){const i=Me.extractMediaWikiApiErrors(e);if(i.length>0)throw new mi(i,e)}handleApiResponse(e){return this.config.throwOnApiError&&this.throwIfApiError(e.data),e}get tokens(){return this.request._tokens}async fetchTokens(e=["csrf"]){return this.config.fexiosConfigs.credentials="include",await this.get({action:"query",meta:"tokens",type:e}),this.tokens}async getToken(e="csrf",i=!1){return(!this.tokens.get(e)||i)&&(this.tokens.delete(e),await this.fetchTokens([e])),this.tokens.get(e)}badToken(e){return this.tokens.delete(e),this.tokens}async postWithToken(e,i,r){const{tokenName:n="token",retry:s=3,noCache:o=!1,fexiosOptions:a}=r||{};if(s<1)throw new Me(Vi.TOKEN_RETRY_LIMIT_EXCEEDED,"The limit of the number of times to automatically re-acquire the token has been exceeded");let l=0;return kd(async()=>{const c=await this.getToken(e,o||l>0);try{const u=await this.post({[n]:c,...i},Xt(a||{},{headers:{"x-mw-token-name":e}}));if(Me.isBadTokenError(u.data))throw u;return u}catch(u){throw Me.isBadTokenError(u)||u?.ok===!1||mi.is(u)?u:new Me(Vi.HTTP_ERROR,"Network/transport or SDK-internal error (not a MediaWiki API error)",u)}},{retry:s,onRetry:(c,u)=>{l=u+1},shouldRetry:c=>Me.isBadTokenError(c)||c?.ok===!1}).catch(c=>{throw Me.isBadTokenError(c)||c?.ok===!1?new Me(Vi.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}};Gi.INIT_DEFAULT_PARAMS={action:"query",errorformat:"plaintext",format:"json",formatversion:2},Gi.DEFAULT_CONFIGS={baseURL:void 0,fexiosConfigs:{responseType:"json"},defaultParams:Gi.INIT_DEFAULT_PARAMS,throwOnApiError:!1},Gi.createRequestHandler=Sa;let ka=Gi;let Ed=class extends ka{async clientLogin(e,i,r){r||(r={}),!r.logincontinue&&!r.loginreturnurl&&(r.loginreturnurl=location?.origin);const n=await this.postWithToken("login",{action:"clientlogin",username:e,password:i,...r},{tokenName:"logintoken"});if(n?.data?.clientlogin?.status==="PASS")return n.data.clientlogin;throw new Me(Vi.LOGIN_FAILED,n.data.clientlogin.message,n)}};class $d{constructor(e,i={}){this.ctx=e,location?.href&&i?.baseURL?.toString()?.startsWith("/")&&(i.baseURL=new URL(i.baseURL,location.origin));const r=new Ed({baseURL:i.baseURL.toString(),fexiosConfigs:{headers:{"x-api-user-agent":`InPageEdit-NEXT ${e.version}`,...i.headers},...i},throwOnApiError:!0});e.set("api",r)}}var Pd=Object.create,cs=Object.defineProperty,Cd=Object.getOwnPropertyDescriptor,Ea=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),$a=t=>{throw TypeError(t)},Id=(t,e,i)=>e in t?cs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ad=(t,e)=>cs(t,"name",{value:e,configurable:!0}),Od=t=>[,,,Pd(t?.[Ea("metadata")]??null)],Rd=["class","method","getter","setter","accessor","field","value","get","set"],Pa=t=>t!==void 0&&typeof t!="function"?$a("Function expected"):t,Td=(t,e,i,r,n)=>({kind:Rd[t],name:e,metadata:r,addInitializer:s=>i._?$a("Already initialized"):n.push(Pa(s||null))}),Ld=(t,e)=>Id(e,Ea("metadata"),t[3]),Nd=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Md=(t,e,i,r,n,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(n=n.prototype,c<5&&(c>3||!u)&&Cd(n,i));Ad(n,i);for(var d=r.length-1;d>=0;d--)l=Td(c,i,a={},t[3],h),o=(0,r[d])(n,l),a._=1,Pa(o)&&(n=o);return Ld(t,n),m&&cs(n,i,m),u?c^4?s:m:n},Ca,us,Ia;Ca=[ve(["wiki","wikiTitle"])];class Ur extends(Ia=Pt){constructor(i){super(i,"currentPage",!1);Fi(this,Be);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 nt(this,Be,ta).call(this),nt(this,Be,If).call(this),window.addEventListener("popstate",nt(this,Be,ia).bind(this)),this.logger.info("initialized",this.wikiTitle)}stop(){window.removeEventListener("popstate",nt(this,Be,ia).bind(this))}get params(){return this.url.searchParams}get canonicalUrl(){const i=document.querySelector('link[rel="canonical"]')?.href;let r=null;return i&&(r=new URL(i,location.origin)),Reflect.defineProperty(this,"canonicalUrl",{get:()=>r}),r}get wikiAction(){return this.params.get("action")||"view"}}Be=new WeakSet,ta=async function(){await nt(this,Be,Of).call(this),await nt(this,Be,Af).call(this)},If=function(){const i=Symbol.for("InPageEdit.CurrentPageService.UrlChangeListenerInstalled");if(window[i])return;const r=history.pushState,n=history.replaceState;history.pushState=function(s,o,a){r.apply(this,[s,o,a]),window.dispatchEvent(new PopStateEvent("popstate",{state:s}))},history.replaceState=function(s,o,a){n.apply(this,[s,o,a]),window.dispatchEvent(new PopStateEvent("popstate",{state:s}))},window[i]=!0},ia=async function(i){const r=this.url,n=new URL(window.location.href);this.url=n,(r.pathname!==n.pathname||r.searchParams.get("title")!==n.searchParams.get("title")||r.searchParams.get("curid")!==n.searchParams.get("curid"))&&(await nt(this,Be,ta).call(this),this.logger.info("location changed",n,this.wikiTitle))},Af=async function(){const r=this.wikiTitle?.getMainDBKey()===this.ctx.wiki.mainPageName;return Reflect.defineProperty(this,"isMainPage",{get:()=>r}),r},Of=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},us=Od(Ia),Ur=Md(us,0,"CurrentPageService",Ca,Ur),Nd(us,1,Ur);class Dd extends Pt{constructor(e){super(e,"resourceLoader",!0),this.ctx=e}stop(){this.removeAll()}loadScript(e,i){if(!e)return Promise.resolve(null);const r=`script:${e}`,n=document.querySelector(`[data-ipe="${r}"]`);return n?Promise.resolve(n):new Promise((o,a)=>{const l=document.createElement("script");l.src=e,l.dataset.ipe=r,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 r=`style:${e}`,n=document.querySelector(`[data-ipe="${r}"]`);return n?Promise.resolve(n):new Promise((o,a)=>{const l=document.createElement("link");l.rel="stylesheet",l.href=e,l.dataset.ipe=r,i&&Object.entries(i).forEach(([u,f])=>{typeof f>"u"||f===!1||f===null?l.removeAttribute(u):l.setAttribute(u,f)}),(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}`,r=document.querySelector(`[data-ipe="${i}"]`);r&&r.remove()}removeScript(e){const i=`script:${e}`,r=document.querySelector(`[data-ipe="${i}"]`);r&&r.remove()}removeAll(){document.querySelectorAll("[data-ipe]").forEach(e=>{e.remove()})}resolveImportPath(e){if(e.startsWith("http")||e.startsWith("//"))return e;const i=document.currentScript?.src;if(!i)return`https://unpkg.com/mediawiki-inpageedit@latest/dist/${e}`;const r=new URL(i);return r.pathname.endsWith(".js")||(r.pathname=r.pathname+"/"),new URL(e,r.toString()).toString()}}const Fr=Object.keys;function jd(t){return typeof t=="boolean"}function Ud(t){return t&&typeof t.nodeType=="number"}function Br(t){return typeof t=="string"}function Aa(t){return typeof t=="number"}function Jt(t){return typeof t=="object"?t!==null:Yi(t)}function Yi(t){return typeof t=="function"}function Fd(t){return!!(t&&t.isComponent)}function Bd(t){return Jt(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function fs(t,e){if(t)for(const i of Fr(t))e(t[i],i)}function qd(t){return Jt(t)&&"current"in t}const ds={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 Hd(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const zd=["Webkit","ms","Moz","O"];Fr(ds).forEach(t=>{zd.forEach(e=>{ds[Hd(e,t)]=0})});const Kd=Symbol.for("jsx-dom:type");var Oa=(function(t){return t.ShadowRoot="ShadowRoot",t})(Oa||{});function Wd(t){return t!=null&&t[Kd]===Oa.ShadowRoot}const Vd="http://www.w3.org/2000/svg",Gd="http://www.w3.org/1999/xlink",Yd="http://www.w3.org/XML/1998/namespace";function Ra(t){return!jd(t)&&t!=null}function hs(t){return Array.isArray(t)?t.map(hs).filter(Boolean).join(" "):Jt(t)?Symbol.iterator in t?hs(Array.from(t)):Fr(t).filter(e=>t[e]).join(" "):Ra(t)?""+t:""}const Qd={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},Xd=/^(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 Ct(t){const e=document.createDocumentFragment();return qr(t.children,e),e}function Jd(t,e,i){e={...e,children:i};const r=new t(e),n=r.render();return"ref"in e&&ps(e.ref,r),n}function p(t,e){let{children:i,...r}=e;!r.namespaceURI&&Qd[t]===0&&(r={...r,namespaceURI:Vd});let n;if(Br(t)){if(n=r.namespaceURI?document.createElementNS(r.namespaceURI,t):document.createElement(t),ih(r,n),qr(i,n),n instanceof window.HTMLSelectElement&&r.value!=null)if(r.multiple===!0&&Array.isArray(r.value)){const s=r.value.map(o=>String(o));n.querySelectorAll("option").forEach(o=>o.selected=s.includes(o.value))}else n.value=r.value;ps(r.ref,n)}else if(Yi(t))Jt(t.defaultProps)&&(r={...t.defaultProps,...r}),n=Fd(t)?Jd(t,r,i):t({...r,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return n}function Zd(t,e){for(var i=arguments.length,r=new Array(i>2?i-2:0),n=2;n<i;n++)r[n-2]=arguments[n];return(Br(e)||Array.isArray(e))&&(r.unshift(e),e={}),e=e||{},e.children!=null&&!r.length&&({children:r,...e}=e),p(t,{...e,children:r},e.key)}function ps(t,e){qd(t)?t.current=e:Yi(t)&&t(e)}function qr(t,e){if(Bd(t))eh(t,e);else if(Br(t)||Aa(t))ms(document.createTextNode(t),e);else if(t===null)ms(document.createComment(""),e);else if(Ud(t))ms(t,e);else if(Wd(t)){const i=e.attachShadow(t.attr);qr(t.children,i),ps(t.ref,i)}}function eh(t,e){for(const i of[...t])qr(i,e);return e}function ms(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 Ta(t,e){e==null||e===!1||(Array.isArray(e)?e.forEach(i=>Ta(t,i)):Br(e)?t.setAttribute("style",e):Jt(e)&&fs(e,(i,r)=>{r.indexOf("-")===0?t.style.setProperty(r,i):Aa(i)&&ds[r]!==0?t.style[r]=i+"px":t.style[r]=i}))}function th(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":La(i,Gd,Hr(t,":"),e);return;case"xmlnsXlink":gi(i,Hr(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":La(i,Yd,Hr(t,":"),e);return}switch(t){case"htmlFor":gi(i,"for",e);return;case"dataset":fs(e,(r,n)=>{r!=null&&(i.dataset[n]=r)});return;case"innerHTML":case"innerText":case"textContent":Ra(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":Jt(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":Yi(e)?e(i):gi(i,"class",hs(e));return;case"ref":case"namespaceURI":return;case"style":Ta(i,e);return;case"on":case"onCapture":fs(e,(r,n)=>{i.addEventListener(n,r,t==="onCapture")});return}if(Yi(e)){if(t[0]==="o"&&t[1]==="n"){let r=t.toLowerCase();const n=r.endsWith("capture");if(r==="ondoubleclick"?r="ondblclick":n&&r==="ondoubleclickcapture"&&(r="ondblclickcapture"),!n&&i[r]===null)i[r]=e;else if(n)i.addEventListener(r.substring(2,r.length-7),e,!0);else{let s;r in window?s=r.substring(2):s=r[2]+t.slice(3),i.addEventListener(s,e)}}}else Jt(e)?i[t]=e:e===!0?gi(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!Xd.test(t)?gi(i,Hr(t,"-"),e):gi(i,t,e))}function gi(t,e,i){t.setAttribute(e,i)}function La(t,e,i,r){t.setAttributeNS(e,i,r)}function ih(t,e){for(const i of Fr(t))th(i,t[i],e);return e}const zr=Object.keys;function rh(t){return typeof t=="boolean"}function nh(t){return t&&typeof t.nodeType=="number"}function gs(t){return typeof t=="string"}function Na(t){return typeof t=="number"}function Zt(t){return typeof t=="object"?t!==null:Qi(t)}function Qi(t){return typeof t=="function"}function sh(t){return!!(t&&t.isComponent)}function oh(t){return Zt(t)&&typeof t.length=="number"&&typeof t.nodeType!="number"}function ys(t,e){if(t)for(const i of zr(t))e(t[i],i)}function ah(t){return Zt(t)&&"current"in t}const bs={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 lh(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1)}const ch=["Webkit","ms","Moz","O"];zr(bs).forEach(t=>{ch.forEach(e=>{bs[lh(e,t)]=0})});const uh=Symbol.for("jsx-dom:type");var Ma=(function(t){return t.ShadowRoot="ShadowRoot",t})(Ma||{});function fh(t){return t!=null&&t[uh]===Ma.ShadowRoot}const dh="http://www.w3.org/2000/svg",hh="http://www.w3.org/1999/xlink",ph="http://www.w3.org/XML/1998/namespace";function Da(t){return!rh(t)&&t!=null}function ws(t){return Array.isArray(t)?t.map(ws).filter(Boolean).join(" "):Zt(t)?Symbol.iterator in t?ws(Array.from(t)):zr(t).filter(e=>t[e]).join(" "):Da(t)?""+t:""}const mh={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},gh=/^(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 yh(t){const e=document.createDocumentFragment();return Kr(t.children,e),e}function bh(t,e,i){e={...e,children:i};const r=new t(e),n=r.render();return"ref"in e&&vs(e.ref,r),n}function pe(t,e){let{children:i,...r}=e;!r.namespaceURI&&mh[t]===0&&(r={...r,namespaceURI:dh});let n;if(gs(t)){if(n=r.namespaceURI?document.createElementNS(r.namespaceURI,t):document.createElement(t),_h(r,n),Kr(i,n),n instanceof window.HTMLSelectElement&&r.value!=null)if(r.multiple===!0&&Array.isArray(r.value)){const s=r.value.map(o=>String(o));n.querySelectorAll("option").forEach(o=>o.selected=s.includes(o.value))}else n.value=r.value;vs(r.ref,n)}else if(Qi(t))Zt(t.defaultProps)&&(r={...t.defaultProps,...r}),n=sh(t)?bh(t,r,i):t({...r,children:i});else throw new TypeError(`Invalid JSX element type: ${t}`);return n}function vs(t,e){ah(t)?t.current=e:Qi(t)&&t(e)}function Kr(t,e){if(oh(t))wh(t,e);else if(gs(t)||Na(t))_s(document.createTextNode(t),e);else if(t===null)_s(document.createComment(""),e);else if(nh(t))_s(t,e);else if(fh(t)){const i=e.attachShadow(t.attr);Kr(t.children,i),vs(t.ref,i)}}function wh(t,e){for(const i of[...t])Kr(i,e);return e}function _s(t,e){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}function Wr(t,e){return t.replace(/[A-Z]/g,i=>e+i.toLowerCase())}function ja(t,e){e==null||e===!1||(Array.isArray(e)?e.forEach(i=>ja(t,i)):gs(e)?t.setAttribute("style",e):Zt(e)&&ys(e,(i,r)=>{r.indexOf("-")===0?t.style.setProperty(r,i):Na(i)&&bs[r]!==0?t.style[r]=i+"px":t.style[r]=i}))}function vh(t,e,i){switch(t){case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":Ua(i,hh,Wr(t,":"),e);return;case"xmlnsXlink":yi(i,Wr(t,":"),e);return;case"xmlBase":case"xmlLang":case"xmlSpace":Ua(i,ph,Wr(t,":"),e);return}switch(t){case"htmlFor":yi(i,"for",e);return;case"dataset":ys(e,(r,n)=>{r!=null&&(i.dataset[n]=r)});return;case"innerHTML":case"innerText":case"textContent":Da(e)&&(i[t]=e);return;case"dangerouslySetInnerHTML":Zt(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":Qi(e)?e(i):yi(i,"class",ws(e));return;case"ref":case"namespaceURI":return;case"style":ja(i,e);return;case"on":case"onCapture":ys(e,(r,n)=>{i.addEventListener(n,r,t==="onCapture")});return}if(Qi(e)){if(t[0]==="o"&&t[1]==="n"){let r=t.toLowerCase();const n=r.endsWith("capture");if(r==="ondoubleclick"?r="ondblclick":n&&r==="ondoubleclickcapture"&&(r="ondblclickcapture"),!n&&i[r]===null)i[r]=e;else if(n)i.addEventListener(r.substring(2,r.length-7),e,!0);else{let s;r in window?s=r.substring(2):s=r[2]+t.slice(3),i.addEventListener(s,e)}}}else Zt(e)?i[t]=e:e===!0?yi(i,t,""):e!==!1&&e!=null&&(i instanceof SVGElement&&!gh.test(t)?yi(i,Wr(t,"-"),e):yi(i,t,e))}function yi(t,e,i){t.setAttribute(e,i)}function Ua(t,e,i,r){t.setAttributeNS(e,i,r)}function _h(t,e){for(const i of zr(t))vh(i,t[i],e);return e}var xs=(t=>(t.Init="modal.init",t.BeforeShow="modal.beforeShow",t.Show="modal.show",t.BeforeClose="modal.beforeClose",t.Close="modal.close",t.Destroy="modal.destroy",t.ToastShow="toast.show",t.ToastClose="toast.close",t))(xs||{});let xh=0;const Fa=t=>`${t}-${++xh}`;function Xi(t){return t instanceof Node?t:document.createTextNode(String(t))}function It(t,e){if(!t)throw new Error(`${e??"Element"} not found`);return t}function Ba(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 Ae(t,e={}){const i=document.createElement(t);if(e.className&&(i.className=e.className),e.html!=null&&(i.innerHTML=e.html),e.text!=null&&(i.textContent=e.text),e.attrs)for(const[r,n]of Object.entries(e.attrs))i.setAttribute(r,n);return i}const Sh=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/i.test(navigator.platform),qa=["ctrl","alt","shift","meta"];function kh(t){if(!t)return null;const e=String(t).trim().toLowerCase().split(/[+\-\s]+/g).filter(Boolean),i=[];let r=null;const n=o=>{i.includes(o)||i.push(o)};for(const o of e){let a=o;if(a==="control"||a==="ctrl"){n("ctrl");continue}if(a==="alt"||a==="option"){n("alt");continue}if(a==="shift"){n("shift");continue}if(a==="meta"||a==="cmd"||a==="command"||a==="super"){n("meta");continue}if(a==="mod"){n(Sh?"meta":"ctrl");continue}a==="esc"&&(a="escape"),a==="return"&&(a="enter"),(a==="space"||a==="spacebar")&&(a="space"),r=a}const s=qa.filter(o=>i.includes(o));return!r||r===""?s.length?s.join("+"):null:s.length?`${s.join("+")}+${r}`:r}function Eh(t){const e=[];t.ctrlKey&&e.push("ctrl"),t.altKey&&e.push("alt"),t.shiftKey&&e.push("shift"),t.metaKey&&e.push("meta");let i=t.key;i===" "&&(i="space");const r=(i.length,i.toLowerCase()),n=qa.filter(s=>e.includes(s));return n.length?`${n.join("+")}+${r}`:r}class $h{constructor(){this.zBase=1e3,this.stack=[]}push(e){this.stack.push(e),this.syncZ()}remove(e){this.stack=this.stack.filter(i=>i!==e),this.syncZ()}top(){return this.stack[this.stack.length-1]}closeAll(e,i){const r=new Set((Array.isArray(i)?i:i?[i]:[]).map(String)),n=new Set((Array.isArray(e)?e:e?[e]:[]).map(String));[...this.stack].reverse().forEach(s=>{const o=s.modalId,a=n.size?n.has(s.pluginName):!0,l=r.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 De=new $h,kr=class kr{constructor(e={}){this.backdropId=Fa("ipe-modal-backdrop"),this.modalId=Fa("ipe-modal"),this.numberId=this.modalId.split("-")[1],this._isDestroyed=!1,this.pluginName="normalModal",this.buttonElsLeft=[],this.buttonElsRight=[],this.keyMap=new Map,this.isOpen=!1,this.isToast=!1,this.isDragging=!1,this.dragStartX=0,this.dragStartY=0,this.modalStartX=0,this.modalStartY=0,this.Event=xs,this._hooks=[],this.startCloseTimer=i=>{this.stopCloseTimer(),this.closeTimer=window.setTimeout(()=>this.close(),i)},this.stopCloseTimer=()=>{this.closeTimer&&window.clearTimeout(this.closeTimer),this.closeTimer=void 0},this.onDragMove=i=>{if(!this.isDragging)return;i.preventDefault();const r=i.clientX-this.dragStartX,n=i.clientY-this.dragStartY,s=this.get$modal(),o=this.modalStartX+r,a=this.modalStartY+n;s.style.left=`${o}px`,s.style.top=`${a}px`},this.onDragEnd=()=>{if(!this.isDragging)return;this.isDragging=!1,document.removeEventListener("pointermove",this.onDragMove),document.removeEventListener("pointerup",this.onDragEnd);const i=this.get$modal(),r=this.get$window();i.classList.remove("is-dragging"),r.style.animation="none",requestAnimationFrame(()=>{this.applyAnimation(!0)})},this.options={...kr.DEFAULT_OPTIONS,...e},this.options.backdrop===!1&&e.bodyScroll===void 0&&(this.options.bodyScroll=!0)}get isDestroyed(){return this._isDestroyed}static extends(e={}){return class extends this{constructor(i={}){super({...e,...i})}}}init(){if(this.$modal)return this;const e=this.options.backdrop!==!1;let i;e&&(i=Ae("div",{className:"ipe-modal-backdrop",attrs:{id:this.backdropId,"data-modal-id":this.modalId}}));const r=Ae("div",{className:"ipe-modal-modal",attrs:{id:this.modalId,role:"dialog","aria-modal":"true",tabindex:"-1"}});if(r.modal=this,!e){r.classList.add("no-backdrop");const m=window.pageYOffset||document.documentElement.scrollTop,d=window.pageXOffset||document.documentElement.scrollLeft,_=window.innerWidth;r.style.top=`${m+60}px`,this.once("modal.show",()=>{r.style.left=`${d+_/2-r.offsetWidth/2}px`})}const n=Ae("div",{className:`ipe-modal-modal__window size--${this.options.sizeClass||"auto"} plugin--${this.pluginName}`});n.modal=this;const s=Ae("div",{className:"ipe-modal-modal__header"}),o=`${this.modalId}-title`,a=Ae("h2",{className:"ipe-modal-modal__title",attrs:{id:o,role:"heading","aria-level":"2"}});r.setAttribute("aria-labelledby",o);const l=Ae("div",{className:"ipe-modal-modal__icons"});if(this.options.closeIcon){const m=Ae("button",{className:"ipe-modal-modal__close",attrs:{type:"button","aria-label":"Close"},html:"&times;"});m.addEventListener("click",()=>{let d=!0;typeof this.options.onClickClose=="function"?this.options.onClickClose(this)===!1&&(d=!1):this.options.onClickClose===!1&&(d=!1),d&&this.close()}),l.appendChild(m)}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)),r.classList.add("is-draggable"));const c=Ae("div",{className:"ipe-modal-modal__content"}),u=Ae("div",{className:"ipe-modal-modal__footer"}),f=Ae("div",{className:"ipe-modal-modal__buttons ipe-modal-modal__buttons--left"}),h=Ae("div",{className:"ipe-modal-modal__buttons ipe-modal-modal__buttons--right"});return u.append(f,h),n.append(s,c,u),r.appendChild(n),this.$backdrop=i,this.$modal=r,this.$window=n,this.$header=s,this.$title=a,this.$icons=l,this.$content=c,this.$footer=u,this.$buttonsLeft=f,this.$buttonsRight=h,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",m=>{this.options.outSideClose&&m.target===i&&this.close()}),this.options.draggable&&n.addEventListener("pointerdown",m=>{m.target&&n.contains(m.target)&&this.bringToFront()}),this.onKeyDown=this.onKeyDown.bind(this),this.emit("modal.init"),this}show(){if(this.$modal||this.init(),!this.$modal)throw new Error("Failed to initialize modal");if(this.isOpen)return this;{const r=this.emit("modal.beforeShow",!0),n=this.options.beforeShow?this.options.beforeShow(this)!==!1:!0;if(!r||!n)return this}this.lastFocused=document.activeElement??null,this.$backdrop&&document.body.appendChild(this.$backdrop),document.body.appendChild(this.$modal),this.shouldLockBodyOnOpen()&&De.lockBodyScroll(),requestAnimationFrame(()=>{this.$backdrop?.classList.add("is-open"),this.$modal.classList.add("is-open"),this.applyAnimation(!0),this.focusFirst()}),document.addEventListener("keydown",this.onKeyDown),De.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 f=()=>{c.removeEventListener(u,f),a()};c.addEventListener(u,f,{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 r=()=>{i||(i=!0,this.destroy(),this.options.onClose?.(this))},n=(s,o)=>{const a=()=>{s.removeEventListener(o,a),r()};s.addEventListener(o,a,{once:!0})};return e>0&&this.$window?(n(this.$window,"transitionend"),n(this.$window,"animationend"),window.setTimeout(r,e+20)):window.setTimeout(r,e),this}destroy(){if(this._isDestroyed)return this;if(this.stopCloseTimer(),document.removeEventListener("keydown",this.onKeyDown),this.isDragging&&this.onDragEnd(),this.$window?.removeEventListener("mouseenter",this.stopCloseTimer),this.isToast){this.$window?.parentElement&&this.$window.parentElement.removeChild(this.$window);const e=ei.indexOf(this);e!==-1&&ei.splice(e,1)}else this.$backdrop?.parentElement&&this.$backdrop.parentElement.removeChild(this.$backdrop),this.$modal?.parentElement&&this.$modal.parentElement.removeChild(this.$modal),De.remove(this),this.shouldUnlockBodyOnClose()&&De.unlockBodyScroll();return this.isOpen=!1,this.lastFocused?.focus?.(),this.emit("modal.destroy"),this._isDestroyed=!0,this}get$backdrop(){return this.$backdrop}get$modal(){return It(this.$modal,"modal")}get$window(){return It(this.$window,"window")}get$header(){return It(this.$header,"header")}get$title(){return It(this.$title,"title")}get$content(){return It(this.$content,"content")}get$icons(){return It(this.$icons,"icons")}get$buttons(e){return e==="leftButtons"?It(this.$buttonsLeft,"leftButtons"):e==="rightButtons"?It(this.$buttonsRight,"rightButtons"):It(this.$footer,"buttons")}setTitle(e){const i=this.get$title();return i.innerHTML="",i.append(Xi(e)),this}setContent(e,i="replace"){const r=this.get$content();return i==="replace"?(r.innerHTML="",r.append(Xi(e))):i==="append"?r.append(Xi(e)):r.prepend(Xi(e)),this}setIcons(e){const i=this.get$icons();i.innerHTML="";for(const r of e){const n=Ae("button",{className:`ipe-modal-modal__icon ${r.className}`,attrs:{type:"button"}});n.addEventListener("click",r.method),i.appendChild(n)}return this}setButtons(e,i){const r=this.$buttonsLeft,n=this.$buttonsRight;[r,n].forEach(o=>o.innerHTML=""),this.buttonElsLeft=[],this.buttonElsRight=[],this.keyMap.clear();const s=i??this.$footer;if(s===this.$footer)e.forEach(o=>this.addButton(o)),e.length===0&&(this.$footer.style.display="none");else{s.innerHTML="";for(const o of e){const a=this.generateButton(o);s.appendChild(a)}}return this}generateButton(e){const i=e.type??"button",r=i==="link"?Ae("a"):Ae("button",{attrs:{type:"button"}});e.id&&(r.id=e.id),r.className=`ipe-modal-btn ${e.className??""}`.trim();const n=Xi(e.label??"OK");if(r.append(n),i==="link"&&e.href&&(r.href=e.href),e.method&&r.addEventListener("click",s=>{if(r._ipe_tmpDisabled){s.preventDefault(),s.stopPropagation();return}e.method.call(r,s,this)}),typeof e.closeAfter=="number"&&e.closeAfter>=0&&r.addEventListener("click",()=>{window.setTimeout(()=>this.close(),e.closeAfter)}),typeof e.enableAfter=="number"&&e.enableAfter>0){i==="button"&&r.setAttribute("disabled","true"),r._ipe_tmpDisabled=!0,r.setAttribute("aria-disabled","true");const s=()=>{i==="button"&&r.removeAttribute("disabled"),delete r._ipe_tmpDisabled,r.removeAttribute("aria-disabled")};window.setTimeout(s,e.enableAfter)}if(e.keyPress){const s=String(e.keyPress).split(/[\,\|]+/g).map(o=>o.trim()).filter(Boolean);for(const o of s){const a=kh(o);a&&this.keyMap.set(a,r)}}return r}addButton(e,i){this.$footer&&(this.$footer.style.display="");const r=e.side??"right",n=r==="left"?this.$buttonsLeft:this.$buttonsRight,s=r==="left"?this.buttonElsLeft:this.buttonElsRight,o=this.generateButton(e),a=Math.max(0,Math.min(i??s.length,s.length));return a>=n.children.length?n.appendChild(o):n.insertBefore(o,n.children[a]),s.splice(a,0,o),this}removeButton(e){const i=this.buttonElsLeft,r=this.buttonElsRight,n=[...i,...r];let s=null;if(e==="*")return n.forEach(a=>{this.keyMap.delete(a.id),a.parentElement?.removeChild(a)}),this.$footer&&(this.$footer.style.display="none"),this;if(typeof e=="number"?s=n[e]??null:typeof e=="string"?s=n.find(a=>a.id===e)??null:e instanceof HTMLElement&&(s=n.find(a=>a===e)??null),!s)return this;for(const[a,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=r.indexOf(s),o!==-1&&(r.splice(o,1),s.parentElement?.removeChild(s))),i.length===0&&r.length===0&&this.$footer&&(this.$footer.style.display="none"),this}changePreviewState(){return this.get$modal().classList.toggle("is-fullscreen"),this}setModalHeight(e,i="height"){const r=this.get$window(),n=Math.max(0,window.innerHeight-e);return r.style[i]=`${n}px`,n}setOptions(e,i){return typeof e=="string"?this.options[e]=i:Object.assign(this.options,e),this}setPluginName(e){return this.$window&&(this.$window.className=this.$window.className.replace(`plugin--${this.pluginName}`,`plugin--${e}`)),this.pluginName=e,this}applyAnimation(e){const i=this.get$modal(),r=this.get$window(),n=this.$backdrop,s=this.options.modalAnimation??this.options.animation,o=typeof s=="string"?s:s&&(e?s.show:s.hide),a=this.options.backdropAnimation??this.options.animation,l=typeof a=="string"?a:a&&(e?a.show:a.hide);!o||o===!1?(i.style.transition="none",r.style.animation="none",r.style.removeProperty("--ipe-modal-anim")):(i.style.removeProperty("transition"),r.style.setProperty("--ipe-modal-anim",o)),n&&(!l||l===!1?n.style.transition="none":n.style.removeProperty("transition"))}on(e,i){return this._hooks.push({type:e,listener:i}),()=>this.off(e,i)}off(e,i){return this._hooks=this._hooks.filter(r=>r.type!==e&&(i?r.listener!==i:!0)),this}once(e,i){const r=this.on(e,n=>(r(),i(n)));return r}emit(e,i){const r=this._hooks.filter(a=>a.type===e);let n=!0;for(const a of r){const l=new CustomEvent(e,{detail:this,cancelable:i}),c=a.listener(l);if(l.defaultPrevented&&(n=!1),c===!1&&(n=!1),!n)break}const s=this.$modal??document.body,o=new CustomEvent(e,{detail:this,cancelable:i});return(!s.dispatchEvent(o)||o.defaultPrevented)&&(n=!1),n}focusFirst(){const e=this.get$modal(),i=Ba(e);i.length?i[0].focus():e.focus({preventScroll:!0})}onKeyDown(e){if(De.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=Ba(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 r=e.ctrlKey||e.altKey||e.metaKey,n=e.target;if(!r&&(n&&["INPUT","TEXTAREA"].includes(n.tagName)||n.contentEditable==="true"))return;const s=Eh(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 De.remove(this),De.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:!De.stack.some(e=>e!==this&&e.options.backdrop!==!1&&e.options.bodyScroll===!1)}shouldUnlockBodyOnClose(){return this.options.backdrop===!1||this.options.bodyScroll!==!1?!1:!De.stack.some(e=>e!==this&&e.options.backdrop!==!1&&e.options.bodyScroll===!1)}onDragStart(e){if(this.options.backdrop!==!1||!this.options.draggable)return;e.preventDefault(),this.isDragging=!0,this.bringToFront(),this.dragStartX=e.clientX,this.dragStartY=e.clientY;const i=this.get$modal(),r=i.getBoundingClientRect();this.modalStartX=r.left+window.pageXOffset,this.modalStartY=r.top+window.pageYOffset,i.style.transform="none",i.style.left=`${this.modalStartX}px`,i.style.top=`${this.modalStartY}px`,document.addEventListener("pointermove",this.onDragMove),document.addEventListener("pointerup",this.onDragEnd),i.classList.add("is-dragging")}showToast(e){this.$window||this.init();const i=Ph(e.position??"top right"),r=this.get$window();this.isToast=!0,r.style.pointerEvents="auto",this.applyAnimation(!0),i.appendChild(r);const n=(typeof this.options.closeAfter=="number"?this.options.closeAfter:this.options.closeAfter?.time)??3e3,s=(typeof this.options.closeAfter=="number"?!0:this.options.closeAfter?.resetOnHover)??!0;return n>0&&(this.startCloseTimer(n),s&&(r.addEventListener("mouseenter",this.stopCloseTimer),r.addEventListener("mouseleave",()=>this.startCloseTimer(n)))),this.isOpen=!0,this.options.onShow?.(this),ei.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=De.top();return s?.close(),s}const i=typeof e=="string"?e:e.id,r=De.stack.find(s=>s.modalId===i);if(r)return r.close(),r;const n=ei.find(s=>s.modalId===i);return n?.close(),n}static closeAll(e,i){const r=new Set((Array.isArray(i)?i:i?[i]:[]).map(String)),n=new Set((Array.isArray(e)?e:e?[e]:[]).map(String));return De.closeAll(e,i),[...ei].forEach(s=>{const o=s.modalId,a=n.size?n.has(s.pluginName):!0,l=r.has(o);a&&!l&&s.close()}),De.top()??new kr}static removeAll(){De.removeAll(),[...ei].forEach(e=>e.destroy())}static dialog(e,i){const r=new this({sizeClass:"dialog",buttons:[{label:"OK",className:"is-primary is-ghost",method:(n,s)=>{i?.(n,s),n.defaultPrevented||r.close()},keyPress:"Enter"}],...e});return r.init().show()}static confirm(e,i){e.title??(e.title="Confirm"),e.content??(e.content="Are you sure you want to perform this action?");const r=e.okBtn??{label:"OK",className:"is-primary is-ghost"},n=e.cancelBtn??{label:"Cancel",className:"is-danger is-ghost"};return new this({sizeClass:"dialog",...e,buttons:[{label:n.label,className:n.className,keyPress:"n",method:(s,o)=>{i?.(!1,o,s),o.close()}},{label:r.label,className:r.className,keyPress:"y",method:(s,o)=>{i?.(!0,o,s),s.defaultPrevented||o.close()}}]}).init().show()}static getDefaultNotifyIcon(e){switch(e){case"success":return pe("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:[pe("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),pe("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 pe("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:[pe("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),pe("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 pe("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:[pe("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),pe("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 pe("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:[pe("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),pe("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 pe("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:[pe("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),pe("path",{d:"M12 11v.01"}),pe("path",{d:"M8 11v.01"}),pe("path",{d:"M16 11v.01"}),pe("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 pe("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:[pe("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),pe("path",{d:"M18.333 6a3.667 3.667 0 0 1 3.667 3.667v8.666a3.667 3.667 0 0 1 -3.667 3.667h-8.666a3.667 3.667 0 0 1 -3.667 -3.667v-8.666a3.667 3.667 0 0 1 3.667 -3.667zm-3.333 -4c1.094 0 1.828 .533 2.374 1.514a1 1 0 1 1 -1.748 .972c-.221 -.398 -.342 -.486 -.626 -.486h-10c-.548 0 -1 .452 -1 1v9.998c0 .32 .154 .618 .407 .805l.1 .065a1 1 0 1 1 -.99 1.738a3 3 0 0 1 -1.517 -2.606v-10c0 -1.652 1.348 -3 3 -3zm1.293 9.293l-3.293 3.292l-1.293 -1.292a1 1 0 0 0 -1.414 1.414l2 2a1 1 0 0 0 1.414 0l4 -4a1 1 0 0 0 -1.414 -1.414"})]});default:return null}}static notify(e,i,r){var a,l,c,u;if(i?.overrideOther&&[...ei].forEach(f=>f.close()),typeof i.title>"u"){const f=e||"Notification";i.title=f[0].toUpperCase()+f.slice(1).toLowerCase()}const n=i.icon??this.getDefaultNotifyIcon(e);n&&(n instanceof Element&&n.classList.add("ipe-modal-notify-icon"),i.title=pe(yh,{children:[n,i.title]})),e==="confirm"&&(typeof i.closeAfter>"u"&&(i.closeAfter=0),i.okBtn||(i.okBtn={label:"OK"})),i.okBtn&&(typeof i.okBtn!="object"&&(i.okBtn={label:"OK"}),(a=i.okBtn).label??(a.label="OK"),(l=i.okBtn).className??(l.className="is-primary is-text ok-btn"),i.okBtn.method=(f,h)=>{r?.(!0,h,f),h.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=(f,h)=>{r?.(!1,h,f),h.close()}),i.buttons=[i.cancelBtn,i.okBtn,...i.buttons??[]].filter(Boolean);const s=`is-notify type-${e||"default"} ${i.className??""}`,o=new this({...i,className:s,sizeClass:"auto",center:!1,fitScreen:!1,closeIcon:!0,outSideClose:!1,bodyScroll:!0,buttons:i.buttons??[]});return o.setPluginName("toast"),o.showToast({position:i.position??"top right"})}};kr.DEFAULT_OPTIONS={className:"",sizeClass:"auto",center:!0,fitScreen:!1,closeIcon:!0,bodyScroll:!1,outSideClose:!0,backdrop:!0,animation:{show:"ipe-modal-fade-in",hide:"ipe-modal-fade-out"},animationSpeed:200};let Ss=kr;const ei=[];function Ph(t="top right"){const e="ipe-modal-toast-container",i=`${e}-${t.replace(/[\s-\.|\/]+/g,"-")}`;let r=document.getElementById(i);return r||(r=Ae("div",{className:`${e} ${t}`,attrs:{id:i,"data-position":t}}),document.body.appendChild(r)),r}const Ch={ipe_progress:"_ipe_progress_so6hn_1"},jt=t=>{const e=t.indeterminate??!0,i=p("div",{class:`${Ch.ipe_progress}`,"data-indeterminate":`${e}`,style:{width:"100%","--progress":t.progress?`${t.progress}%`:"0%"},...t});return i.setProgress=r=>{typeof r=="number"?(i.dataset.indeterminate="false",i.style.setProperty("--progress",`${r}%`)):(i.dataset.indeterminate="true",i.style.setProperty("--progress","0%"))},i};class xe extends Ss{constructor(e={}){e.className||(e.className=""),e.className+=" theme-ipe",e.modalAnimation||(e.modalAnimation={show:"ipe-modal-fade-in",hide:"ipe-modal-fade-out"}),super(e)}setLoadingState(e){if(this.get$window().classList.toggle("loading",e),e){const i=this.get$window().querySelectorAll("input:not([disabled]),button:not([disabled])");this._tmpDisabledActiveInputs=i,i.forEach(r=>{r.disabled=!0}),this.get$content().append(p("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:p(jt,{style:{width:"80%",maxWidth:"800px"}})}))}else{this.get$window().querySelector("#ipe-modalLoadingWrapper")?.remove();const i=this._tmpDisabledActiveInputs;i&&i.forEach(r=>{r.disabled=!1})}}}class Ih{constructor(e){this.ctx=e,this.IPEModal=xe,this.IPEModalEvent=xs,this.show=xe.show.bind(xe),this.createObject=xe.createObject.bind(xe),this.close=xe.close.bind(xe),this.closeAll=xe.closeAll.bind(xe),this.removeAll=xe.removeAll.bind(xe),this.dialog=xe.dialog.bind(xe),this.confirm=xe.confirm.bind(xe),this.notify=xe.notify.bind(xe),e.set("modal",this),e.on("dispose",()=>{xe.closeAll()})}}const Ha=t=>{if(!t)return new URLSearchParams;if(t instanceof URLSearchParams)return t;if(typeof t!="object"||t?.constructor!==Object)throw new TypeError("only plain object is supported");const e=new URLSearchParams;for(const[i,r]of Object.entries(t))if(r!=null){if(Array.isArray(r)){for(const n of r)e.append(i,n?.toString());continue}if(typeof r=="object"&&r!==null&&r.constructor===Object){for(const[n,s]of Object.entries(r))s!=null&&e.set(`${i}[${n}]`,s?.toString());continue}e.set(i,r?.toString())}return e},za=(t,e,i)=>{const r=typeof t=="string"?new URL(t,window?.location?.origin):new URL(t),n=new URLSearchParams(r.search),s=Ha(e);for(const[o,a]of s.entries())n.set(o,a);return r.search=n.toString(),r.hash="",r};var Ah=Object.create,ks=Object.defineProperty,Oh=Object.getOwnPropertyDescriptor,Ka=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Wa=t=>{throw TypeError(t)},Rh=(t,e,i)=>e in t?ks(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Th=(t,e)=>ks(t,"name",{value:e,configurable:!0}),Lh=t=>[,,,Ah(t?.[Ka("metadata")]??null)],Nh=["class","method","getter","setter","accessor","field","value","get","set"],Va=t=>t!==void 0&&typeof t!="function"?Wa("Function expected"):t,Mh=(t,e,i,r,n)=>({kind:Nh[t],name:e,metadata:r,addInitializer:s=>i._?Wa("Already initialized"):n.push(Va(s||null))}),Dh=(t,e)=>Rh(e,Ka("metadata"),t[3]),jh=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Uh=(t,e,i,r,n,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(n=n.prototype,c<5&&(c>3||!u)&&Oh(n,i));Th(n,i);for(var d=r.length-1;d>=0;d--)l=Mh(c,i,a={},t[3],h),o=(0,r[d])(n,l),a._=1,Va(o)&&(n=o);return Dh(t,n),m&&ks(n,i,m),u?c^4?s:m:n},Ga,Es,Ya;Ga=[ve(["api","storage"])];class Vr extends(Ya=Pt){constructor(e){super(e,"wiki",!1),this.ctx=e,this._data={},this.CACHE_VERSION=3,this.CACHE_TTL={siteinfo:1e3*60*60*24*3,userinfo:1e3*60*30},this.QUERY_DATA={siteinfo:{meta:"siteinfo",siprop:"general|specialpagealiases|namespacealiases|namespaces|magicwords"},userinfo:{meta:"userinfo",uiprop:"groups|rights|blockinfo|options"}},this.CACHE_DB=void 0,this.mwConfig={get:((i,r)=>window?.mw?.config?.get?.(i,r)??r),has:(i=>window?.mw?.config?.exists?.(i)??!1),get values(){return window?.mw?.config?.values||{}}},this.CACHE_DB=e.storage.createDatabase("wiki-metadata",1/0,this.CACHE_VERSION)}get logger(){return this.ctx.logger("WIKI_METADATA")}get api(){return this.ctx.api}async start(){await Promise.all(Object.keys(this.QUERY_DATA).map(e=>this.initData(e))),this.ctx.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=>{e.preferences.registerCustomConfig("WikiMetadataService",L.object({WikiMetadataService:L.const(p("div",{children:[p("h3",{children:"Wiki Informations"}),p("ul",{children:[p("li",{children:[p("strong",{children:"Site:"})," ",this.general.sitename," (",this.landingPageUrl,")"]}),p("li",{children:[p("strong",{children:"User"}),": ",this.userInfo.name," (ID: ",this.userInfo.id,")"]}),p("li",{children:[p("strong",{children:"Groups"}),": ",this.userGroups.join(", ")||"None"]})]}),p("div",{children:[p("p",{style:{fontStyle:"italic"},children:"If the information shown above is incorrect (for example, the user is not you), click the button below."}),p("button",{className:"btn danger",onClick:i=>{i.preventDefault(),Promise.all(Object.keys(this.QUERY_DATA).map(r=>this.invalidateCache(r))).then(()=>{window.location.reload()})},children:"🧹 Clear caches & Reload"})]})]})).role("raw-html")}).description("WikiMetadataService"),"about")}),this.logger.info("All initialized",this._data)}async initData(e,i=!1){const r=i?null:await this.fetchFromCache(e);if(r)return this._data[e]=r,this.logger.debug("Using cached",e,r),r;{const n=await this.fetchFromApi(e);return this.saveToCache(e,n),this._data[e]=n,this.logger.debug("Fetched from API",e,n),n}}getCacheKey(e){return`${e}:${new URL(this.ctx.api.config.baseURL).pathname.replace(/^\//,"")}`}async fetchFromApi(e){return this.api.get({action:"query",...this.QUERY_DATA[e]}).then(({data:i})=>{if(typeof i?.query!="object"||i.query===null)throw new Error("Invalid query data",{cause:i});return e==="siteinfo"?i.query:i.query?.[e]||i.query}).catch(i=>(this.logger.error("Failed to fetch",i),Promise.reject(i)))}async fetchFromCache(e){const i=this.getCacheKey(e);return await this.CACHE_DB.get(i,this.CACHE_TTL[e])}async saveToCache(e,i){const r=this.getCacheKey(e);return this.CACHE_DB.set(r,i)}async invalidateCache(e){const i=this.getCacheKey(e);return this.CACHE_DB.delete(i)}get _raw(){return this._data}get siteInfo(){return this._data.siteinfo}get general(){return this.siteInfo.general}get specialPageAliases(){return this.siteInfo.specialpagealiases}get namespaceAliases(){return this.siteInfo.namespacealiases}get namespaces(){return this.siteInfo.namespaces}get namespaceMap(){const e=Object.values(this.namespaces).map(i=>({id:i.id,canonical:i.canonical,aliases:this.namespaceAliases.filter(r=>r.id===i.id).map(r=>r.alias)})).sort((i,r)=>i.id-r.id);return Reflect.defineProperty(this,"namespaceMap",{get:()=>e}),e}get magicWords(){return this.siteInfo.magicwords}get userInfo(){return this._data.userinfo}get userOptions(){return this.userInfo.options}get isUserBlocked(){return this.userInfo.blockedbyid&&this.userInfo.blockexpiry&&new Date(this.userInfo.blockexpiry).getTime()>Date.now()}get userGroups(){return this.userInfo.groups}get userRights(){return this.userInfo.rights}get 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 za(this.siteInfo.general.base,e).toString()}getUrl(e,i){const r=Ha(i);let n;return typeof e=="string"&&e!==""?n=new URL(`${this.articleBaseUrl.replace("$1",e)}`):typeof e=="number"?(r.set("curid",e.toString()),n=new URL(this.getSciprtUrl("index"))):n=new URL(this.getSciprtUrl("index")),n.search=r.toString(),n.toString()}hasRight(e){return this.userRights.includes(e)}hasAnyRight(...e){return e.some(i=>this.hasRight(i))}hasEveryRights(...e){return e.every(i=>this.hasRight(i))}inGroup(e){return this.userGroups.includes(e)}inAnyGroup(...e){return this.userGroups.some(i=>e.includes(i))}getBlockInfo(){return this.isUserBlocked?{blockid:this.userInfo.blockid,blockedby:this.userInfo.blockedbyid,blockedbyid:this.userInfo.blockedbyid,blockreason:this.userInfo.blockreason,blockedtimestamp:this.userInfo.blockedtimestamp,blockexpiry:this.userInfo.blockexpiry}:null}}Es=Lh(Ya),Vr=Uh(Es,0,"WikiMetadataService",Ga,Vr),jh(Es,1,Vr);class Fh{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 Bh=()=>new Proxy(new Fh,{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)}}),qh=(()=>{const t=Symbol.for("IPE.GlobalMemoryStorage");return t in globalThis||(globalThis[t]=Bh()),globalThis[t]})();class Hh{constructor(e,i,r=1/0,n,s="localStorage"){this.dbName=e,this.storeName=i,this.ttl=r,this.version=n,this.engine=s,typeof r!="number"&&(this.ttl=Number(r)),(isNaN(this.ttl)||this.ttl<=0)&&(this.ttl=1/0),this.engine==="localStorage"&&"localStorage"in window?this.db=window.localStorage:this.engine==="sessionStorage"&&"sessionStorage"in window?this.db=window.sessionStorage:this.db=qh}makeKey(e){return`${this.dbName?this.dbName+":":""}${this.storeName?this.storeName+"/":""}${e}`}load(e){const i=this.getRaw(e);if(i===null)return null;let r;try{r=JSON.parse(i)}catch{return this.deleteSync(e),null}const n=r;return typeof n.time!="number"||!("value"in n)?(this.deleteSync(e),null):typeof this.version=="number"&&n.version!==this.version?(this.deleteSync(e),null):n}getRaw(e){const i=this.makeKey(e);return this.db.getItem(i)}setRaw(e,i){const r=this.makeKey(e);try{this.db.setItem(r,i)}catch{}}deleteSync(e){const i=this.makeKey(e);this.db.removeItem(i)}isExpired(e,i=this.ttl){return e?Date.now()-e.time>i:!1}async get(e,i=this.ttl,r){const n=this.load(e),s=this.isExpired(n,i);if(!n||s){if(typeof r=="function"){const o=await r();return await this.set(e,o),o}return null}return n.value}async set(e,i){const r=Date.now();if(typeof e=="string"){const o=e,a=i;if(a===null||typeof a>"u"){await this.delete(o);return}const l={time:r,value:a,version:this.version};return this.setRaw(o,JSON.stringify(l)),l}const n=e,s={};for(const[o,a]of Object.entries(n)){if(a===null||typeof a>"u"){this.deleteSync(o);continue}const l={time:r,value:a,version:this.version};this.setRaw(o,JSON.stringify(l)),s[o]=l}return s}async has(e,i=this.ttl){const r=this.load(e);return r!==null&&!this.isExpired(r,i)}async delete(e){this.deleteSync(e)}async updatedAt(e){const i=this.load(e);return i?i.time:0}async clear(){const e=this.makeKey(""),i=[];for(let r=0;r<this.db.length;r++){const n=this.db.key(r);n&&n.startsWith(e)&&i.push(n)}for(const r of i)this.db.removeItem(r);return this}async*keys(){const e=this.makeKey("");for(let i=0;i<this.db.length;i++){const r=this.db.key(i);r&&r.startsWith(e)&&(yield r.slice(e.length))}}async*values(){for await(const e of this.keys()){const i=this.load(e);if(i){if(this.isExpired(i)){this.deleteSync(e);continue}yield i}}}async*entries(){for await(const e of this.keys()){const i=this.load(e);if(i){if(this.isExpired(i)){this.deleteSync(e);continue}yield[e,i]}}}}var ye;(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,f){const h=Math.max(1,c.attempts);for(let m=0;m<h;m++)try{return await u(m)}catch(d){if(m===h-1)throw d;await f?.(d,m);const _=c.baseDelayMs*Math.pow(2,m)+Math.floor(Math.random()*10);await(0,t.sleep)(_)}throw new Error("withRetry exhausted unexpectedly")}t.withRetry=i;function r(c,u,f){return new Promise((h,m)=>{const d=indexedDB.open(c,u);d.onupgradeneeded=()=>{try{const _=d.result,k=d.transaction;f?.(_,k)}catch(_){m(_)}},d.onerror=()=>m(d.error),d.onblocked=()=>{},d.onsuccess=()=>{const _=d.result;_.onversionchange=()=>{try{_.close()}finally{t.cache.delete(c)}},h(_)}})}async function n(c,u,f){let h=!c.objectStoreNames.contains(u),m=[];if(!h&&f?.indexes?.length){const k=c.transaction(u,"readonly"),E=k.objectStore(u),x=new Set(Array.from(E.indexNames));m=(f.indexes||[]).filter(y=>!x.has(y.name)),await new Promise((y,g)=>{k.oncomplete=()=>y(),k.onabort=()=>g(k.error),k.onerror=()=>g(k.error)})}if(!h&&m.length===0)return c;const d=c.version+1;c.close();const _=await r(c.name,d,(k,E)=>{let x;k.objectStoreNames.contains(u)?x=E.objectStore(u):x=k.createObjectStore(u,{keyPath:f?.keyPath??void 0,autoIncrement:!!f?.autoIncrement});for(const y of m)x.indexNames.contains(y.name)||x.createIndex(y.name,y.keyPath,y.options)});return _.onversionchange=()=>{try{_.close()}finally{t.cache.delete(_.name)}},_}async function s(c,u,f){let h=t.cache.get(c);return h?(h=h.then(m=>n(m,u,f)),t.cache.set(c,h)):(h=(async()=>{const m=await r(c);return n(m,u,f)})(),t.cache.set(c,h)),h}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,f)=>{c.onsuccess=()=>u(c.result),c.onerror=()=>f(c.error)})}t.asyncRequest=a;function l(c){return new Promise((u,f)=>{c.oncomplete=()=>u(),c.onabort=()=>f(c.error??new DOMException("Aborted","AbortError")),c.onerror=()=>f(c.error??new DOMException("TransactionError","UnknownError"))})}t.waitTx=l})(ye||(ye={}));let zh=class{constructor(e,i,r={}){this.dbName=e,this.storeName=i,this.options=r}get _iterBatch(){return this.options.iterBatch??ye.defaults.iterBatch}get _retryCfg(){const e=this.options.retry??ye.defaults.retry;return{attempts:e.attempts??3,baseDelayMs:e.baseDelayMs??16}}async _withStore(e,i){const r=this._retryCfg;return ye.withRetry(r,async()=>{const n=await ye.getDB(this.dbName,this.storeName,this.options.ensure);try{const s=n.transaction(this.storeName,e),o=s.objectStore(this.storeName),a=await i(o);return await ye.waitTx(s),a}catch(s){throw s}},async n=>{ye.shouldReconnect(n)&&await ye.closeConnection(this.dbName)})}async get(e){return this._withStore("readonly",async i=>{const r=await ye.asyncRequest(i.get(e));return r===void 0?void 0:r})}async set(e,i){return await this._withStore("readwrite",async r=>{const n=this.options.ensure?.keyPath!=null?r.put(i):r.put(i,e);await ye.asyncRequest(n)}),this}async delete(e){return this._withStore("readwrite",async i=>{const r=await ye.asyncRequest(i.get(e))!==void 0;return await ye.asyncRequest(i.delete(e)),r})}async clear(){await this._withStore("readwrite",async e=>{await ye.asyncRequest(e.clear())})}async has(e){return await this.get(e)!==void 0}async count(){return this._withStore("readonly",async e=>await ye.asyncRequest(e.count())??0)}async*_iterateEntries(){let e=null,i=!1;const r=Math.max(1,this._iterBatch);for(;!i;){const n=await this._withStore("readonly",async s=>{const o=[],a=e===null?void 0:IDBKeyRange.lowerBound(e,!0);return await new Promise((l,c)=>{const u=s.openCursor(a);u.onerror=()=>c(u.error),u.onsuccess=()=>{const f=u.result;if(!f){i=!0,l();return}o.push([f.key,f.value]),e=f.key,o.length>=r?l():f.continue()}}),o});for(const s of n)yield s;if(n.length===0)break}}entries(){return this._iterateEntries()}async*keys(){for await(const[e]of this.entries())yield e}async*values(){for await(const[,e]of this.entries())yield e}[Symbol.asyncIterator](){return this.entries()[Symbol.asyncIterator]()}async forEach(e){for await(const[i,r]of this.entries())await e(r,i,this)}async getMany(e){const i=new Map;for await(const r of e)i.set(r,void 0);return await this._withStore("readonly",async r=>{await Promise.all(i.keys().map(async n=>{const s=await ye.asyncRequest(r.get(n));i.set(n,s===void 0?void 0:s)}))}),i}async setMany(e){const i=this.options.ensure?.keyPath!=null;return await this._withStore("readwrite",async r=>{for await(const[n,s]of e){const o=i?r.put(s):r.put(s,n);await ye.asyncRequest(o)}}),this}async deleteMany(e){let i=0;return await this._withStore("readwrite",async r=>{for await(const n of e)await ye.asyncRequest(r.get(n))!==void 0&&i++,await ye.asyncRequest(r.delete(n))}),i}async disconnect(){await ye.closeConnection(this.dbName)}};class Kh{constructor(e,i,r=1/0,n){this.dbName=e,this.storeName=i,this.ttl=r,this.version=n,this.db=new zh(e,i),this.keys=this.db.keys.bind(this.db),this.values=this.db.values.bind(this.db),this.entries=this.db.entries.bind(this.db),typeof this.ttl!="number"&&(this.ttl=Number(this.ttl)),(isNaN(this.ttl)||this.ttl<=0)&&(this.ttl=1/0),this._clearExpiredEntries().catch(()=>{})}async _clearExpiredEntries(){if(this.ttl===1/0)return;const e=Date.now(),i=[];for await(const[r,n]of this.db.entries())typeof n.time=="number"&&e-n.time>this.ttl&&i.push(r);i.length>0&&await this.db.deleteMany(i)}async get(e,i=this.ttl,r){const n=await this.loadFromDB(e),s=this.checkIfExpired(n,i);if(!n||s){if(typeof r=="function"){const o=await r();return await this.set(e,o),o}return null}return n.value}async set(e,i){const r=Date.now();if(typeof e=="string"){const l=e,c=i;if(c===null||typeof c>"u")return this.delete(l);const u={time:r,value:c,version:this.version};return await this.db.set(l,u),u}const n=e,s=[],o=[],a={};for(const[l,c]of Object.entries(n))if(c===null||typeof c>"u")o.push(l);else{const u={time:r,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 r=await this.loadFromDB(e),n=this.checkIfExpired(r,i);return r!==null&&!n}async delete(e){await this.db.delete(e)}async updatedAt(e){const i=await this.loadFromDB(e);return i?i.time:0}async loadFromDB(e){const i=await this.db.get(e);if(i===void 0)return null;if(typeof i.time!="number"||typeof i.value>"u"){try{await this.delete(e)}catch{}return null}if(typeof this.version=="number"&&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 Wh 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,r,n="indexedDB"){const s="indexedDB"in window&&window.indexedDB!==null;switch(n==="indexedDB"&&!s&&(n="localStorage"),n){case"indexedDB":return new Kh(this.config.dbName,e,i,r);case"localStorage":case"sessionStorage":case"memory":return new Hh(this.config.dbName,e,i,r,n);default:throw new Error(`Unsupported storage engine: ${n}`)}}}var Xe=(t=>(t.preferences="preferences",t.watch="watch",t.unwatch="unwatch",t.nochange="nochange",t))(Xe||{});function Vh(t){const i=class i{constructor(n,s=!0){this._loaded=s,this.api=t,n.revisions?.forEach(o=>{typeof o?.slots?.main=="object"&&Object.assign(o,o.slots.main)}),this.pageInfo={...i.DEFAULT_PAGE_INFO,...n}}static async newFromApi(n){const{data:s}=await this.api.get({...i.DEFAULT_QUERY_PARAMS,...n}),o=s?.query?.pages?.[0];if(!o||!o.title)throw new Error("Invalid page info",{cause:s});return new i(o,!0)}static newBlankPage(n={}){return new i(n,!1)}static async newFromAnyKind(n){const{title:s,pageId:o,revisionId:a}=n||{};return a?this.newFromApi({revids:parseInt(a.toString(),10)}):o?this.newFromApi({pageids:parseInt(o.toString(),10)}):s?this.newFromApi({titles:s.toString()}):null}static async newBatchFromApi(n){const{titles:s,pageids:o,revids:a,...l}=n||{},{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(n){return this.api.post({action:"parse",page:this.pageInfo.title,prop:"text|langlinks|categories|links|templates|images|externallinks|sections|revid|displaytitle|iwlinks|properties|parsewarnings",...n})}async preview(n,s){return this.parse({action:"parse",page:void 0,title:this.title,text:n,pst:1,preview:1,disableeditsection:1,disablelimitreport:1,...s})}async edit(n,s){const{text:o,prependtext:a,appendtext:l,summary:c="",watchlist:u=Xe.preferences,section:f}=n;return this.api.postWithEditToken({action:"edit",title:this.title,starttimestamp:this.pageInfo.touched,basetimestamp:this.revisions[0]?.timestamp,text:o,prependtext:a,appendtext:l,summary:c,watchlist:u,section:f,...s})}async createOnly(n,s){return this.edit(n,{createonly:1,...s})}async delete(n,s){return this.api.postWithEditToken({action:"delete",pageid:this.pageInfo.pageid,reason:n,...s})}async moveTo(n,s,o){return this.api.postWithEditToken({action:"move",from:this.pageInfo.title,to:n,reason:s,movetalk:1,movesubpages:1,...o})}userCan(n){return!!this.pageInfo?.actions?.[n]}userCanEdit(){return this.userCan("edit")}async reloadSelfInfo(){const n=await i.newFromApi({pageids:this.pageInfo.pageid,titles:this.pageInfo.title}),s=(this.pageInfo.revisions||[]).concat(n.revisions||[]).sort((o,a)=>o.revid-a.revid).reduce((o,a)=>(o.find(l=>l.revid===a.revid)||o.push(a),o),[]);return this.pageInfo=n.pageInfo,this.pageInfo.revisions=s,this._loaded=!0,this}get pageid(){return this.pageInfo.pageid}get title(){return this.pageInfo.title}get ns(){return this.pageInfo.ns}get contentmodel(){return this.pageInfo.contentmodel}get fullurl(){return this.pageInfo.fullurl}get canonicalurl(){return this.pageInfo.canonicalurl}get editurl(){return this.pageInfo.editurl}get revisions(){return this.pageInfo.revisions||[]}get lastrevid(){return this.pageInfo.lastrevid}get templates(){return this.pageInfo.templates||[]}get images(){return this.pageInfo.images||[]}};i.api=t,i.DEFAULT_QUERY_PARAMS={action:"query",prop:"info|templates|transcludedin|images|pageimages|revisions",inprop:"protection|url|varianttitles",intestactions:"edit|move|delete",tllimit:"max",tilimit:"max",imlimit:"max",piprop:"thumbnail|name|original",pithumbsize:"200",pilimit:"max",rvprop:"ids|timestamp|flags|comment|user|content",rvslots:"main"},i.DEFAULT_PAGE_INFO={pageid:0,ns:0,title:"",contentmodel:"wikitext",pagelanguage:"",pagelanguagehtmlcode:"",pagelanguagedir:"ltr",touched:new Date().toISOString(),lastrevid:0,length:0,protection:[],restrictiontypes:[],fullurl:"",canonicalurl:"",editurl:"",varianttitles:{},actions:{edit:!0,move:!1,delete:!1},revisions:[],templates:[],images:[]};let e=i;return e}const Xo=class Xo extends Pt{constructor(e){super(e,"wikiPage",!0),this.ctx=e,this.WikiPage=Vh(this.ctx.api)}async createInstance(e,i=!1){return await this.WikiPage.newFromApi(e)}async newFromTitle(e,i=!1,r,n=!1){return this.createInstance({titles:e.toString(),converttitles:i,rvsection:r},n)}async newFromPageId(e,i,r=!1){return this.createInstance({pageids:e,rvsection:i},r)}async newFromRevision(e,i,r=!1){return await this.createInstance({revids:e,rvsection:i},r)}newBlankPage(e={}){return this.WikiPage.newBlankPage(e)}};Xo.inject=["api"];let $s=Xo;const Qa=new WeakMap,ht={toDBKey:t=>t.replace(/ /g,"_"),toNormalText:t=>t.replace(/_/g," "),ensureCase:(t,e)=>e==="first-letter"?t.charAt(0).toUpperCase()+t.slice(1):t},bi={normalizeSpecialPageName:t=>t.toLowerCase(),buildSpecialPageIndex:t=>{const e=new Map,i=new Map,r=new Map;for(const n of t.specialpagealiases){const s=n.realname;e.set(s,s);const o=bi.normalizeSpecialPageName(s);r.set(o,s);for(const a of n.aliases){i.set(a,s);const l=bi.normalizeSpecialPageName(a);r.set(l,s)}}return{byRealName:e,byAlias:i,byNormalized:r}},findSpecialPageRealName:(t,e)=>{const i=t.split("/")[0];let r=e.byRealName.get(i)??e.byAlias.get(i);if(r!==void 0)return r;const n=bi.normalizeSpecialPageName(i);return e.byNormalized.get(n)??null}},ot={normalizeNamespaceText:t=>t.replace(/[_\s]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),buildIndex:t=>{const e=new Map,i=new Map,r=new Map,n=new Map;for(const[s,o]of Object.entries(t.namespaces)){const a=parseInt(s);e.set(o.name,a),i.set(o.canonical??"",a);const l=ot.normalizeNamespaceText(o.name),c=ot.normalizeNamespaceText(o.canonical??"");n.set(l,a),n.set(c,a)}for(const s of t.namespacealiases){r.set(s.alias,s.id);const o=ot.normalizeNamespaceText(s.alias);n.set(o,s.id)}return{byName:e,byCanonical:i,byAlias:r,byNormalized:n}},findNamespaceId:(t,e)=>{let i=e.byName.get(t)??e.byCanonical.get(t)??e.byAlias.get(t);if(i!==void 0)return i;const r=ot.normalizeNamespaceText(t);return e.byNormalized.get(r)??null},isTalkPage:t=>t%2===1&&t>0,getDefaultNamespaceInfo:t=>({id:t,name:"",canonical:"",case:"first-letter",content:!1,nonincludable:!1,subpages:!1})};function Gh(t){var s,o;const e=Qa.get(t);if(e)return e;const i=ot.buildIndex(t),r=bi.buildSpecialPageIndex(t),a=class a{constructor(c,u){Fi(this,s);Fi(this,o);if(this.newTitle=a.create.bind(a),this.toText=this.getPrefixedText.bind(this),this.toString=this.getPrefixedDBKey.bind(this),ze(this,s,c||""),ze(this,o,u??0),u===void 0?this.fixNSByTitle():this.stripNamespaceFromTitle(),this.getMainText()==="")throw new Error("Invalid title")}static create(c,u){return new a(c,u)}fixNSByTitle(){const c=X(this,s).indexOf(":");if(c===-1)return;if(c===0){ze(this,s,X(this,s).substring(1));return}const u=X(this,s).substring(0,c),f=X(this,s).substring(c+1),h=ot.findNamespaceId(u,a._namespaceIndex);h!==null&&(ze(this,s,f),ze(this,o,h))}stripNamespaceFromTitle(){const c=X(this,s).indexOf(":");if(c===-1)return;if(c===0){ze(this,s,X(this,s).substring(1));return}const u=X(this,s).substring(0,c),f=X(this,s).substring(c+1);ot.findNamespaceId(u,a._namespaceIndex)!==null&&ze(this,s,f)}getNamespaceInfo(){return a._meta.namespaces[X(this,o)]??ot.getDefaultNamespaceInfo(X(this,o))}getMainDBKey(){const c=this.getNamespaceInfo();if(X(this,o)===-1){const u=bi.findSpecialPageRealName(X(this,s),a._specialPageIndex);if(u){const f=X(this,s).includes("/")?X(this,s).substring(X(this,s).indexOf("/")):"",h=u+f;return ht.ensureCase(ht.toDBKey(h),c.case)}}return ht.ensureCase(ht.toDBKey(X(this,s)),c.case)}getMainText(){const c=this.getNamespaceInfo();if(X(this,o)===-1){const u=bi.findSpecialPageRealName(X(this,s),a._specialPageIndex);if(u){const f=X(this,s).includes("/")?X(this,s).substring(X(this,s).indexOf("/")):"",h=u+f;return ht.ensureCase(ht.toNormalText(h),c.case)}}return ht.ensureCase(ht.toNormalText(X(this,s)),c.case)}getMainRootText(){return this.getMainText().split("/")[0]}getPrefixedDBKey(){return X(this,o)===0?this.getMainDBKey():`${this.getNamespaceDBKey()}:${this.getMainDBKey()}`}getPrefixedText(){return X(this,o)===0?this.getMainText():`${this.getNamespaceText()}:${this.getMainText()}`}getNamespaceId(){return X(this,o)}getNamespaceText(){return this.getNamespaceInfo().name??""}getNamespaceDBKey(){const c=this.getNamespaceInfo();return ht.ensureCase(ht.toDBKey(this.getNamespaceText()),c.case)}getSubjectPage(){if(ot.isTalkPage(X(this,o))){const c=X(this,o)-1;return new a(X(this,s),c)}return this}getTalkPage(){if(ot.isTalkPage(X(this,o)))return this;if(X(this,o)<0)return null;const c=X(this,o)+1;return a._meta.namespaces[c.toString()]?new a(X(this,s),c):null}getURL(c){const u=a._meta.general.articlepath,f=this.getPrefixedDBKey(),h=u.replace("$1",f),m=new URL(h,location.origin);return c&&(c instanceof URLSearchParams?c:new URLSearchParams(c)).forEach((_,k)=>{m.searchParams.set(k,_)}),m}setTitle(c){return ze(this,s,c),ze(this,o,0),this.fixNSByTitle(),this}setMainText(c){return ze(this,s,c),this}setNamespaceText(c){const u=ot.findNamespaceId(c,a._namespaceIndex);return u!==null&&ze(this,o,u),this}setNamespaceId(c){return ze(this,o,c),this}equals(c){return typeof c=="string"&&(c=new a(c)),this.getPrefixedDBKey()===c.getPrefixedDBKey()}isSpecial(c){if(X(this,o)!==-1)return!1;const u=new a(c,-1);return this.getMainRootText()===u.getMainRootText()}toJSON(){return{ns:X(this,o),text:this.getMainText(),title:this.getPrefixedText(),url:this.getURL().toString(),isSpecial:X(this,o)<0}}};s=new WeakMap,o=new WeakMap,a._meta=t,a._namespaceIndex=i,a._specialPageIndex=r;let n=a;return Qa.set(t,n),n}const Er=class Er 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=Gh(this.ctx.wiki.siteInfo)}newTitle(e,i){return new this.Title(e,i)}newMainPageTitle(){return this.newTitle(this.ctx.wiki.mainPageName)}async newTitleFromUrl(e){const i=this.parseWikiLink(e);return i?.title?i.title:i?.pageId?this.newTitleFromPageId(i.pageId):null}async newTitleFromAnyId(e,i=!1){const{title:r,pageId:n,revId:s}=e??{};if(typeof r=="string")return this.newTitle(r);let o,a;if(s?(o=parseInt(s.toString(),10),a="revid"):n&&(o=parseInt(n.toString(),10),a="pageid"),!o||!a||isNaN(o)||o<=0)throw new Error("Invalid id or kind",{cause:e});if(!i&&this._cachedTitles.has(`${a}:${o}`))return await this._cachedTitles.get(`${a}:${o}`);const{promise:l,resolve:c,reject:u}=re();this._cachedTitles.set(`${a}:${o}`,l);try{const{wikiPage:f}=this.ctx;let h=null;if(a==="pageid")h=await f.newFromPageId(o);else if(a==="revid")h=await f.newFromRevision(o);else throw new Error(`Invalid kind: ${a}`);c(this.newTitle(h.title))}catch(f){this._cachedTitles.delete(`${a}:${o}`),u(f)}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 r,n,s="view";const o=i.getMainDBKey().split("/").slice(1).join("/")||"";if(i.isSpecial("edit")&&o)r=o,s="edit";else if(i.isSpecial("talkpage")&&o){const a=i.newTitle(o).getTalkPage();if(!a)return null;r=a.getPrefixedDBKey()}else if(i.isSpecial("mypage"))r=i.newTitle(this.ctx.wiki.userInfo.name,2).getPrefixedDBKey()+(o?`/${o}`:"");else if(i.isSpecial("mytalk"))r=i.newTitle(this.ctx.wiki.userInfo.name,3).getPrefixedDBKey()+(o?`/${o}`:"");else if(i.isSpecial("newsection")&&o)r=o,n="new",s="edit";else return null;return{title:new this.Title(r),section:n,action:s}}isWikiLink(e){return e.startsWith(this.wikiArticleBaseUrl)||e.startsWith(this.wikiIndexPhpUrl)||e.startsWith(`${this.wikiBaseUrl}/?`)||e===this.ctx.wiki.landingPageUrl}validateHrefAttr(e){return typeof e!="string"?!1:!Er.REG_SKIPPED_HREF.test(e)}parseWikiLink(e){if(!e||typeof e=="string"&&!this.validateHrefAttr(e))return null;const i=za(e);if(!this.isWikiLink(i.toString()))return null;const r=i.searchParams,n=i.hash.replace("#",""),s=r.get("action")||"view",o=r.get("title")||"",a=parseInt(r.get("curid")||"0",10),l=parseInt(r.get("oldid")||"0",10);let c=o||(()=>{try{return decodeURIComponent(i.pathname.substring(this.wikiArticlePath.length))}catch(m){return this.logger.error("parseLink",i,m),""}})();c.endsWith("index.php")&&(c="");let u,f,h;if(l)h=l;else if(a)f=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:f,revId:h,url:i,params:r,hash:n,action:s}}};Er.inject=["wiki","wikiPage"],Er.REG_SKIPPED_HREF=/^(#|javascript:|vbscript:|file:)/i;let Ps=Er;const Yh=t=>typeof t=="function";async function Qh(t){return Yh(t)?await t():t}var Xh=Object.create,Cs=Object.defineProperty,Jh=Object.getOwnPropertyDescriptor,Xa=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ja=t=>{throw TypeError(t)},Zh=(t,e,i)=>e in t?Cs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ep=(t,e)=>Cs(t,"name",{value:e,configurable:!0}),tp=t=>[,,,Xh(t?.[Xa("metadata")]??null)],ip=["class","method","getter","setter","accessor","field","value","get","set"],Za=t=>t!==void 0&&typeof t!="function"?Ja("Function expected"):t,rp=(t,e,i,r,n)=>({kind:ip[t],name:e,metadata:r,addInitializer:s=>i._?Ja("Already initialized"):n.push(Za(s||null))}),np=(t,e)=>Zh(e,Xa("metadata"),t[3]),sp=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},op=(t,e,i,r,n,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(n=n.prototype,c<5&&(c>3||!u)&&Jh(n,i));ep(n,i);for(var d=r.length-1;d>=0;d--)l=rp(c,i,a={},t[3],h),o=(0,r[d])(n,l),a._=1,Za(o)&&(n=o);return np(t,n),m&&Cs(n,i,m),u?c^4?s:m:n},el,Is,tl;el=[ve(["storage","wiki"])];class Gr extends(tl=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(){this.defineCategory({name:"general",label:"General",description:"General settings",autoGenerateForm:!0}),this.defineCategory({name:"editor",label:"Editor",description:"Settings related to editing content",autoGenerateForm:!0})}async get(e,i){if(!e)return this.getAll();i??(i=()=>{const n=this.defaultOf(e);return this.logger.debug(e,`(fallback value: ${n})`),n});const r=await this.db.get(e,void 0);return r!==null?r:await Qh(i)}async getAll(){const e=this.loadDefaultConfigs();for await(const[i,r]of this.db.entries())i!=="_touched"&&i in e&&(e[i]=r.value);return e}async set(e,i){return(await this.setMany({[e]:i}))[e]}async setMany(e){const i=this.loadDefaultConfigs(),r={};for(const[n,s]of Object.entries(e))s===i[n]||s===void 0?r[n]=void 0:r[n]=s;return await this.db.set(r),this.ctx.emit("preferences/changed",{ctx:this.ctx,input:e,changes:r}),r}defaultOf(e){var i;return(i=this._defaultPreferences)[e]??(i[e]=this.loadDefaultConfigs()[e])}async getExportableRecord(e){e??(e=await this.getAll());const i=this.loadDefaultConfigs(),r={};return Object.entries(i).sort(([n],[s])=>n.localeCompare(s)).forEach(([n,s])=>{const o=e[n];o!==void 0&&o!==s&&(r[n]=o)}),r}loadDefaultConfigs(){const e={};return this.getConfigRegistries().forEach(i=>{try{const r=i.schema({});Object.entries(r).forEach(([n,s])=>{e[n]=s})}catch{}}),Object.entries(e).forEach(([i,r])=>{this._defaultPreferences[i]=r}),e}registerCustomConfig(e,i,r){return this.customRegistries.push({name:e,schema:i,category:r||"general"}),this}getConfigRegistries(e){return Array.from(this.ctx.registry.entries()).map(([i])=>i===null?{name:"@root",schema:wi?.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 L(L.intersect(this.getConfigRegistries().map(e=>e.schema)))}defineCategory(e){const i=this.categoryDefinitions.findIndex(r=>r.name===e.name);return i<0?this.categoryDefinitions.push(e):this.categoryDefinitions[i]=e,this.categoryDefinitions.sort((r,n)=>(r.index??0)-(n.index??0)),this}getConfigCategories(){return this.categoryDefinitions}async _migrageFromLegacyMasterDB(){const e=this.ctx.storage.createDatabase("preferences",1/0);let i=0;for await(const[r,n]of e.entries())r!=="_touched"&&(await this.db.set(r,n.value),i++);return i&&this.logger.info(`Migrated ${i} preferences from master DB`),await e.clear(),await e?.db?.disconnect?.(),i}}Is=tp(tl),Gr=op(Is,0,"PreferencesService",el,Gr),sp(Is,1,Gr);var ti=(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.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))(ti||{});const $r=class $r extends Le{constructor(i){super({name:"InPageEdit"});Fi(this,_t);this.version="0.12.0",this.Endpoints=ti,this.schema=L,this.config=zi($r.DEFAULT_CONFIG,i),this.logger=ba({name:"IPE",color:"#33aaff",level:this.config.logLevel}),nt(this,_t,Rf).call(this),this.config.autoInstallCorePlugins&&nt(this,_t,Lf).call(this),nt(this,_t,Nf).call(this)}async withInject(i){const{promise:r,resolve:n}=re();return this.inject(i,s=>{n(s)}),r}};_t=new WeakSet,Rf=async function(){this.plugin($d,this.config.apiConfigs),this.plugin(Ur),this.plugin(Dd),this.plugin(Ih),this.plugin(Gr),this.plugin(Wh,{dbName:this.config.storageNamespace}),this.plugin(Vr),this.plugin($s),this.plugin(Ps),nt(this,_t,Tf).call(this,["api","currentPage","resourceLoader","modal","preferences","storage","wikiPage","wikiTitle","wiki","getUrl","getSciprtUrl","getMainpageUrl"])},Tf=function(i){if(typeof i=="string"&&(i=[i]),!Array.isArray(i)||i.length===0)return this;for(const r of i){const n=this[$r.internal][r];n?.type==="service"&&(n.builtin=!0)}return this},Lf=async function(){[Promise.resolve().then(()=>_p).then(({PluginAnalytics:r})=>r),Promise.resolve().then(()=>Rp).then(({PluginInArticleLinks:r})=>r),Promise.resolve().then(()=>yy).then(({PluginPluginStore:r})=>r),Promise.resolve().then(()=>zy).then(({PluginPreferencesUI:r})=>r),Promise.resolve().then(()=>sb).then(({PluginQuickEdit:r})=>r),Promise.resolve().then(()=>gb).then(({PluginQuickDelete:r})=>r),Promise.resolve().then(()=>Pb).then(({PluginQuickMove:r})=>r),Promise.resolve().then(()=>jb).then(({PluginQuickPreview:r})=>r),Promise.resolve().then(()=>tw).then(({PluginQuickDiff:r})=>r),Promise.resolve().then(()=>iw).then(({PluginQuickRedirect:r})=>r),Promise.resolve().then(()=>hw).then(({PluginToolbox:r})=>r)].forEach(async r=>{this.plugin(await r)})},Nf=async function(){this.inject(["resourceLoader"],i=>{})},$r.DEFAULT_CONFIG={apiConfigs:{},legacyPreferences:{},logLevel:ns.info,storageNamespace:"InPageEdit",autoloadStyles:!0,autoInstallCorePlugins:!0};let wi=$r;function il(t){return t.charAt(0).toLowerCase()+t.slice(1)}function ap(t){return il(t).replace(/_/g,"-").replace(/.[A-Z]+/g,e=>e[0]+"-"+e.slice(1).toLowerCase())}function lp(t){return il(t).replace(/-/g,"_").replace(/.[A-Z]+/g,e=>e[0]+"_"+e.slice(1).toLowerCase())}const qn=class qn{constructor(e,i=void 0,r){Fi(this,Pr);this.ctx=e,this.disposeHandlers=[],this.name=r||"",this.config=i||{};const{promise:n,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)}n.then(()=>{this.logger.debug("started")}),n.catch(a=>{this.logger.error("start failed",a),this.ctx.scope.dispose()})}),this.ctx.once("dispose",()=>{this.disposeHandlers.forEach(a=>a(this.ctx)),this.stop(),this.logger.debug("disposed")})}start(){}stop(){}addDisposeHandler(e){this.disposeHandlers.push(e)}removeDisposeHandler(e){this.disposeHandlers=this.disposeHandlers.filter(i=>i!==e)}set name(e){ze(this,Pr,lp(e).toUpperCase())}get name(){return X(this,Pr)}get logger(){return this.ctx.logger(this.name)}};Pr=new WeakMap,qn.inject=[],qn.reusable=!1;let je=qn;window.RLQ||(window.RLQ=[]),window.__IPE_MODULES__||(window.__IPE_MODULES__=[]),up("InPageEdit#autoload",()=>{const t=rl();t&&cp({baseURL:t,CoreClass:wi})});async function cp(t={baseURL:rl(),CoreClass:wi}){const{baseURL:e,CoreClass:i}=t;typeof window?.ipe?.stop=="function"&&await window.ipe.stop();const r=window.InPageEdit||{},n=new i({apiConfigs:{baseURL:e},legacyPreferences:r?.myPreferences||{}});if(window.InPageEdit=i,window.ipe=n,await n.start(),window.RLQ.push(()=>{mw.hook("InPageEdit.ready").fire(n)}),Array.isArray(window.__IPE_MODULES__)){const s=[];for(;window.__IPE_MODULES__.length;)try{const o=window.__IPE_MODULES__.shift();typeof o=="function"&&o?.(n),s.push(o)}catch{}window.__IPE_MODULES__={push:o=>{typeof o=="function"&&o(n),s.push(o)}},n.on("dispose",()=>{window.__IPE_MODULES__=s})}n.logger("AUTOLOAD").info(`
76
5
  ____ ____ ______ ___ __
77
6
  / _/___ / __ \\____ _____ ____ / ____/___/ (_) /_
78
7
  / // __ \\/ /_/ / __ \`/ __ \`/ _ \\/ __/ / __ / / __/
79
8
  _/ // / / / ____/ /_/ / /_/ / __/ /___/ /_/ / / /_
80
9
  /___/_/ /_/_/ \\__,_/\\__, /\\___/_____/\\__,_/_/\\__/
81
- /____/ v`+r.version+`
10
+ /____/ v`+n.version+`
82
11
  - Wiki API Endpoint: ${e}
83
- - Documentation: ${di.HOME_URL}
84
- - Bug Reports: ${di.GITHUB_URL}`)}function qa(){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 Rh(t,e){const i=Symbol.for(t);return window[i]?!1:(window[i]=!0,e(),!0)}var Lh=Object.create,ys=Object.defineProperty,Nh=Object.getOwnPropertyDescriptor,Ha=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),za=t=>{throw TypeError(t)},Mh=(t,e,i)=>e in t?ys(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Dh=(t,e)=>ys(t,"name",{value:e,configurable:!0}),jh=t=>[,,,Lh(t?.[Ha("metadata")]??null)],Uh=["class","method","getter","setter","accessor","field","value","get","set"],Wa=t=>t!==void 0&&typeof t!="function"?za("Function expected"):t,Fh=(t,e,i,n,r)=>({kind:Uh[t],name:e,metadata:n,addInitializer:s=>i._?za("Already initialized"):r.push(Wa(s||null))}),Bh=(t,e)=>Mh(e,Ha("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},Hh=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(r=r.prototype,c<5&&(c>3||!u)&&Nh(r,i));Dh(r,i);for(var g=n.length-1;g>=0;g--)l=Fh(c,i,a={},t[3],h),o=(0,n[g])(r,l),a._=1,Wa(o)&&(r=o);return Bh(t,r),m&&ys(r,i,m),u?c^4?s:m:r},Ka,bs,Va;Ka=[xe(["wiki","preferences"])];class Bn extends(Va=Ve){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(){this.ctx.preferences.registerCustomConfig("analytics",Y.object({"analytics._intro":Y.const(p("section",{children:[p("h3",{children:"InPageEdit Analytics"}),p("p",{children:"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."}),p("h4",{children:"What data will be collected?"}),p("ul",{style:{listStyle:"auto",paddingLeft:"1.5em"},children:[p("li",{children:"Usage data: What features you use, what pages you edit, etc."}),p("li",{children:"User information: Your username, user ID."}),p("li",{children:"Site information: The wiki you are editing."})]}),p("p",{children:p("strong",{children:"NO sensitive data will be collected."})}),p("ul",{style:{listStyle:"auto",paddingLeft:"1.5em"},children:[p("li",{children:p("a",{href:this.analyticsDashUrl,target:"_blank",rel:"noopener noreferrer",children:"Analytics Platform →"})}),p("li",{children:p("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:"My Data →"})})]})]})).role("raw-html"),"analytics.enabled":Y.boolean().description("Share my usage data with the community.").default(!1)}).description("Analytics settings"),"general")}get analyticsDashUrl(){return di.ANALYTICS_DASH_URL}get analyticsApiBase(){return di.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)}_showConfirmNotify(){localStorage.getItem("IPE:analytics/confirm-shown")||this.ctx.inject(["modal"],i=>{i.modal.notify("confirm",{title:"Enable Analytics",content:p("div",{children:[p("p",{children:"Help us improve InPageEdit by sharing your usage data with us."}),p("p",{children:"What data will be collected?"}),p("ul",{style:{listStyle:"auto",paddingLeft:"1.5em"},children:[p("li",{children:"Usage data: What features you use, what pages you edit, etc."}),p("li",{children:"User information: Your username, user ID."}),p("li",{children:"Site information: The wiki you are editing."})]}),p("p",{children:p("strong",{children:"NO sensitive data will be collected."})})]}),okBtn:{label:"Enable"},cancelBtn:{label:"Disable"},closeAfter:0,onClose(){localStorage.setItem("IPE:analytics/confirm-shown","1")}},n=>{i.preferences.set("analytics.enabled",n),n&&this.addEvent("analytics","enabled")})})}_initPluginListeners(){const e=this.ctx;e.on("in-article-links/anchor-clicked",i=>{this.addEvent("in-article-links",Ih(i.action))}),e.on("quick-delete/submit",i=>{this.addEvent("quick-delete","submit",i.wikiPage.title)}),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",i=>{this.addEvent("quick-move","submit")}),e.on("toolbox/button-clicked",i=>{this.addEvent("toolbox",`button-clicked#${i.id||"unknown"}`)})}addEvent(e,i,n){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}=ne();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()}}bs=jh(Va),Bn=Hh(bs,0,"PluginAnalytics",Ka,Bn),qh(bs,1,Bn);const zh=Object.freeze(Object.defineProperty({__proto__:null,get PluginAnalytics(){return Bn}},Symbol.toStringTag,{value:"Module"}));function pi(t){return function(e){return e.PreferencesSchema=t,e}}const Qa=t=>p("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:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),p("path",{d:"M13.5 6.5l4 4"}),p("path",{d:"M19 16l-2 3h4l-2 3"})]});var Wh=Object.create,ws=Object.defineProperty,Kh=Object.getOwnPropertyDescriptor,Ya=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ga=t=>{throw TypeError(t)},Vh=(t,e,i)=>e in t?ws(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Qh=(t,e)=>ws(t,"name",{value:e,configurable:!0}),Yh=t=>[,,,Wh(t?.[Ya("metadata")]??null)],Gh=["class","method","getter","setter","accessor","field","value","get","set"],Xa=t=>t!==void 0&&typeof t!="function"?Ga("Function expected"):t,Xh=(t,e,i,n,r)=>({kind:Gh[t],name:e,metadata:n,addInitializer:s=>i._?Ga("Already initialized"):r.push(Xa(s||null))}),Jh=(t,e)=>Vh(e,Ya("metadata"),t[3]),Zh=(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},ep=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(r=r.prototype,c<5&&(c>3||!u)&&Kh(r,i));Qh(r,i);for(var g=n.length-1;g>=0;g--)l=Xh(c,i,a={},t[3],h),o=(0,n[g])(r,l),a._=1,Xa(o)&&(r=o);return Jh(t,r),m&&ws(r,i,m),u?c^4?s:m:r},Ja,vs,Za;Ja=[xe(["wiki","wikiTitle","preferences"]),pi(Y.object({"inArticleLinks.enable":Y.boolean().description("Whether to enable in-article links").default(!0),"inArticleLinks.quickDiff.enable":Y.boolean().description("Whether to enable in-article links for quick diff").default(!0),"inArticleLinks.quickEdit.enable":Y.boolean().description("Whether to enable in-article links for quick edit").default(!0),"inArticleLinks.quickEdit.redlinks":Y.boolean().description("Whether to show quick edit button for redlinks").default(!0)}).description("In-article links preferences").extra("category","in-article-links"))];class qn extends(Za=Ve){constructor(e){super(e,{linkClassName:"ipe__in-article-link"},"InArticleLinks"),this._cachedAnchorInfo=new WeakMap,this.ctx.set("inArticleLinks",this),this.ctx.preferences.defineCategory({label:"In Article Links",name:"in-article-links",description:"In-article links preferences",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)))}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}),window?.mw?.hook?.("wikipage.content").add(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 h=l?.getPrefixedDBKey()||"",m=u.get("section")?.replace(/^T-/,"")||void 0,g=u.get("oldid"),k=u.has("redlink");let D;m==="new"||l?.isSpecial("newsection")?D="new":m&&/^\d+$/.test(m)&&(D=parseInt(m,10));const T=g?parseInt(g,10):void 0,A={title:h,pageId:c||void 0,section:D,revision:T,createOnly:k},b=p("a",{href:"#ipe://quick-edit/",dataset:A,className:`${this.config.linkClassName} ipe-quick-edit ${k?"ipe-quick-edit--create-only":""}`,style:{userSelect:"none",marginLeft:"0.2em"},onClick:d=>{d.preventDefault(),this.ctx.emit("in-article-links/anchor-clicked",{ctx:this.ctx,anchor:a,info:o,event:d,action:"quickEdit"}),n.quickEdit.showModal(A)},children:p(Qa,{className:"ipe-icon"})});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}),window?.mw?.hook?.("wikipage.content").add(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,f;if(l?.getNamespaceId()===-1?([,f,u]=l.getMainDBKey().split("/"),u||(u="prev")):(u=c.get("diff"),f=c.get("oldid")),!u||!f)return;const h={};i(u)?(h.fromrev=parseInt(f),h.torelative=u):(h.fromrev=parseInt(f),h.torev=parseInt(u));const m=p("a",{href:"#ipe://quick-diff/",dataset:h,className:`${this.config.linkClassName} ipe-quick-diff`,style:{userSelect:"none",marginLeft:"0.2em"},onClick:g=>{g.preventDefault(),this.ctx.emit("in-article-links/anchor-clicked",{ctx:this.ctx,anchor:a,info:o,event:g,action:"quickDiff"}),n.quickDiff.comparePages(h)},children:p("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-diff ipe-icon",children:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),p("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"}),p("path",{d:"M12 10l0 4"}),p("path",{d:"M10 12l4 0"}),p("path",{d:"M10 17l4 0"})]})});a.insertAdjacentElement("afterend",m)})})})}}vs=Yh(Za),qn=ep(vs,0,"PluginInArticleLinks",Ja,qn),Zh(vs,1,qn);const tp=Object.freeze(Object.defineProperty({__proto__:null,get PluginInArticleLinks(){return qn}},Symbol.toStringTag,{value:"Module"}));/**
85
- * @vue/shared v3.5.22
86
- * (c) 2018-present Yuxi (Evan) You and Vue contributors
87
- * @license MIT
88
- **/function _s(t){const e=Object.create(null);for(const i of t.split(","))e[i]=1;return i=>i in e}const re={},mi=[],dt=()=>{},el=()=>!1,Hn=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&(t.charCodeAt(2)>122||t.charCodeAt(2)<97),xs=t=>t.startsWith("onUpdate:"),$e=Object.assign,Ss=(t,e)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)},ip=Object.prototype.hasOwnProperty,se=(t,e)=>ip.call(t,e),K=Array.isArray,gi=t=>zn(t)==="[object Map]",tl=t=>zn(t)==="[object Set]",Q=t=>typeof t=="function",be=t=>typeof t=="string",Ut=t=>typeof t=="symbol",de=t=>t!==null&&typeof t=="object",il=t=>(de(t)||Q(t))&&Q(t.then)&&Q(t.catch),nl=Object.prototype.toString,zn=t=>nl.call(t),np=t=>zn(t).slice(8,-1),rl=t=>zn(t)==="[object Object]",ks=t=>be(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,Vi=_s(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),Wn=t=>{const e=Object.create(null);return i=>e[i]||(e[i]=t(i))},rp=/-\w/g,It=Wn(t=>t.replace(rp,e=>e.slice(1).toUpperCase())),sp=/\B([A-Z])/g,Ft=Wn(t=>t.replace(sp,"-$1").toLowerCase()),sl=Wn(t=>t.charAt(0).toUpperCase()+t.slice(1)),Es=Wn(t=>t?`on${sl(t)}`:""),Fe=(t,e)=>!Object.is(t,e),$s=(t,...e)=>{for(let i=0;i<t.length;i++)t[i](...e)},ol=(t,e,i,n=!1)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:n,value:i})},op=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let al;const Kn=()=>al||(al=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Ps(t){if(K(t)){const e={};for(let i=0;i<t.length;i++){const n=t[i],r=be(n)?up(n):Ps(n);if(r)for(const s in r)e[s]=r[s]}return e}else if(be(t)||de(t))return t}const ap=/;(?![^(]*\))/g,lp=/:([^]+)/,cp=/\/\*[^]*?\*\//g;function up(t){const e={};return t.replace(cp,"").split(ap).forEach(i=>{if(i){const n=i.split(lp);n.length>1&&(e[n[0].trim()]=n[1].trim())}}),e}function Vn(t){let e="";if(be(t))e=t;else if(K(t))for(let i=0;i<t.length;i++){const n=Vn(t[i]);n&&(e+=n+" ")}else if(de(t))for(const i in t)t[i]&&(e+=i+" ");return e.trim()}const fp=_s("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly");function ll(t){return!!t||t===""}const cl=t=>!!(t&&t.__v_isRef===!0),Cs=t=>be(t)?t:t==null?"":K(t)||de(t)&&(t.toString===nl||!Q(t.toString))?cl(t)?Cs(t.value):JSON.stringify(t,ul,2):String(t),ul=(t,e)=>cl(e)?ul(t,e.value):gi(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((i,[n,r],s)=>(i[Os(n,s)+" =>"]=r,i),{})}:tl(e)?{[`Set(${e.size})`]:[...e.values()].map(i=>Os(i))}:Ut(e)?Os(e):de(e)&&!K(e)&&!rl(e)?String(e):e,Os=(t,e="")=>{var i;return Ut(t)?`Symbol(${(i=t.description)!=null?i:e})`:t};/**
89
- * @vue/reactivity v3.5.22
90
- * (c) 2018-present Yuxi (Evan) You and Vue contributors
91
- * @license MIT
92
- **/let Be;class dp{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.parent=Be,!e&&Be&&(this.index=(Be.scopes||(Be.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=Be;try{return Be=this,e()}finally{Be=i}}}on(){++this._on===1&&(this.prevScope=Be,Be=this)}off(){this._on>0&&--this._on===0&&(Be=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 hp(){return Be}let ce;const Is=new WeakSet;class fl{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,Be&&Be.active&&Be.effects.push(this)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,Is.has(this)&&(Is.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||hl(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,bl(this),pl(this);const e=ce,i=ot;ce=this,ot=!0;try{return this.fn()}finally{ml(this),ce=e,ot=i,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)Ls(e);this.deps=this.depsTail=void 0,bl(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?Is.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){Rs(this)&&this.run()}get dirty(){return Rs(this)}}let dl=0,Qi,Yi;function hl(t,e=!1){if(t.flags|=8,e){t.next=Yi,Yi=t;return}t.next=Qi,Qi=t}function As(){dl++}function Ts(){if(--dl>0)return;if(Yi){let e=Yi;for(Yi=void 0;e;){const i=e.next;e.next=void 0,e.flags&=-9,e=i}}let t;for(;Qi;){let e=Qi;for(Qi=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 pl(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function ml(t){let e,i=t.depsTail,n=i;for(;n;){const r=n.prevDep;n.version===-1?(n===i&&(i=r),Ls(n),pp(n)):e=n,n.dep.activeLink=n.prevActiveLink,n.prevActiveLink=void 0,n=r}t.deps=e,t.depsTail=i}function Rs(t){for(let e=t.deps;e;e=e.nextDep)if(e.dep.version!==e.version||e.dep.computed&&(gl(e.dep.computed)||e.dep.version!==e.version))return!0;return!!t._dirty}function gl(t){if(t.flags&4&&!(t.flags&16)||(t.flags&=-17,t.globalVersion===Gi)||(t.globalVersion=Gi,!t.isSSR&&t.flags&128&&(!t.deps&&!t._dirty||!Rs(t))))return;t.flags|=2;const e=t.dep,i=ce,n=ot;ce=t,ot=!0;try{pl(t);const r=t.fn(t._value);(e.version===0||Fe(r,t._value))&&(t.flags|=128,t._value=r,e.version++)}catch(r){throw e.version++,r}finally{ce=i,ot=n,ml(t),t.flags&=-3}}function Ls(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)Ls(s,!0)}!e&&!--i.sc&&i.map&&i.map.delete(i.key)}function pp(t){const{prevDep:e,nextDep:i}=t;e&&(e.nextDep=i,t.prevDep=void 0),i&&(i.prevDep=e,t.nextDep=void 0)}let ot=!0;const yl=[];function ht(){yl.push(ot),ot=!1}function pt(){const t=yl.pop();ot=t===void 0?!0:t}function bl(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const i=ce;ce=void 0;try{e()}finally{ce=i}}}let Gi=0;class mp{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 Qn{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(!ce||!ot||ce===this.computed)return;let i=this.activeLink;if(i===void 0||i.sub!==ce)i=this.activeLink=new mp(ce,this),ce.deps?(i.prevDep=ce.depsTail,ce.depsTail.nextDep=i,ce.depsTail=i):ce.deps=ce.depsTail=i,wl(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=ce.depsTail,i.nextDep=void 0,ce.depsTail.nextDep=i,ce.depsTail=i,ce.deps===i&&(ce.deps=n)}return i}trigger(e){this.version++,Gi++,this.notify(e)}notify(e){As();try{for(let i=this.subs;i;i=i.prevSub)i.sub.notify()&&i.sub.dep.notify()}finally{Ts()}}}function wl(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)wl(n)}const i=t.dep.subs;i!==t&&(t.prevSub=i,i&&(i.nextSub=t)),t.dep.subs=t}}const Ns=new WeakMap,Zt=Symbol(""),Ms=Symbol(""),Xi=Symbol("");function Ie(t,e,i){if(ot&&ce){let n=Ns.get(t);n||Ns.set(t,n=new Map);let r=n.get(i);r||(n.set(i,r=new Qn),r.map=n,r.key=i),r.track()}}function At(t,e,i,n,r,s){const o=Ns.get(t);if(!o){Gi++;return}const a=l=>{l&&l.trigger()};if(As(),e==="clear")o.forEach(a);else{const l=K(t),c=l&&ks(i);if(l&&i==="length"){const u=Number(n);o.forEach((f,h)=>{(h==="length"||h===Xi||!Ut(h)&&h>=u)&&a(f)})}else switch((i!==void 0||o.has(void 0))&&a(o.get(i)),c&&a(o.get(Xi)),e){case"add":l?c&&a(o.get("length")):(a(o.get(Zt)),gi(t)&&a(o.get(Ms)));break;case"delete":l||(a(o.get(Zt)),gi(t)&&a(o.get(Ms)));break;case"set":gi(t)&&a(o.get(Zt));break}}Ts()}function yi(t){const e=te(t);return e===t?e:(Ie(e,"iterate",Xi),Ze(t)?e:e.map(Pe))}function Yn(t){return Ie(t=te(t),"iterate",Xi),t}const gp={__proto__:null,[Symbol.iterator](){return Ds(this,Symbol.iterator,Pe)},concat(...t){return yi(this).concat(...t.map(e=>K(e)?yi(e):e))},entries(){return Ds(this,"entries",t=>(t[1]=Pe(t[1]),t))},every(t,e){return Tt(this,"every",t,e,void 0,arguments)},filter(t,e){return Tt(this,"filter",t,e,i=>i.map(Pe),arguments)},find(t,e){return Tt(this,"find",t,e,Pe,arguments)},findIndex(t,e){return Tt(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return Tt(this,"findLast",t,e,Pe,arguments)},findLastIndex(t,e){return Tt(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return Tt(this,"forEach",t,e,void 0,arguments)},includes(...t){return js(this,"includes",t)},indexOf(...t){return js(this,"indexOf",t)},join(t){return yi(this).join(t)},lastIndexOf(...t){return js(this,"lastIndexOf",t)},map(t,e){return Tt(this,"map",t,e,void 0,arguments)},pop(){return Ji(this,"pop")},push(...t){return Ji(this,"push",t)},reduce(t,...e){return vl(this,"reduce",t,e)},reduceRight(t,...e){return vl(this,"reduceRight",t,e)},shift(){return Ji(this,"shift")},some(t,e){return Tt(this,"some",t,e,void 0,arguments)},splice(...t){return Ji(this,"splice",t)},toReversed(){return yi(this).toReversed()},toSorted(t){return yi(this).toSorted(t)},toSpliced(...t){return yi(this).toSpliced(...t)},unshift(...t){return Ji(this,"unshift",t)},values(){return Ds(this,"values",Pe)}};function Ds(t,e,i){const n=Yn(t),r=n[e]();return n!==t&&!Ze(t)&&(r._next=r.next,r.next=()=>{const s=r._next();return s.done||(s.value=i(s.value)),s}),r}const yp=Array.prototype;function Tt(t,e,i,n,r,s){const o=Yn(t),a=o!==t&&!Ze(t),l=o[e];if(l!==yp[e]){const f=l.apply(t,s);return a?Pe(f):f}let c=i;o!==t&&(a?c=function(f,h){return i.call(this,Pe(f),h,t)}:i.length>2&&(c=function(f,h){return i.call(this,f,h,t)}));const u=l.call(o,c,n);return a&&r?r(u):u}function vl(t,e,i,n){const r=Yn(t);let s=i;return r!==t&&(Ze(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,Pe(a),l,t)}),r[e](s,...n)}function js(t,e,i){const n=te(t);Ie(n,"iterate",Xi);const r=n[e](...i);return(r===-1||r===!1)&&qs(i[0])?(i[0]=te(i[0]),n[e](...i)):r}function Ji(t,e,i=[]){ht(),As();const n=te(t)[e].apply(t,i);return Ts(),pt(),n}const bp=_s("__proto__,__v_isRef,__isVue"),_l=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(Ut));function wp(t){Ut(t)||(t=String(t));const e=te(this);return Ie(e,"has",t),e.hasOwnProperty(t)}class xl{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?Cl:Pl:s?$l:El).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;const o=K(e);if(!r){let l;if(o&&(l=gp[i]))return l;if(i==="hasOwnProperty")return wp}const a=Reflect.get(e,i,ke(e)?e:n);if((Ut(i)?_l.has(i):bp(i))||(r||Ie(e,"get",i),s))return a;if(ke(a)){const l=o&&ks(i)?a:a.value;return r&&de(l)?Bs(l):l}return de(a)?r?Bs(a):Fs(a):a}}class Sl extends xl{constructor(e=!1){super(!1,e)}set(e,i,n,r){let s=e[i];if(!this._isShallow){const l=Bt(s);if(!Ze(n)&&!Bt(n)&&(s=te(s),n=te(n)),!K(e)&&ke(s)&&!ke(n))return l||(s.value=n),!0}const o=K(e)&&ks(i)?Number(i)<e.length:se(e,i),a=Reflect.set(e,i,n,ke(e)?e:r);return e===te(r)&&(o?Fe(n,s)&&At(e,"set",i,n):At(e,"add",i,n)),a}deleteProperty(e,i){const n=se(e,i);e[i];const r=Reflect.deleteProperty(e,i);return r&&n&&At(e,"delete",i,void 0),r}has(e,i){const n=Reflect.has(e,i);return(!Ut(i)||!_l.has(i))&&Ie(e,"has",i),n}ownKeys(e){return Ie(e,"iterate",K(e)?"length":Zt),Reflect.ownKeys(e)}}class kl extends xl{constructor(e=!1){super(!0,e)}set(e,i){return!0}deleteProperty(e,i){return!0}}const vp=new Sl,_p=new kl,xp=new Sl(!0),Sp=new kl(!0),Us=t=>t,Gn=t=>Reflect.getPrototypeOf(t);function kp(t,e,i){return function(...n){const r=this.__v_raw,s=te(r),o=gi(s),a=t==="entries"||t===Symbol.iterator&&o,l=t==="keys"&&o,c=r[t](...n),u=i?Us:e?er:Pe;return!e&&Ie(s,"iterate",l?Ms:Zt),{next(){const{value:f,done:h}=c.next();return h?{value:f,done:h}:{value:a?[u(f[0]),u(f[1])]:u(f),done:h}},[Symbol.iterator](){return this}}}}function Xn(t){return function(...e){return t==="delete"?!1:t==="clear"?void 0:this}}function Ep(t,e){const i={get(r){const s=this.__v_raw,o=te(s),a=te(r);t||(Fe(r,a)&&Ie(o,"get",r),Ie(o,"get",a));const{has:l}=Gn(o),c=e?Us:t?er:Pe;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&&Ie(te(r),"iterate",Zt),r.size},has(r){const s=this.__v_raw,o=te(s),a=te(r);return t||(Fe(r,a)&&Ie(o,"has",r),Ie(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=te(a),c=e?Us:t?er:Pe;return!t&&Ie(l,"iterate",Zt),a.forEach((u,f)=>r.call(s,c(u),c(f),o))}};return $e(i,t?{add:Xn("add"),set:Xn("set"),delete:Xn("delete"),clear:Xn("clear")}:{add(r){!e&&!Ze(r)&&!Bt(r)&&(r=te(r));const s=te(this);return Gn(s).has.call(s,r)||(s.add(r),At(s,"add",r,r)),this},set(r,s){!e&&!Ze(s)&&!Bt(s)&&(s=te(s));const o=te(this),{has:a,get:l}=Gn(o);let c=a.call(o,r);c||(r=te(r),c=a.call(o,r));const u=l.call(o,r);return o.set(r,s),c?Fe(s,u)&&At(o,"set",r,s):At(o,"add",r,s),this},delete(r){const s=te(this),{has:o,get:a}=Gn(s);let l=o.call(s,r);l||(r=te(r),l=o.call(s,r)),a&&a.call(s,r);const c=s.delete(r);return l&&At(s,"delete",r,void 0),c},clear(){const r=te(this),s=r.size!==0,o=r.clear();return s&&At(r,"clear",void 0,void 0),o}}),["keys","values","entries",Symbol.iterator].forEach(r=>{i[r]=kp(r,t,e)}),i}function Jn(t,e){const i=Ep(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 $p={get:Jn(!1,!1)},Pp={get:Jn(!1,!0)},Cp={get:Jn(!0,!1)},Op={get:Jn(!0,!0)},El=new WeakMap,$l=new WeakMap,Pl=new WeakMap,Cl=new WeakMap;function Ip(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function Ap(t){return t.__v_skip||!Object.isExtensible(t)?0:Ip(np(t))}function Fs(t){return Bt(t)?t:Zn(t,!1,vp,$p,El)}function Tp(t){return Zn(t,!1,xp,Pp,$l)}function Bs(t){return Zn(t,!0,_p,Cp,Pl)}function qb(t){return Zn(t,!0,Sp,Op,Cl)}function Zn(t,e,i,n,r){if(!de(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const s=Ap(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 bi(t){return Bt(t)?bi(t.__v_raw):!!(t&&t.__v_isReactive)}function Bt(t){return!!(t&&t.__v_isReadonly)}function Ze(t){return!!(t&&t.__v_isShallow)}function qs(t){return t?!!t.__v_raw:!1}function te(t){const e=t&&t.__v_raw;return e?te(e):t}function Rp(t){return!se(t,"__v_skip")&&Object.isExtensible(t)&&ol(t,"__v_skip",!0),t}const Pe=t=>de(t)?Fs(t):t,er=t=>de(t)?Bs(t):t;function ke(t){return t?t.__v_isRef===!0:!1}function Ol(t){return Il(t,!1)}function tr(t){return Il(t,!0)}function Il(t,e){return ke(t)?t:new Lp(t,e)}class Lp{constructor(e,i){this.dep=new Qn,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=i?e:te(e),this._value=i?e:Pe(e),this.__v_isShallow=i}get value(){return this.dep.track(),this._value}set value(e){const i=this._rawValue,n=this.__v_isShallow||Ze(e)||Bt(e);e=n?e:te(e),Fe(e,i)&&(this._rawValue=e,this._value=n?e:Pe(e),this.dep.trigger())}}function Hs(t){return ke(t)?t.value:t}const Np={get:(t,e,i)=>e==="__v_raw"?t:Hs(Reflect.get(t,e,i)),set:(t,e,i,n)=>{const r=t[e];return ke(r)&&!ke(i)?(r.value=i,!0):Reflect.set(t,e,i,n)}};function Al(t){return bi(t)?t:new Proxy(t,Np)}class Mp{constructor(e){this.__v_isRef=!0,this._value=void 0;const i=this.dep=new Qn,{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 Dp(t){return new Mp(t)}class jp{constructor(e,i,n){this.fn=e,this.setter=i,this._value=void 0,this.dep=new Qn(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=Gi-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!i,this.isSSR=n}notify(){if(this.flags|=16,!(this.flags&8)&&ce!==this)return hl(this,!0),!0}get value(){const e=this.dep.track();return gl(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}}function Up(t,e,i=!1){let n,r;return Q(t)?n=t:(n=t.get,r=t.set),new jp(n,r,i)}const ir={},nr=new WeakMap;let ei;function Fp(t,e=!1,i=ei){if(i){let n=nr.get(i);n||nr.set(i,n=[]),n.push(t)}}function Bp(t,e,i=re){const{immediate:n,deep:r,once:s,scheduler:o,augmentJob:a,call:l}=i,c=d=>r?d:Ze(d)||r===!1||r===0?qt(d,1):qt(d);let u,f,h,m,g=!1,k=!1;if(ke(t)?(f=()=>t.value,g=Ze(t)):bi(t)?(f=()=>c(t),g=!0):K(t)?(k=!0,g=t.some(d=>bi(d)||Ze(d)),f=()=>t.map(d=>{if(ke(d))return d.value;if(bi(d))return c(d);if(Q(d))return l?l(d,2):d()})):Q(t)?e?f=l?()=>l(t,2):t:f=()=>{if(h){ht();try{h()}finally{pt()}}const d=ei;ei=u;try{return l?l(t,3,[m]):t(m)}finally{ei=d}}:f=dt,e&&r){const d=f,y=r===!0?1/0:r;f=()=>qt(d(),y)}const D=hp(),T=()=>{u.stop(),D&&D.active&&Ss(D.effects,u)};if(s&&e){const d=e;e=(...y)=>{d(...y),T()}}let A=k?new Array(t.length).fill(ir):ir;const b=d=>{if(!(!(u.flags&1)||!u.dirty&&!d))if(e){const y=u.run();if(r||g||(k?y.some((v,x)=>Fe(v,A[x])):Fe(y,A))){h&&h();const v=ei;ei=u;try{const x=[y,A===ir?void 0:k&&A[0]===ir?[]:A,m];A=y,l?l(e,3,x):e(...x)}finally{ei=v}}}else u.run()};return a&&a(b),u=new fl(f),u.scheduler=o?()=>o(b,!1):b,m=d=>Fp(d,!1,u),h=u.onStop=()=>{const d=nr.get(u);if(d){if(l)l(d,4);else for(const y of d)y();nr.delete(u)}},e?n?b(!0):A=u.run():o?o(b.bind(null,!0),!0):u.run(),T.pause=u.pause.bind(u),T.resume=u.resume.bind(u),T.stop=T,T}function qt(t,e=1/0,i){if(e<=0||!de(t)||t.__v_skip||(i=i||new Map,(i.get(t)||0)>=e))return t;if(i.set(t,e),e--,ke(t))qt(t.value,e,i);else if(K(t))for(let n=0;n<t.length;n++)qt(t[n],e,i);else if(tl(t)||gi(t))t.forEach(n=>{qt(n,e,i)});else if(rl(t)){for(const n in t)qt(t[n],e,i);for(const n of Object.getOwnPropertySymbols(t))Object.prototype.propertyIsEnumerable.call(t,n)&&qt(t[n],e,i)}return t}/**
93
- * @vue/runtime-core v3.5.22
94
- * (c) 2018-present Yuxi (Evan) You and Vue contributors
95
- * @license MIT
96
- **/const Zi=[];let zs=!1;function Hb(t,...e){if(zs)return;zs=!0,ht();const i=Zi.length?Zi[Zi.length-1].component:null,n=i&&i.appContext.config.warnHandler,r=qp();if(n)wi(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 <${Ac(i,s.type)}>`).join(`
97
- `),r]);else{const s=[`[Vue warn]: ${t}`,...e];r.length&&s.push(`
98
- `,...Hp(r))}pt(),zs=!1}function qp(){let t=Zi[Zi.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 Hp(t){const e=[];return t.forEach((i,n)=>{e.push(...n===0?[]:[`
99
- `],...zp(i))}),e}function zp({vnode:t,recurseCount:e}){const i=e>0?`... (${e} recursive calls)`:"",n=t.component?t.component.parent==null:!1,r=` at <${Ac(t.component,t.type,n)}`,s=">"+i;return t.props?[r,...Wp(t.props),s]:[r+s]}function Wp(t){const e=[],i=Object.keys(t);return i.slice(0,3).forEach(n=>{e.push(...Tl(n,t[n]))}),i.length>3&&e.push(" ..."),e}function Tl(t,e,i){return be(e)?(e=JSON.stringify(e),i?e:[`${t}=${e}`]):typeof e=="number"||typeof e=="boolean"||e==null?i?e:[`${t}=${e}`]:ke(e)?(e=Tl(t,te(e.value),!0),i?e:[`${t}=Ref<`,e,">"]):Q(e)?[`${t}=fn${e.name?`<${e.name}>`:""}`]:(e=te(e),i?e:[`${t}=`,e])}function wi(t,e,i,n){try{return n?t(...n):t()}catch(r){rr(r,e,i)}}function mt(t,e,i,n){if(Q(t)){const r=wi(t,e,i,n);return r&&il(r)&&r.catch(s=>{rr(s,e,i)}),r}if(K(t)){const r=[];for(let s=0;s<t.length;s++)r.push(mt(t[s],e,i,n));return r}}function rr(t,e,i,n=!0){const r=e?e.vnode:null,{errorHandler:s,throwUnhandledErrorInProduction:o}=e&&e.appContext.config||re;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 f=0;f<u.length;f++)if(u[f](t,l,c)===!1)return}a=a.parent}if(s){ht(),wi(s,null,10,[t,l,c]),pt();return}}Kp(t,i,r,n,o)}function Kp(t,e,i,n=!0,r=!1){if(r)throw t}const Te=[];let gt=-1;const vi=[];let Ht=null,_i=0;const Rl=Promise.resolve();let sr=null;function or(t){const e=sr||Rl;return t?e.then(this?t.bind(this):t):e}function Vp(t){let e=gt+1,i=Te.length;for(;e<i;){const n=e+i>>>1,r=Te[n],s=en(r);s<t||s===t&&r.flags&2?e=n+1:i=n}return e}function Ws(t){if(!(t.flags&1)){const e=en(t),i=Te[Te.length-1];!i||!(t.flags&2)&&e>=en(i)?Te.push(t):Te.splice(Vp(e),0,t),t.flags|=1,Ll()}}function Ll(){sr||(sr=Rl.then(Dl))}function Qp(t){K(t)?vi.push(...t):Ht&&t.id===-1?Ht.splice(_i+1,0,t):t.flags&1||(vi.push(t),t.flags|=1),Ll()}function Nl(t,e,i=gt+1){for(;i<Te.length;i++){const n=Te[i];if(n&&n.flags&2){if(t&&n.id!==t.uid)continue;Te.splice(i,1),i--,n.flags&4&&(n.flags&=-2),n(),n.flags&4||(n.flags&=-2)}}}function Ml(t){if(vi.length){const e=[...new Set(vi)].sort((i,n)=>en(i)-en(n));if(vi.length=0,Ht){Ht.push(...e);return}for(Ht=e,_i=0;_i<Ht.length;_i++){const i=Ht[_i];i.flags&4&&(i.flags&=-2),i.flags&8||i(),i.flags&=-2}Ht=null,_i=0}}const en=t=>t.id==null?t.flags&2?-1:1/0:t.id;function Dl(t){try{for(gt=0;gt<Te.length;gt++){const e=Te[gt];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),wi(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;gt<Te.length;gt++){const e=Te[gt];e&&(e.flags&=-2)}gt=-1,Te.length=0,Ml(),sr=null,(Te.length||vi.length)&&Dl()}}let yt=null,jl=null;function ar(t){const e=yt;return yt=t,jl=t&&t.type.__scopeId||null,e}function Yp(t,e=yt,i){if(!e||t._n)return t;const n=(...r)=>{n._d&&_c(-1);const s=ar(e);let o;try{o=t(...r)}finally{ar(s),n._d&&_c(1)}return o};return n._n=!0,n._c=!0,n._d=!0,n}function ti(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&&(ht(),mt(l,i,8,[t.el,a,t,e]),pt())}}const Gp=Symbol("_vte"),Xp=t=>t.__isTeleport,Jp=Symbol("_leaveCb");function Ks(t,e){t.shapeFlag&6&&t.component?(t.transition=e,Ks(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 Ul(t,e){return Q(t)?$e({name:t.name},e,{setup:t}):t}function Fl(t){t.ids=[t.ids[0]+t.ids[2]+++"-",0,0]}function Zp(t){const e=so(),i=tr(null);if(e){const r=e.refs===re?e.refs={}:e.refs;Object.defineProperty(r,t,{enumerable:!0,get:()=>i.value,set:s=>i.value=s})}return i}const lr=new WeakMap;function tn(t,e,i,n,r=!1){if(K(t)){t.forEach((g,k)=>tn(g,e&&(K(e)?e[k]:e),i,n,r));return}if(nn(n)&&!r){n.shapeFlag&512&&n.type.__asyncResolved&&n.component.subTree.component&&tn(t,e,i,n.component.subTree);return}const s=n.shapeFlag&4?ao(n.component):n.el,o=r?null:s,{i:a,r:l}=t,c=e&&e.r,u=a.refs===re?a.refs={}:a.refs,f=a.setupState,h=te(f),m=f===re?el:g=>se(h,g);if(c!=null&&c!==l){if(Bl(e),be(c))u[c]=null,m(c)&&(f[c]=null);else if(ke(c)){c.value=null;const g=e;g.k&&(u[g.k]=null)}}if(Q(l))wi(l,a,12,[o,u]);else{const g=be(l),k=ke(l);if(g||k){const D=()=>{if(t.f){const T=g?m(l)?f[l]:u[l]:l.value;if(r)K(T)&&Ss(T,s);else if(K(T))T.includes(s)||T.push(s);else if(g)u[l]=[s],m(l)&&(f[l]=u[l]);else{const A=[s];l.value=A,t.k&&(u[t.k]=A)}}else g?(u[l]=o,m(l)&&(f[l]=o)):k&&(l.value=o,t.k&&(u[t.k]=o))};if(o){const T=()=>{D(),lr.delete(t)};T.id=-1,lr.set(t,T),Qe(T,i)}else Bl(t),D()}}}function Bl(t){const e=lr.get(t);e&&(e.flags|=8,lr.delete(t))}Kn().requestIdleCallback,Kn().cancelIdleCallback;const nn=t=>!!t.type.__asyncLoader,ql=t=>t.type.__isKeepAlive;function em(t,e){Hl(t,"a",e)}function tm(t,e){Hl(t,"da",e)}function Hl(t,e,i=Le){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;)ql(r.parent.vnode)&&im(n,e,i,r),r=r.parent}}function im(t,e,i,n){const r=cr(e,t,n,!0);Kl(()=>{Ss(n[e],r)},i)}function cr(t,e,i=Le,n=!1){if(i){const r=i[t]||(i[t]=[]),s=e.__weh||(e.__weh=(...o)=>{ht();const a=un(i),l=mt(e,i,t,o);return a(),pt(),l});return n?r.unshift(s):r.push(s),s}}const Rt=t=>(e,i=Le)=>{(!fn||t==="sp")&&cr(t,(...n)=>e(...n),i)},zl=Rt("bm"),Vs=Rt("m"),nm=Rt("bu"),rm=Rt("u"),Wl=Rt("bum"),Kl=Rt("um"),sm=Rt("sp"),om=Rt("rtg"),am=Rt("rtc");function lm(t,e=Le){cr("ec",t,e)}const cm=Symbol.for("v-ndc");function Vl(t,e,i,n){let r;const s=i,o=K(t);if(o||be(t)){const a=o&&bi(t);let l=!1,c=!1;a&&(l=!Ze(t),c=Bt(t),t=Yn(t)),r=new Array(t.length);for(let u=0,f=t.length;u<f;u++)r[u]=e(l?c?er(Pe(t[u])):Pe(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(de(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}const Qs=t=>t?Cc(t)?ao(t):Qs(t.parent):null,rn=$e(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=>Qs(t.parent),$root:t=>Qs(t.root),$host:t=>t.ce,$emit:t=>t.emit,$options:t=>Xl(t),$forceUpdate:t=>t.f||(t.f=()=>{Ws(t.update)}),$nextTick:t=>t.n||(t.n=or.bind(t.proxy)),$watch:t=>Am.bind(t)}),Ys=(t,e)=>t!==re&&!t.__isScriptSetup&&se(t,e),um={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 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(Ys(n,e))return o[e]=1,n[e];if(r!==re&&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!==re&&se(i,e))return o[e]=4,i[e];Gs&&(o[e]=0)}}const u=rn[e];let f,h;if(u)return e==="$attrs"&&Ie(t.attrs,"get",""),u(t);if((f=a.__cssModules)&&(f=f[e]))return f;if(i!==re&&se(i,e))return o[e]=4,i[e];if(h=l.config.globalProperties,se(h,e))return h[e]},set({_:t},e,i){const{data:n,setupState:r,ctx:s}=t;return Ys(r,e)?(r[e]=i,!0):n!==re&&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!==re&&a[0]!=="$"&&se(t,a)||Ys(e,a)||(l=s[0])&&se(l,a)||se(n,a)||se(rn,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 ur(t){return K(t)?t.reduce((e,i)=>(e[i]=null,e),{}):t}function Ql(t,e){return!t||!e?t||e:K(t)&&K(e)?t.concat(e):$e({},ur(t),ur(e))}let Gs=!0;function fm(t){const e=Xl(t),i=t.proxy,n=t.ctx;Gs=!1,e.beforeCreate&&Yl(e.beforeCreate,t,"bc");const{data:r,computed:s,methods:o,watch:a,provide:l,inject:c,created:u,beforeMount:f,mounted:h,beforeUpdate:m,updated:g,activated:k,deactivated:D,beforeDestroy:T,beforeUnmount:A,destroyed:b,unmounted:d,render:y,renderTracked:v,renderTriggered:x,errorCaptured:E,serverPrefetch:L,expose:B,inheritAttrs:Ce,components:Ne,directives:Ee,filters:we}=e;if(c&&dm(c,n,null),o)for(const le in o){const G=o[le];Q(G)&&(n[le]=G.bind(i))}if(r){const le=r.call(i,i);de(le)&&(t.data=Fs(le))}if(Gs=!0,s)for(const le in s){const G=s[le],it=Q(G)?G.bind(i,i):Q(G.get)?G.get.bind(i,i):dt,Tr=!Q(G)&&Q(G.set)?G.set.bind(i):dt,ai=Tc({get:it,set:Tr});Object.defineProperty(n,le,{enumerable:!0,configurable:!0,get:()=>ai.value,set:xt=>ai.value=xt})}if(a)for(const le in a)Gl(a[le],n,i,le);if(l){const le=Q(l)?l.call(i):l;Reflect.ownKeys(le).forEach(G=>{tc(G,le[G])})}u&&Yl(u,t,"c");function ae(le,G){K(G)?G.forEach(it=>le(it.bind(i))):G&&le(G.bind(i))}if(ae(zl,f),ae(Vs,h),ae(nm,m),ae(rm,g),ae(em,k),ae(tm,D),ae(lm,E),ae(am,v),ae(om,x),ae(Wl,A),ae(Kl,d),ae(sm,L),K(B))if(B.length){const le=t.exposed||(t.exposed={});B.forEach(G=>{Object.defineProperty(le,G,{get:()=>i[G],set:it=>i[G]=it,enumerable:!0})})}else t.exposed||(t.exposed={});y&&t.render===dt&&(t.render=y),Ce!=null&&(t.inheritAttrs=Ce),Ne&&(t.components=Ne),Ee&&(t.directives=Ee),L&&Fl(t)}function dm(t,e,i=dt){K(t)&&(t=Xs(t));for(const n in t){const r=t[n];let s;de(r)?"default"in r?s=on(r.from||n,r.default,!0):s=on(r.from||n):s=on(r),ke(s)?Object.defineProperty(e,n,{enumerable:!0,configurable:!0,get:()=>s.value,set:o=>s.value=o}):e[n]=s}}function Yl(t,e,i){mt(K(t)?t.map(n=>n.bind(e.proxy)):t.bind(e.proxy),e,i)}function Gl(t,e,i,n){let r=n.includes(".")?pc(i,n):()=>i[n];if(be(t)){const s=e[t];Q(s)&&Si(r,s)}else if(Q(t))Si(r,t.bind(i));else if(de(t))if(K(t))t.forEach(s=>Gl(s,e,i,n));else{const s=Q(t.handler)?t.handler.bind(i):e[t.handler];Q(s)&&Si(r,s,t)}}function Xl(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=>fr(l,c,o,!0)),fr(l,e,o)),de(e)&&s.set(e,l),l}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=hm[o]||i&&i[o];t[o]=a?a(t[o],e[o]):e[o]}return t}const hm={data:Jl,props:Zl,emits:Zl,methods:sn,computed:sn,beforeCreate:Re,created:Re,beforeMount:Re,mounted:Re,beforeUpdate:Re,updated:Re,beforeDestroy:Re,beforeUnmount:Re,destroyed:Re,unmounted:Re,activated:Re,deactivated:Re,errorCaptured:Re,serverPrefetch:Re,components:sn,directives:sn,watch:mm,provide:Jl,inject:pm};function Jl(t,e){return e?t?function(){return $e(Q(t)?t.call(this,this):t,Q(e)?e.call(this,this):e)}:e:t}function pm(t,e){return sn(Xs(t),Xs(e))}function Xs(t){if(K(t)){const e={};for(let i=0;i<t.length;i++)e[t[i]]=t[i];return e}return t}function Re(t,e){return t?[...new Set([].concat(t,e))]:e}function sn(t,e){return t?$e(Object.create(null),t,e):e}function Zl(t,e){return t?K(t)&&K(e)?[...new Set([...t,...e])]:$e(Object.create(null),ur(t),ur(e??{})):e}function mm(t,e){if(!t)return e;if(!e)return t;const i=$e(Object.create(null),t);for(const n in e)i[n]=Re(t[n],e[n]);return i}function ec(){return{app:null,config:{isNativeTag:el,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 gm=0;function ym(t,e){return function(n,r=null){Q(n)||(n=$e({},n)),r!=null&&!de(r)&&(r=null);const s=ec(),o=new WeakSet,a=[];let l=!1;const c=s.app={_uid:gm++,_component:n,_props:r,_container:null,_context:s,_instance:null,version:tg,get config(){return s.config},set config(u){},use(u,...f){return o.has(u)||(u&&Q(u.install)?(o.add(u),u.install(c,...f)):Q(u)&&(o.add(u),u(c,...f))),c},mixin(u){return s.mixins.includes(u)||s.mixins.push(u),c},component(u,f){return f?(s.components[u]=f,c):s.components[u]},directive(u,f){return f?(s.directives[u]=f,c):s.directives[u]},mount(u,f,h){if(!l){const m=c._ceVNode||Lt(n,r);return m.appContext=s,h===!0?h="svg":h===!1&&(h=void 0),t(m,u,h),l=!0,c._container=u,u.__vue_app__=c,ao(m.component)}},onUnmount(u){a.push(u)},unmount(){l&&(mt(a,c._instance,16),t(null,c._container),delete c._container.__vue_app__)},provide(u,f){return s.provides[u]=f,c},runWithContext(u){const f=xi;xi=c;try{return u()}finally{xi=f}}};return c}}let xi=null;function tc(t,e){if(Le){let i=Le.provides;const n=Le.parent&&Le.parent.provides;n===i&&(i=Le.provides=Object.create(n)),i[t]=e}}function on(t,e,i=!1){const n=so();if(n||xi){let r=xi?xi._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&&Q(e)?e.call(n&&n.proxy):e}}const ic={},nc=()=>Object.create(ic),rc=t=>Object.getPrototypeOf(t)===ic;function bm(t,e,i,n=!1){const r={},s=nc();t.propsDefaults=Object.create(null),sc(t,e,r,s);for(const o in t.propsOptions[0])o in r||(r[o]=void 0);i?t.props=n?r:Tp(r):t.type.props?t.props=r:t.props=s,t.attrs=s}function wm(t,e,i,n){const{props:r,attrs:s,vnode:{patchFlag:o}}=t,a=te(r),[l]=t.propsOptions;let c=!1;if((n||o>0)&&!(o&16)){if(o&8){const u=t.vnode.dynamicProps;for(let f=0;f<u.length;f++){let h=u[f];if(dr(t.emitsOptions,h))continue;const m=e[h];if(l)if(se(s,h))m!==s[h]&&(s[h]=m,c=!0);else{const g=It(h);r[g]=Js(l,a,g,m,t,!1)}else m!==s[h]&&(s[h]=m,c=!0)}}}else{sc(t,e,r,s)&&(c=!0);let u;for(const f in a)(!e||!se(e,f)&&((u=Ft(f))===f||!se(e,u)))&&(l?i&&(i[f]!==void 0||i[u]!==void 0)&&(r[f]=Js(l,a,f,void 0,t,!0)):delete r[f]);if(s!==a)for(const f in s)(!e||!se(e,f))&&(delete s[f],c=!0)}c&&At(t.attrs,"set","")}function sc(t,e,i,n){const[r,s]=t.propsOptions;let o=!1,a;if(e)for(let l in e){if(Vi(l))continue;const c=e[l];let u;r&&se(r,u=It(l))?!s||!s.includes(u)?i[u]=c:(a||(a={}))[u]=c:dr(t.emitsOptions,l)||(!(l in n)||c!==n[l])&&(n[l]=c,o=!0)}if(s){const l=te(i),c=a||re;for(let u=0;u<s.length;u++){const f=s[u];i[f]=Js(r,l,f,c[f],t,!se(c,f))}}return o}function Js(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&&Q(l)){const{propsDefaults:c}=r;if(i in c)n=c[i];else{const u=un(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===Ft(i))&&(n=!0))}return n}const vm=new WeakMap;function oc(t,e,i=!1){const n=i?vm:e.propsCache,r=n.get(t);if(r)return r;const s=t.props,o={},a=[];let l=!1;if(!Q(t)){const u=f=>{l=!0;const[h,m]=oc(f,e,!0);$e(o,h),m&&a.push(...m)};!i&&e.mixins.length&&e.mixins.forEach(u),t.extends&&u(t.extends),t.mixins&&t.mixins.forEach(u)}if(!s&&!l)return de(t)&&n.set(t,mi),mi;if(K(s))for(let u=0;u<s.length;u++){const f=It(s[u]);ac(f)&&(o[f]=re)}else if(s)for(const u in s){const f=It(u);if(ac(f)){const h=s[u],m=o[f]=K(h)||Q(h)?{type:h}:$e({},h),g=m.type;let k=!1,D=!0;if(K(g))for(let T=0;T<g.length;++T){const A=g[T],b=Q(A)&&A.name;if(b==="Boolean"){k=!0;break}else b==="String"&&(D=!1)}else k=Q(g)&&g.name==="Boolean";m[0]=k,m[1]=D,(k||se(m,"default"))&&a.push(f)}}const c=[o,a];return de(t)&&n.set(t,c),c}function ac(t){return t[0]!=="$"&&!Vi(t)}const Zs=t=>t==="_"||t==="_ctx"||t==="$stable",eo=t=>K(t)?t.map(bt):[bt(t)],_m=(t,e,i)=>{if(e._n)return e;const n=Yp((...r)=>eo(e(...r)),i);return n._c=!1,n},lc=(t,e,i)=>{const n=t._ctx;for(const r in t){if(Zs(r))continue;const s=t[r];if(Q(s))e[r]=_m(r,s,n);else if(s!=null){const o=eo(s);e[r]=()=>o}}},cc=(t,e)=>{const i=eo(e);t.slots.default=()=>i},uc=(t,e,i)=>{for(const n in e)(i||!Zs(n))&&(t[n]=e[n])},xm=(t,e,i)=>{const n=t.slots=nc();if(t.vnode.shapeFlag&32){const r=e._;r?(uc(n,e,i),i&&ol(n,"_",r,!0)):lc(e,n)}else e&&cc(t,e)},Sm=(t,e,i)=>{const{vnode:n,slots:r}=t;let s=!0,o=re;if(n.shapeFlag&32){const a=e._;a?i&&a===1?s=!1:uc(r,e,i):(s=!e.$stable,lc(e,r)),o=e}else e&&(cc(t,e),o={default:1});if(s)for(const a in r)!Zs(a)&&o[a]==null&&delete r[a]},Qe=jm;function km(t){return Em(t)}function Em(t,e){const i=Kn();i.__VUE__=!0;const{insert:n,remove:r,patchProp:s,createElement:o,createText:a,createComment:l,setText:c,setElementText:u,parentNode:f,nextSibling:h,setScopeId:m=dt,insertStaticContent:g}=t,k=(w,_,S,O=null,P=null,C=null,U=void 0,M=null,R=!!_.dynamicChildren)=>{if(w===_)return;w&&!cn(w,_)&&(O=Rr(w),xt(w,P,C,!0),w=null),_.patchFlag===-2&&(R=!1,_.dynamicChildren=null);const{type:I,ref:H,shapeFlag:F}=_;switch(I){case hr:D(w,_,S,O);break;case zt:T(w,_,S,O);break;case no:w==null&&A(_,S,O,U);break;case at:Ne(w,_,S,O,P,C,U,M,R);break;default:F&1?y(w,_,S,O,P,C,U,M,R):F&6?Ee(w,_,S,O,P,C,U,M,R):(F&64||F&128)&&I.process(w,_,S,O,P,C,U,M,R,xn)}H!=null&&P?tn(H,w&&w.ref,C,_||w,!_):H==null&&w&&w.ref!=null&&tn(w.ref,null,C,w,!0)},D=(w,_,S,O)=>{if(w==null)n(_.el=a(_.children),S,O);else{const P=_.el=w.el;_.children!==w.children&&c(P,_.children)}},T=(w,_,S,O)=>{w==null?n(_.el=l(_.children||""),S,O):_.el=w.el},A=(w,_,S,O)=>{[w.el,w.anchor]=g(w.children,_,S,O,w.el,w.anchor)},b=({el:w,anchor:_},S,O)=>{let P;for(;w&&w!==_;)P=h(w),n(w,S,O),w=P;n(_,S,O)},d=({el:w,anchor:_})=>{let S;for(;w&&w!==_;)S=h(w),r(w),w=S;r(_)},y=(w,_,S,O,P,C,U,M,R)=>{_.type==="svg"?U="svg":_.type==="math"&&(U="mathml"),w==null?v(_,S,O,P,C,U,M,R):L(w,_,P,C,U,M,R)},v=(w,_,S,O,P,C,U,M)=>{let R,I;const{props:H,shapeFlag:F,transition:q,dirs:V}=w;if(R=w.el=o(w.type,C,H&&H.is,H),F&8?u(R,w.children):F&16&&E(w.children,R,null,O,P,to(w,C),U,M),V&&ti(w,null,O,"created"),x(R,w,w.scopeId,U,O),H){for(const fe in H)fe!=="value"&&!Vi(fe)&&s(R,fe,null,H[fe],C,O);"value"in H&&s(R,"value",null,H.value,C),(I=H.onVnodeBeforeMount)&&wt(I,O,w)}V&&ti(w,null,O,"beforeMount");const ee=$m(P,q);ee&&q.beforeEnter(R),n(R,_,S),((I=H&&H.onVnodeMounted)||ee||V)&&Qe(()=>{I&&wt(I,O,w),ee&&q.enter(R),V&&ti(w,null,O,"mounted")},P)},x=(w,_,S,O,P)=>{if(S&&m(w,S),O)for(let C=0;C<O.length;C++)m(w,O[C]);if(P){let C=P.subTree;if(_===C||vc(C.type)&&(C.ssContent===_||C.ssFallback===_)){const U=P.vnode;x(w,U,U.scopeId,U.slotScopeIds,P.parent)}}},E=(w,_,S,O,P,C,U,M,R=0)=>{for(let I=R;I<w.length;I++){const H=w[I]=M?Kt(w[I]):bt(w[I]);k(null,H,_,S,O,P,C,U,M)}},L=(w,_,S,O,P,C,U)=>{const M=_.el=w.el;let{patchFlag:R,dynamicChildren:I,dirs:H}=_;R|=w.patchFlag&16;const F=w.props||re,q=_.props||re;let V;if(S&&ii(S,!1),(V=q.onVnodeBeforeUpdate)&&wt(V,S,_,w),H&&ti(_,w,S,"beforeUpdate"),S&&ii(S,!0),(F.innerHTML&&q.innerHTML==null||F.textContent&&q.textContent==null)&&u(M,""),I?B(w.dynamicChildren,I,M,S,O,to(_,P),C):U||G(w,_,M,null,S,O,to(_,P),C,!1),R>0){if(R&16)Ce(M,F,q,S,P);else if(R&2&&F.class!==q.class&&s(M,"class",null,q.class,P),R&4&&s(M,"style",F.style,q.style,P),R&8){const ee=_.dynamicProps;for(let fe=0;fe<ee.length;fe++){const oe=ee[fe],He=F[oe],ze=q[oe];(ze!==He||oe==="value")&&s(M,oe,He,ze,P,S)}}R&1&&w.children!==_.children&&u(M,_.children)}else!U&&I==null&&Ce(M,F,q,S,P);((V=q.onVnodeUpdated)||H)&&Qe(()=>{V&&wt(V,S,_,w),H&&ti(_,w,S,"updated")},O)},B=(w,_,S,O,P,C,U)=>{for(let M=0;M<_.length;M++){const R=w[M],I=_[M],H=R.el&&(R.type===at||!cn(R,I)||R.shapeFlag&198)?f(R.el):S;k(R,I,H,null,O,P,C,U,!0)}},Ce=(w,_,S,O,P)=>{if(_!==S){if(_!==re)for(const C in _)!Vi(C)&&!(C in S)&&s(w,C,_[C],null,P,O);for(const C in S){if(Vi(C))continue;const U=S[C],M=_[C];U!==M&&C!=="value"&&s(w,C,M,U,P,O)}"value"in S&&s(w,"value",_.value,S.value,P)}},Ne=(w,_,S,O,P,C,U,M,R)=>{const I=_.el=w?w.el:a(""),H=_.anchor=w?w.anchor:a("");let{patchFlag:F,dynamicChildren:q,slotScopeIds:V}=_;V&&(M=M?M.concat(V):V),w==null?(n(I,S,O),n(H,S,O),E(_.children||[],S,H,P,C,U,M,R)):F>0&&F&64&&q&&w.dynamicChildren?(B(w.dynamicChildren,q,S,P,C,U,M),(_.key!=null||P&&_===P.subTree)&&fc(w,_,!0)):G(w,_,S,H,P,C,U,M,R)},Ee=(w,_,S,O,P,C,U,M,R)=>{_.slotScopeIds=M,w==null?_.shapeFlag&512?P.ctx.activate(_,S,O,U,R):we(_,S,O,P,C,U,R):he(w,_,R)},we=(w,_,S,O,P,C,U)=>{const M=w.component=Km(w,O,P);if(ql(w)&&(M.ctx.renderer=xn),Vm(M,!1,U),M.asyncDep){if(P&&P.registerDep(M,ae,U),!w.el){const R=M.subTree=Lt(zt);T(null,R,_,S),w.placeholder=R.el}}else ae(M,w,_,S,P,C,U)},he=(w,_,S)=>{const O=_.component=w.component;if(Mm(w,_,S))if(O.asyncDep&&!O.asyncResolved){le(O,_,S);return}else O.next=_,O.update();else _.el=w.el,O.vnode=_},ae=(w,_,S,O,P,C,U)=>{const M=()=>{if(w.isMounted){let{next:F,bu:q,u:V,parent:ee,vnode:fe}=w;{const kt=dc(w);if(kt){F&&(F.el=fe.el,le(w,F,U)),kt.asyncDep.then(()=>{w.isUnmounted||M()});return}}let oe=F,He;ii(w,!1),F?(F.el=fe.el,le(w,F,U)):F=fe,q&&$s(q),(He=F.props&&F.props.onVnodeBeforeUpdate)&&wt(He,ee,F,fe),ii(w,!0);const ze=bc(w),St=w.subTree;w.subTree=ze,k(St,ze,f(St.el),Rr(St),w,P,C),F.el=ze.el,oe===null&&Dm(w,ze.el),V&&Qe(V,P),(He=F.props&&F.props.onVnodeUpdated)&&Qe(()=>wt(He,ee,F,fe),P)}else{let F;const{el:q,props:V}=_,{bm:ee,m:fe,parent:oe,root:He,type:ze}=w,St=nn(_);ii(w,!1),ee&&$s(ee),!St&&(F=V&&V.onVnodeBeforeMount)&&wt(F,oe,_),ii(w,!0);{He.ce&&He.ce._def.shadowRoot!==!1&&He.ce._injectChildStyle(ze);const kt=w.subTree=bc(w);k(null,kt,S,O,w,P,C),_.el=kt.el}if(fe&&Qe(fe,P),!St&&(F=V&&V.onVnodeMounted)){const kt=_;Qe(()=>wt(F,oe,kt),P)}(_.shapeFlag&256||oe&&nn(oe.vnode)&&oe.vnode.shapeFlag&256)&&w.a&&Qe(w.a,P),w.isMounted=!0,_=S=O=null}};w.scope.on();const R=w.effect=new fl(M);w.scope.off();const I=w.update=R.run.bind(R),H=w.job=R.runIfDirty.bind(R);H.i=w,H.id=w.uid,R.scheduler=()=>Ws(H),ii(w,!0),I()},le=(w,_,S)=>{_.component=w;const O=w.vnode.props;w.vnode=_,w.next=null,wm(w,_.props,O,S),Sm(w,_.children,S),ht(),Nl(w),pt()},G=(w,_,S,O,P,C,U,M,R=!1)=>{const I=w&&w.children,H=w?w.shapeFlag:0,F=_.children,{patchFlag:q,shapeFlag:V}=_;if(q>0){if(q&128){Tr(I,F,S,O,P,C,U,M,R);return}else if(q&256){it(I,F,S,O,P,C,U,M,R);return}}V&8?(H&16&&_n(I,P,C),F!==I&&u(S,F)):H&16?V&16?Tr(I,F,S,O,P,C,U,M,R):_n(I,P,C,!0):(H&8&&u(S,""),V&16&&E(F,S,O,P,C,U,M,R))},it=(w,_,S,O,P,C,U,M,R)=>{w=w||mi,_=_||mi;const I=w.length,H=_.length,F=Math.min(I,H);let q;for(q=0;q<F;q++){const V=_[q]=R?Kt(_[q]):bt(_[q]);k(w[q],V,S,null,P,C,U,M,R)}I>H?_n(w,P,C,!0,!1,F):E(_,S,O,P,C,U,M,R,F)},Tr=(w,_,S,O,P,C,U,M,R)=>{let I=0;const H=_.length;let F=w.length-1,q=H-1;for(;I<=F&&I<=q;){const V=w[I],ee=_[I]=R?Kt(_[I]):bt(_[I]);if(cn(V,ee))k(V,ee,S,null,P,C,U,M,R);else break;I++}for(;I<=F&&I<=q;){const V=w[F],ee=_[q]=R?Kt(_[q]):bt(_[q]);if(cn(V,ee))k(V,ee,S,null,P,C,U,M,R);else break;F--,q--}if(I>F){if(I<=q){const V=q+1,ee=V<H?_[V].el:O;for(;I<=q;)k(null,_[I]=R?Kt(_[I]):bt(_[I]),S,ee,P,C,U,M,R),I++}}else if(I>q)for(;I<=F;)xt(w[I],P,C,!0),I++;else{const V=I,ee=I,fe=new Map;for(I=ee;I<=q;I++){const Xe=_[I]=R?Kt(_[I]):bt(_[I]);Xe.key!=null&&fe.set(Xe.key,I)}let oe,He=0;const ze=q-ee+1;let St=!1,kt=0;const Sn=new Array(ze);for(I=0;I<ze;I++)Sn[I]=0;for(I=V;I<=F;I++){const Xe=w[I];if(He>=ze){xt(Xe,P,C,!0);continue}let Et;if(Xe.key!=null)Et=fe.get(Xe.key);else for(oe=ee;oe<=q;oe++)if(Sn[oe-ee]===0&&cn(Xe,_[oe])){Et=oe;break}Et===void 0?xt(Xe,P,C,!0):(Sn[Et-ee]=I+1,Et>=kt?kt=Et:St=!0,k(Xe,_[Et],S,null,P,C,U,M,R),He++)}const Qu=St?Pm(Sn):mi;for(oe=Qu.length-1,I=ze-1;I>=0;I--){const Xe=ee+I,Et=_[Xe],Yu=_[Xe+1],Gu=Xe+1<H?Yu.el||Yu.placeholder:O;Sn[I]===0?k(null,Et,S,Gu,P,C,U,M,R):St&&(oe<0||I!==Qu[oe]?ai(Et,S,Gu,2):oe--)}}},ai=(w,_,S,O,P=null)=>{const{el:C,type:U,transition:M,children:R,shapeFlag:I}=w;if(I&6){ai(w.component.subTree,_,S,O);return}if(I&128){w.suspense.move(_,S,O);return}if(I&64){U.move(w,_,S,xn);return}if(U===at){n(C,_,S);for(let F=0;F<R.length;F++)ai(R[F],_,S,O);n(w.anchor,_,S);return}if(U===no){b(w,_,S);return}if(O!==2&&I&1&&M)if(O===0)M.beforeEnter(C),n(C,_,S),Qe(()=>M.enter(C),P);else{const{leave:F,delayLeave:q,afterLeave:V}=M,ee=()=>{w.ctx.isUnmounted?r(C):n(C,_,S)},fe=()=>{C._isLeaving&&C[Jp](!0),F(C,()=>{ee(),V&&V()})};q?q(C,ee,fe):fe()}else n(C,_,S)},xt=(w,_,S,O=!1,P=!1)=>{const{type:C,props:U,ref:M,children:R,dynamicChildren:I,shapeFlag:H,patchFlag:F,dirs:q,cacheIndex:V}=w;if(F===-2&&(P=!1),M!=null&&(ht(),tn(M,null,S,w,!0),pt()),V!=null&&(_.renderCache[V]=void 0),H&256){_.ctx.deactivate(w);return}const ee=H&1&&q,fe=!nn(w);let oe;if(fe&&(oe=U&&U.onVnodeBeforeUnmount)&&wt(oe,_,w),H&6)Db(w.component,S,O);else{if(H&128){w.suspense.unmount(S,O);return}ee&&ti(w,null,_,"beforeUnmount"),H&64?w.type.remove(w,_,S,xn,O):I&&!I.hasOnce&&(C!==at||F>0&&F&64)?_n(I,_,S,!1,!0):(C===at&&F&384||!P&&H&16)&&_n(R,_,S),O&&Ku(w)}(fe&&(oe=U&&U.onVnodeUnmounted)||ee)&&Qe(()=>{oe&&wt(oe,_,w),ee&&ti(w,null,_,"unmounted")},S)},Ku=w=>{const{type:_,el:S,anchor:O,transition:P}=w;if(_===at){Mb(S,O);return}if(_===no){d(w);return}const C=()=>{r(S),P&&!P.persisted&&P.afterLeave&&P.afterLeave()};if(w.shapeFlag&1&&P&&!P.persisted){const{leave:U,delayLeave:M}=P,R=()=>U(S,C);M?M(w.el,C,R):R()}else C()},Mb=(w,_)=>{let S;for(;w!==_;)S=h(w),r(w),w=S;r(_)},Db=(w,_,S)=>{const{bum:O,scope:P,job:C,subTree:U,um:M,m:R,a:I}=w;hc(R),hc(I),O&&$s(O),P.stop(),C&&(C.flags|=8,xt(U,w,_,S)),M&&Qe(M,_),Qe(()=>{w.isUnmounted=!0},_)},_n=(w,_,S,O=!1,P=!1,C=0)=>{for(let U=C;U<w.length;U++)xt(w[U],_,S,O,P)},Rr=w=>{if(w.shapeFlag&6)return Rr(w.component.subTree);if(w.shapeFlag&128)return w.suspense.next();const _=h(w.anchor||w.el),S=_&&_[Gp];return S?h(S):_};let Do=!1;const Vu=(w,_,S)=>{w==null?_._vnode&&xt(_._vnode,null,null,!0):k(_._vnode||null,w,_,null,null,null,S),_._vnode=w,Do||(Do=!0,Nl(),Ml(),Do=!1)},xn={p:k,um:xt,m:ai,r:Ku,mt:we,mc:E,pc:G,pbc:B,n:Rr,o:t};return{render:Vu,hydrate:void 0,createApp:ym(Vu)}}function to({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 ii({effect:t,job:e},i){i?(t.flags|=32,e.flags|=4):(t.flags&=-33,e.flags&=-5)}function $m(t,e){return(!t||t&&!t.pendingBranch)&&e&&!e.persisted}function fc(t,e,i=!1){const n=t.children,r=e.children;if(K(n)&&K(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]=Kt(r[s]),a.el=o.el),!i&&a.patchFlag!==-2&&fc(o,a)),a.type===hr&&a.patchFlag!==-1&&(a.el=o.el),a.type===zt&&!a.el&&(a.el=o.el)}}function Pm(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 dc(t){const e=t.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:dc(e)}function hc(t){if(t)for(let e=0;e<t.length;e++)t[e].flags|=8}const Cm=Symbol.for("v-scx"),Om=()=>on(Cm);function Im(t,e){return io(t,null,{flush:"sync"})}function Si(t,e,i){return io(t,e,i)}function io(t,e,i=re){const{immediate:n,deep:r,flush:s,once:o}=i,a=$e({},i),l=e&&n||!e&&s!=="post";let c;if(fn){if(s==="sync"){const m=Om();c=m.__watcherHandles||(m.__watcherHandles=[])}else if(!l){const m=()=>{};return m.stop=dt,m.resume=dt,m.pause=dt,m}}const u=Le;a.call=(m,g,k)=>mt(m,u,g,k);let f=!1;s==="post"?a.scheduler=m=>{Qe(m,u&&u.suspense)}:s!=="sync"&&(f=!0,a.scheduler=(m,g)=>{g?m():Ws(m)}),a.augmentJob=m=>{e&&(m.flags|=4),f&&(m.flags|=2,u&&(m.id=u.uid,m.i=u))};const h=Bp(t,e,a);return fn&&(c?c.push(h):l&&h()),h}function Am(t,e,i){const n=this.proxy,r=be(t)?t.includes(".")?pc(n,t):()=>n[t]:t.bind(n,n);let s;Q(e)?s=e:(s=e.handler,i=e);const o=un(this),a=io(r,s.bind(n),i);return o(),a}function pc(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 mc(t,e,i=re){const n=so(),r=It(e),s=Ft(e),o=gc(t,r),a=Dp((l,c)=>{let u,f=re,h;return Im(()=>{const m=t[r];Fe(u,m)&&(u=m,c())}),{get(){return l(),i.get?i.get(u):u},set(m){const g=i.set?i.set(m):m;if(!Fe(g,u)&&!(f!==re&&Fe(m,f)))return;const k=n.vnode.props;k&&(e in k||r in k||s in k)&&(`onUpdate:${e}`in k||`onUpdate:${r}`in k||`onUpdate:${s}`in k)||(u=m,c()),n.emit(`update:${e}`,g),Fe(m,g)&&Fe(m,f)&&!Fe(g,h)&&c(),f=m,h=g}}});return a[Symbol.iterator]=()=>{let l=0;return{next(){return l<2?{value:l++?o||re:a,done:!1}:{done:!0}}}},a}const gc=(t,e)=>e==="modelValue"||e==="model-value"?t.modelModifiers:t[`${e}Modifiers`]||t[`${It(e)}Modifiers`]||t[`${Ft(e)}Modifiers`];function Tm(t,e,...i){if(t.isUnmounted)return;const n=t.vnode.props||re;let r=i;const s=e.startsWith("update:"),o=s&&gc(n,e.slice(7));o&&(o.trim&&(r=i.map(u=>be(u)?u.trim():u)),o.number&&(r=i.map(op)));let a,l=n[a=Es(e)]||n[a=Es(It(e))];!l&&s&&(l=n[a=Es(Ft(e))]),l&&mt(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,mt(c,t,6,r)}}const Rm=new WeakMap;function yc(t,e,i=!1){const n=i?Rm:e.emitsCache,r=n.get(t);if(r!==void 0)return r;const s=t.emits;let o={},a=!1;if(!Q(t)){const l=c=>{const u=yc(c,e,!0);u&&(a=!0,$e(o,u))};!i&&e.mixins.length&&e.mixins.forEach(l),t.extends&&l(t.extends),t.mixins&&t.mixins.forEach(l)}return!s&&!a?(de(t)&&n.set(t,null),null):(K(s)?s.forEach(l=>o[l]=null):$e(o,s),de(t)&&n.set(t,o),o)}function dr(t,e){return!t||!Hn(e)?!1:(e=e.slice(2).replace(/Once$/,""),se(t,e[0].toLowerCase()+e.slice(1))||se(t,Ft(e))||se(t,e))}function zb(){}function bc(t){const{type:e,vnode:i,proxy:n,withProxy:r,propsOptions:[s],slots:o,attrs:a,emit:l,render:c,renderCache:u,props:f,data:h,setupState:m,ctx:g,inheritAttrs:k}=t,D=ar(t);let T,A;try{if(i.shapeFlag&4){const d=r||n,y=d;T=bt(c.call(y,d,u,f,m,h,g)),A=a}else{const d=e;T=bt(d.length>1?d(f,{attrs:a,slots:o,emit:l}):d(f,null)),A=e.props?a:Lm(a)}}catch(d){an.length=0,rr(d,t,1),T=Lt(zt)}let b=T;if(A&&k!==!1){const d=Object.keys(A),{shapeFlag:y}=b;d.length&&y&7&&(s&&d.some(xs)&&(A=Nm(A,s)),b=$i(b,A,!1,!0))}return i.dirs&&(b=$i(b,null,!1,!0),b.dirs=b.dirs?b.dirs.concat(i.dirs):i.dirs),i.transition&&Ks(b,i.transition),T=b,ar(D),T}const Lm=t=>{let e;for(const i in t)(i==="class"||i==="style"||Hn(i))&&((e||(e={}))[i]=t[i]);return e},Nm=(t,e)=>{const i={};for(const n in t)(!xs(n)||!(n.slice(9)in e))&&(i[n]=t[n]);return i};function Mm(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?wc(n,o,c):!!o;if(l&8){const u=e.dynamicProps;for(let f=0;f<u.length;f++){const h=u[f];if(o[h]!==n[h]&&!dr(c,h))return!0}}}else return(r||a)&&(!a||!a.$stable)?!0:n===o?!1:n?o?wc(n,o,c):!0:!!o;return!1}function wc(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]&&!dr(i,s))return!0}return!1}function Dm({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 vc=t=>t.__isSuspense;function jm(t,e){e&&e.pendingBranch?K(t)?e.effects.push(...t):e.effects.push(t):Qp(t)}const at=Symbol.for("v-fgt"),hr=Symbol.for("v-txt"),zt=Symbol.for("v-cmt"),no=Symbol.for("v-stc"),an=[];let Ye=null;function Wt(t=!1){an.push(Ye=t?null:[])}function Um(){an.pop(),Ye=an[an.length-1]||null}let ln=1;function _c(t,e=!1){ln+=t,t<0&&Ye&&e&&(Ye.hasOnce=!0)}function xc(t){return t.dynamicChildren=ln>0?Ye||mi:null,Um(),ln>0&&Ye&&Ye.push(t),t}function ki(t,e,i,n,r,s){return xc(Ei(t,e,i,n,r,s,!0))}function Sc(t,e,i,n,r){return xc(Lt(t,e,i,n,r,!0))}function kc(t){return t?t.__v_isVNode===!0:!1}function cn(t,e){return t.type===e.type&&t.key===e.key}const Ec=({key:t})=>t??null,pr=({ref:t,ref_key:e,ref_for:i})=>(typeof t=="number"&&(t=""+t),t!=null?be(t)||ke(t)||Q(t)?{i:yt,r:t,k:e,f:!!i}:t:null);function Ei(t,e=null,i=null,n=0,r=null,s=t===at?0:1,o=!1,a=!1){const l={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&Ec(e),ref:e&&pr(e),scopeId:jl,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:yt};return a?(ro(l,i),s&128&&t.normalize(l)):i&&(l.shapeFlag|=be(i)?8:16),ln>0&&!o&&Ye&&(l.patchFlag>0||s&6)&&l.patchFlag!==32&&Ye.push(l),l}const Lt=Fm;function Fm(t,e=null,i=null,n=0,r=null,s=!1){if((!t||t===cm)&&(t=zt),kc(t)){const a=$i(t,e,!0);return i&&ro(a,i),ln>0&&!s&&Ye&&(a.shapeFlag&6?Ye[Ye.indexOf(t)]=a:Ye.push(a)),a.patchFlag=-2,a}if(eg(t)&&(t=t.__vccOpts),e){e=Bm(e);let{class:a,style:l}=e;a&&!be(a)&&(e.class=Vn(a)),de(l)&&(qs(l)&&!K(l)&&(l=$e({},l)),e.style=Ps(l))}const o=be(t)?1:vc(t)?128:Xp(t)?64:de(t)?4:Q(t)?2:0;return Ei(t,e,i,n,r,o,s,!0)}function Bm(t){return t?qs(t)||rc(t)?$e({},t):t:null}function $i(t,e,i=!1,n=!1){const{props:r,ref:s,patchFlag:o,children:a,transition:l}=t,c=e?$c(r||{},e):r,u={__v_isVNode:!0,__v_skip:!0,type:t.type,props:c,key:c&&Ec(c),ref:e&&e.ref?i&&s?K(s)?s.concat(pr(e)):[s,pr(e)]:pr(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!==at?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&&$i(t.ssContent),ssFallback:t.ssFallback&&$i(t.ssFallback),placeholder:t.placeholder,el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce};return l&&n&&Ks(u,l.clone(u)),u}function qm(t=" ",e=0){return Lt(hr,null,t,e)}function Hm(t="",e=!1){return e?(Wt(),Sc(zt,null,t)):Lt(zt,null,t)}function bt(t){return t==null||typeof t=="boolean"?Lt(zt):K(t)?Lt(at,null,t.slice()):kc(t)?Kt(t):Lt(hr,null,String(t))}function Kt(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:$i(t)}function ro(t,e){let i=0;const{shapeFlag:n}=t;if(e==null)e=null;else if(K(e))i=16;else if(typeof e=="object")if(n&65){const r=e.default;r&&(r._c&&(r._d=!1),ro(t,r()),r._c&&(r._d=!0));return}else{i=32;const r=e._;!r&&!rc(e)?e._ctx=yt:r===3&&yt&&(yt.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else Q(e)?(e={default:e,_ctx:yt},i=32):(e=String(e),n&64?(i=16,e=[qm(e)]):i=8);t.children=e,t.shapeFlag|=i}function $c(...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=Vn([e.class,n.class]));else if(r==="style")e.style=Ps([e.style,n.style]);else if(Hn(r)){const s=e[r],o=n[r];o&&s!==o&&!(K(s)&&s.includes(o))&&(e[r]=s?[].concat(s,o):o)}else r!==""&&(e[r]=n[r])}return e}function wt(t,e,i,n=null){mt(t,e,7,[i,n])}const zm=ec();let Wm=0;function Km(t,e,i){const n=t.type,r=(e?e.appContext:t.appContext)||zm,s={uid:Wm++,vnode:t,type:n,parent:e,appContext:r,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new dp(!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:oc(n,r),emitsOptions:yc(n,r),emit:null,emitted:null,propsDefaults:re,inheritAttrs:n.inheritAttrs,ctx:re,data:re,props:re,attrs:re,slots:re,refs:re,setupState:re,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=Tm.bind(null,s),t.ce&&t.ce(s),s}let Le=null;const so=()=>Le||yt;let mr,oo;{const t=Kn(),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)}};mr=e("__VUE_INSTANCE_SETTERS__",i=>Le=i),oo=e("__VUE_SSR_SETTERS__",i=>fn=i)}const un=t=>{const e=Le;return mr(t),t.scope.on(),()=>{t.scope.off(),mr(e)}},Pc=()=>{Le&&Le.scope.off(),mr(null)};function Cc(t){return t.vnode.shapeFlag&4}let fn=!1;function Vm(t,e=!1,i=!1){e&&oo(e);const{props:n,children:r}=t.vnode,s=Cc(t);bm(t,n,s,e),xm(t,r,i||e);const o=s?Qm(t,e):void 0;return e&&oo(!1),o}function Qm(t,e){const i=t.type;t.accessCache=Object.create(null),t.proxy=new Proxy(t.ctx,um);const{setup:n}=i;if(n){ht();const r=t.setupContext=n.length>1?Gm(t):null,s=un(t),o=wi(n,t,0,[t.props,r]),a=il(o);if(pt(),s(),(a||t.sp)&&!nn(t)&&Fl(t),a){if(o.then(Pc,Pc),e)return o.then(l=>{Oc(t,l)}).catch(l=>{rr(l,t,0)});t.asyncDep=o}else Oc(t,o)}else Ic(t)}function Oc(t,e,i){Q(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:de(e)&&(t.setupState=Al(e)),Ic(t)}function Ic(t,e,i){const n=t.type;t.render||(t.render=n.render||dt);{const r=un(t);ht();try{fm(t)}finally{pt(),r()}}}const Ym={get(t,e){return Ie(t,"get",""),t[e]}};function Gm(t){const e=i=>{t.exposed=i||{}};return{attrs:new Proxy(t.attrs,Ym),slots:t.slots,emit:t.emit,expose:e}}function ao(t){return t.exposed?t.exposeProxy||(t.exposeProxy=new Proxy(Al(Rp(t.exposed)),{get(e,i){if(i in e)return e[i];if(i in rn)return rn[i](t)},has(e,i){return i in e||i in rn}})):t.proxy}const Xm=/(?:^|[-_])\w/g,Jm=t=>t.replace(Xm,e=>e.toUpperCase()).replace(/[-_]/g,"");function Zm(t,e=!0){return Q(t)?t.displayName||t.name:t.name||e&&t.__name}function Ac(t,e,i=!1){let n=Zm(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?Jm(n):i?"App":"Anonymous"}function eg(t){return Q(t)&&"__vccOpts"in t}const Tc=(t,e)=>Up(t,e,fn),tg="3.5.22";/**
100
- * @vue/runtime-dom v3.5.22
101
- * (c) 2018-present Yuxi (Evan) You and Vue contributors
102
- * @license MIT
103
- **/let lo;const Rc=typeof window<"u"&&window.trustedTypes;if(Rc)try{lo=Rc.createPolicy("vue",{createHTML:t=>t})}catch{}const Lc=lo?t=>lo.createHTML(t):t=>t,ig="http://www.w3.org/2000/svg",ng="http://www.w3.org/1998/Math/MathML",Nt=typeof document<"u"?document:null,Nc=Nt&&Nt.createElement("template"),rg={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"?Nt.createElementNS(ig,t):e==="mathml"?Nt.createElementNS(ng,t):i?Nt.createElement(t,{is:i}):Nt.createElement(t);return t==="select"&&n&&n.multiple!=null&&r.setAttribute("multiple",n.multiple),r},createText:t=>Nt.createTextNode(t),createComment:t=>Nt.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>Nt.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{Nc.innerHTML=Lc(n==="svg"?`<svg>${t}</svg>`:n==="mathml"?`<math>${t}</math>`:t);const a=Nc.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]}},sg=Symbol("_vtc");function og(t,e,i){const n=t[sg];n&&(e=(e?[e,...n]:[...n]).join(" ")),e==null?t.removeAttribute("class"):i?t.setAttribute("class",e):t.className=e}const Mc=Symbol("_vod"),ag=Symbol("_vsh"),lg=Symbol(""),cg=/(?:^|;)\s*display\s*:/;function ug(t,e,i){const n=t.style,r=be(i);let s=!1;if(i&&!r){if(e)if(be(e))for(const o of e.split(";")){const a=o.slice(0,o.indexOf(":")).trim();i[a]==null&&gr(n,a,"")}else for(const o in e)i[o]==null&&gr(n,o,"");for(const o in i)o==="display"&&(s=!0),gr(n,o,i[o])}else if(r){if(e!==i){const o=n[lg];o&&(i+=";"+o),n.cssText=i,s=cg.test(i)}}else e&&t.removeAttribute("style");Mc in t&&(t[Mc]=s?n.display:"",t[ag]&&(n.display="none"))}const Dc=/\s*!important$/;function gr(t,e,i){if(K(i))i.forEach(n=>gr(t,e,n));else if(i==null&&(i=""),e.startsWith("--"))t.setProperty(e,i);else{const n=fg(t,e);Dc.test(i)?t.setProperty(Ft(n),i.replace(Dc,""),"important"):t[n]=i}}const jc=["Webkit","Moz","ms"],co={};function fg(t,e){const i=co[e];if(i)return i;let n=It(e);if(n!=="filter"&&n in t)return co[e]=n;n=sl(n);for(let r=0;r<jc.length;r++){const s=jc[r]+n;if(s in t)return co[e]=s}return e}const Uc="http://www.w3.org/1999/xlink";function Fc(t,e,i,n,r,s=fp(e)){n&&e.startsWith("xlink:")?i==null?t.removeAttributeNS(Uc,e.slice(6,e.length)):t.setAttributeNS(Uc,e,i):i==null||s&&!ll(i)?t.removeAttribute(e):t.setAttribute(e,s?"":Ut(i)?String(i):i)}function Bc(t,e,i,n,r){if(e==="innerHTML"||e==="textContent"){i!=null&&(t[e]=e==="innerHTML"?Lc(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=ll(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 dg(t,e,i,n){t.addEventListener(e,i,n)}function hg(t,e,i,n){t.removeEventListener(e,i,n)}const qc=Symbol("_vei");function pg(t,e,i,n,r=null){const s=t[qc]||(t[qc]={}),o=s[e];if(n&&o)o.value=n;else{const[a,l]=mg(e);if(n){const c=s[e]=bg(n,r);dg(t,a,c,l)}else o&&(hg(t,a,o,l),s[e]=void 0)}}const Hc=/(?:Once|Passive|Capture)$/;function mg(t){let e;if(Hc.test(t)){e={};let n;for(;n=t.match(Hc);)t=t.slice(0,t.length-n[0].length),e[n[0].toLowerCase()]=!0}return[t[2]===":"?t.slice(3):Ft(t.slice(2)),e]}let uo=0;const gg=Promise.resolve(),yg=()=>uo||(gg.then(()=>uo=0),uo=Date.now());function bg(t,e){const i=n=>{if(!n._vts)n._vts=Date.now();else if(n._vts<=i.attached)return;mt(wg(n,i.value),e,5,[n])};return i.value=t,i.attached=yg(),i}function wg(t,e){if(K(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 zc=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>96&&t.charCodeAt(2)<123,vg=(t,e,i,n,r,s)=>{const o=r==="svg";e==="class"?og(t,n,o):e==="style"?ug(t,i,n):Hn(e)?xs(e)||pg(t,e,i,n,s):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):_g(t,e,n,o))?(Bc(t,e,n),!t.tagName.includes("-")&&(e==="value"||e==="checked"||e==="selected")&&Fc(t,e,n,o,s,e!=="value")):t._isVueCE&&(/[A-Z]/.test(e)||!be(n))?Bc(t,It(e),n,s,e):(e==="true-value"?t._trueValue=n:e==="false-value"&&(t._falseValue=n),Fc(t,e,n,o))};function _g(t,e,i,n){if(n)return!!(e==="innerHTML"||e==="textContent"||e in t&&zc(e)&&Q(i));if(e==="spellcheck"||e==="draggable"||e==="translate"||e==="autocorrect"||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 zc(e)&&be(i)?!1:e in t}const xg=$e({patchProp:vg},rg);let Wc;function Sg(){return Wc||(Wc=km(xg))}const kg=(...t)=>{const e=Sg().createApp(...t),{mount:i}=e;return e.mount=n=>{const r=$g(n);if(!r)return;const s=e._component;!Q(s)&&!s.render&&!s.template&&(s.template=r.innerHTML),r.nodeType===1&&(r.textContent="");const o=i(r,!1,Eg(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),o},e};function Eg(t){if(t instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&t instanceof MathMLElement)return"mathml"}function $g(t){return be(t)?document.querySelector(t):t}const fo=Symbol("IPEInjectKey"),Pg=(t,e)=>(e?e.provide(fo,t):tc(fo,t),t),Cg=()=>{const t=on(fo);if(!t)throw new Error("InPageEdit instance is not provided");return t},Og=(t,...e)=>{const i=kg(...e);return Pg(t,i),i},et='@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;border-left:3px solid var(--schema-color-muted, #e5e7eb);padding-left: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}';/**
104
- * SchemaForm
105
- * 一个基于 Schemastery 的 Web Components 表单生成器
106
- *
107
- * ✅ 使用 TypeScript,组件前缀统一为 <schema-*>
108
- * ✅ 简单样式 + 通过 CSS 变量 --schema-* 配置主题
109
- * ✅ 暴露 API:设置/获取表单数据、设置 Schema、校验
110
- * ✅ 支持的类型:string / number / boolean / date / const / object / array / tuple / dict / union
111
- * ✅ 支持按类型拆分的独立 Field 组件:<schema-form-string> 等,可单独使用
112
- * ✅ 字段容器带类名:schema-form-item schema-type-xxx,并带 data-path="a.b.0.c"
113
- * ✅ schema-form-array 支持条目上下移动
114
- * ✅ 主类为泛型:SchemaForm<T>
115
- * ✅ 提供 createSchemasteryForm<T>() 工厂,返回带强类型的 FormInstance<T>
116
- *
117
- * @license MIT
118
- * @author dragon-fish
119
- * @author @openai/gpt-5
120
- */const Kc={arrayAdd:"+",arrayMoveUp:"↑",arrayMoveDown:"↓",arrayRemove:"×",dictAdd:"+",dictRemove:"×",rootLabel:"root"},me=(t,e)=>{customElements.get(t)||customElements.define(t,e)},Ig=(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{}}},dn=t=>t.map(String).join("."),Ag=t=>t.replace(/[^a-zA-Z0-9_-]/g,"_"),Vt=t=>`schema_${Ag(dn(t)||"root")}`,ni=t=>dn(t),ie=(t,...e)=>{const i=new Set(...e);i.size&&t.setAttribute("part",Array.from(i).join(" "))},Tg=["wrapper","form","field","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 ho(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 Vc(t){return typeof t=="function"&&!!t?.type}function Qc(t){if(!t)throw new Error("schema is required");if(Vc(t))return t;try{const e=Schema.from(t);if(Vc(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 lt(t){return t?.meta??{}}function Rg(t){return t.length>0&&t.every(e=>e?.type==="const")}function Pi(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?Pi(r[0]):void 0}case"const":return e.value;case"date":return;default:return}}class vt extends HTMLElement{constructor(){super(),this._path=[],this._i18n=Kc,this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=et,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",dn(this._path)),ie(n,"field",`field-${e}`),this._label){const r=document.createElement("label");r.className="label",r.textContent=this._label,ie(r,"field-label"),n.appendChild(r)}if(i){const r=document.createElement("div");r.className="helper",r.textContent=i,ie(r,"field-helper"),n.appendChild(r)}return n}set schema(e){this._schema=Qc(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 Yc extends vt{render(){if(this.$input&&this.$root.contains(this.$input)){const s=this._value??"";this.$input.value!==s&&document.activeElement!==this.$input&&(this.$input.value=s);return}this.$root.innerHTML=`<style>${et}</style>`;const e=lt(this._schema),i=this.makeFieldContainer("string",e.description),n=document.createElement("input");this.$input=n,n.className="input",ie(n,"field-input","field-input-text"),n.type="text",n.name=ni(this._path),n.id=Vt(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(ho("string",n.value));const r=i.querySelector("label.label");r&&(r.htmlFor=n.id),i.appendChild(n),this.$root.appendChild(i)}}me("schema-form-string",Yc);class Gc extends vt{render(){if(this.$input&&this.$root.contains(this.$input)){const o=this._value??"";this.$input.value!==String(o)&&document.activeElement!==this.$input&&(this.$input.value=o);return}this.$root.innerHTML=`<style>${et}</style>`;const e=this._schema?.type??"number",i=lt(this._schema),n=this.makeFieldContainer("number",i.description),r=document.createElement("input");this.$input=r,r.className="input",ie(r,"field-input","field-input-number"),r.name=ni(this._path),r.id=Vt(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(ho(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)}}me("schema-form-number",Gc);class Xc extends vt{render(){this.$root.innerHTML=`<style>${et}</style>`;const e=lt(this._schema),i=this.makeFieldContainer("boolean",e.description),n=document.createElement("label");n.className="checkbox",ie(n,"field-checkbox");const r=document.createElement("input");r.type="checkbox",r.checked=!!this._value,r.name=ni(this._path),r.id=Vt(this._path),ie(r,"field-input","field-input-checkbox");const s=document.createElement("span");s.textContent=e.description??this._label??"",ie(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)}}me("schema-form-boolean",Xc);function yr(t){return String(t).padStart(2,"0")}function hn(t){return`${t.getFullYear()}-${yr(t.getMonth()+1)}-${yr(t.getDate())}`}function po(t){return`${yr(t.getHours())}:${yr(t.getMinutes())}`}function br(t){return`${hn(t)}T${po(t)}`}class Jc extends vt{render(){if(this.$input&&this.$root.contains(this.$input)){const o=lt(this._schema).role||"date";if(document.activeElement!==this.$input)if(this._value instanceof Date)o==="date"?this.$input.value=hn(this._value):o==="time"?this.$input.value=po(this._value):o==="datetime"&&(this.$input.value=br(this._value));else if(typeof this._value=="string"&&o!=="time"){const a=new Date(this._value);isNaN(+a)||(o==="date"?this.$input.value=hn(a):o==="datetime"&&(this.$input.value=br(a)))}else this._value||(this.$input.value="");return}this.$root.innerHTML=`<style>${et}</style>`;const e=lt(this._schema),i=this.makeFieldContainer("date",e.description),n=document.createElement("input");this.$input=n,n.className="input",ie(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=ni(this._path),n.id=Vt(this._path),this._value instanceof Date)r==="date"?n.value=hn(this._value):r==="time"?n.value=po(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=hn(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)}}me("schema-form-date",Jc);class mo extends vt{render(){this.$root.innerHTML=`<style>${et}</style>`;const e=lt(this._schema),i=this._schema.value;if(e.role==="raw-html"){if(i instanceof Node){this.$root.appendChild(i);return}const o=document.createElement("div");o.innerHTML=String(i),ie(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=Vt(this._path),ie(r,"field-const-value");const s=n.querySelector("label.label");s&&(s.htmlFor=r.id),n.appendChild(r),this.$root.appendChild(n)}}me("schema-form-const",mo);function Lg(t){switch(t.type){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 Ci(t,e,i,n,r){const s=Lg(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",Tg),o}class Zc extends vt{render(){this.$root.innerHTML=`<style>${et}</style>`;const e=lt(this._schema),i=this.makeFieldContainer("union",e.description),n=this._schema.list||[];if(Rg(n)){const r=document.createElement("select");r.className="input",ie(r,"field-input","field-input-select"),r.name=ni(this._path),r.id=Vt(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(ho("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",ie(r,"field-toolbar");const s=document.createElement("select");s.className="input",ie(s,"field-input","field-input-select","field-toolbar-select"),s.name=ni(this._path)+".__type",s.id=Vt(this._path)+"__type";let o=0;n.forEach((u,f)=>{const h=document.createElement("option");h.value=String(f),h.textContent=String(u.meta?.description||u.value||u.type),s.appendChild(h)}),s.onchange=()=>{o=Number(s.value);const u=n[o],f=Pi(u);this.emitChange(f),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",ie(l,"field-group");const c=()=>{l.innerHTML="";const u=n[o],f=Ci(u,this._path,this._value,this._label);f instanceof mo||(f.addEventListener("change",h=>{h.stopPropagation(),this.emitChange(h.detail.value)}),l.appendChild(f))};c(),i.appendChild(l)}this.$root.appendChild(i)}}me("schema-form-union",Zc);class eu extends vt{render(){this.$root.innerHTML=`<style>${et}</style>`;const e=lt(this._schema),i=this.makeFieldContainer("tuple",e.description),n=document.createElement("div");n.className="group",ie(n,"field-group");const r=Array.isArray(this._value)?this._value:[];(this._schema.list||[]).forEach((s,o)=>{const a=Ci(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)}}me("schema-form-tuple",eu);class tu extends vt{render(){this.$root.innerHTML=`<style>${et}</style>`;const e=lt(this._schema),i=this.makeFieldContainer("object",e.description),n=document.createElement("div");n.className="group",ie(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=Ci(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)}}me("schema-form-object",tu);const Ar=class Ar extends vt{constructor(){super(...arguments),this._itemIds=[]}generateItemId(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return"i"+Ar._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>${et}</style>`;const e=lt(this._schema),i=this.makeFieldContainer("array",e.description),n=document.createElement("div");n.className="group",ie(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((f,h)=>{const m=[...this._path,h],g=document.createElement("div");g.className="row schema-collection-row",ie(g,"field-row","collection-row");const k=this._itemIds[h];g.dataset.uid=k,g.setAttribute("data-path",dn(m));const D=Ci(r,m,f,`${this._label??""}[${h}]`);D.addEventListener("change",y=>{y.stopPropagation();const v=s().slice();v[h]=y.detail.value,this._value=v,this.emitChange(v)});const T=document.createElement("div");T.className="actions",ie(T,"field-actions");const A=document.createElement("button");A.type="button",A.className="btn",ie(A,"field-button","field-button-secondary"),A.textContent=this._i18n.arrayMoveUp??"↑",A.onclick=()=>{if(h<=0)return;const y=this.capturePositions(n),v=s().slice();[v[h-1],v[h]]=[v[h],v[h-1]],[this._itemIds[h-1],this._itemIds[h]]=[this._itemIds[h],this._itemIds[h-1]],this._value=v,o(y),this.emitChange(v)};const b=document.createElement("button");b.type="button",b.className="btn",ie(b,"field-button","field-button-secondary"),b.textContent=this._i18n.arrayMoveDown??"↓",b.onclick=()=>{const y=s();if(h>=y.length-1)return;const v=this.capturePositions(n),x=y.slice();[x[h+1],x[h]]=[x[h],x[h+1]],[this._itemIds[h+1],this._itemIds[h]]=[this._itemIds[h],this._itemIds[h+1]],this._value=x,o(v),this.emitChange(x)};const d=document.createElement("button");d.type="button",d.className="btn danger",ie(d,"field-button","field-button-danger"),d.textContent=this._i18n.arrayRemove??"×",d.onclick=()=>{g.classList.add("leaving");const y=250;let v=!1;const x=()=>{if(v)return;v=!0,clearTimeout(E);const L=s().filter((Ce,Ne)=>Ne!==h);this._itemIds.splice(h,1);const B=this.capturePositions(n);this._value=L,o(B),this.emitChange(L)};g.addEventListener("transitionend",x,{once:!0});const E=setTimeout(x,y+80)},T.append(A,b,d),g.appendChild(D),g.appendChild(T),n.appendChild(g),u&&u===k&&(g.classList.add("enter"),requestAnimationFrame(()=>{g.classList.add("enter-active")}),requestAnimationFrame(()=>{g.classList.remove("enter")}))}),c&&this.playFLIP(n,c)};o();const a=document.createElement("button");a.type="button",a.className="btn primary",ie(a,"field-button","field-button-primary"),a.textContent=this._i18n.arrayAdd??"+",a.onclick=()=>{const c=this.capturePositions(n),u=s().slice(),f=Pi(r);u.push(f);const h=this.generateItemId();this._itemIds.push(h),this._value=u,o(c,h),this.emitChange(u)};const l=document.createElement("div");l.className="actions",ie(l,"field-actions"),l.appendChild(a),i.appendChild(n),i.appendChild(l),this.$root.appendChild(i)}};Ar._idCounter=0;let wr=Ar;me("schema-form-array",wr);class iu extends vt{render(){this.$root.innerHTML=`<style>${et}</style>`;const e=lt(this._schema),i=this.makeFieldContainer("dict",e.description),n=document.createElement("div");n.className="group",ie(n,"field-group");const r=this._schema.inner,s=this._value??{},o=h=>`d_${h}`,a=()=>{const h={};return n.querySelectorAll(".kv").forEach(m=>{const g=m.dataset.uid;g&&(h[g]=m.getBoundingClientRect())}),h},l=h=>{n.querySelectorAll(".kv").forEach(m=>{const g=m.dataset.uid;if(!g)return;const k=h[g];if(!k)return;const D=m.getBoundingClientRect(),T=k.left-D.left,A=k.top-D.top;(T||A)&&(m.style.transition="none",m.style.transform=`translate(${T}px, ${A}px)`,requestAnimationFrame(()=>{m.style.transition="transform .25s ease",m.style.transform=""}))})},c=(h,m)=>{n.innerHTML="",Object.keys(s).forEach(g=>{const k=[...this._path,g],D=document.createElement("div");D.className="kv schema-collection-row",ie(D,"field-row","collection-row"),D.dataset.uid=o(g),D.setAttribute("data-path",dn(k));const T=document.createElement("input");T.className="input",ie(T,"field-input","field-input-text"),T.value=g,T.name=ni(k)+".__key",T.id=Vt(k)+"__key";const A=Ci(r,k,s[g],`${this._label??""}[${g}]`),b=document.createElement("button");b.type="button",b.className="btn danger",ie(b,"field-button","field-button-danger"),b.textContent=this._i18n.dictRemove??"×",b.onclick=()=>{const d=a();delete s[g];const y={...this._value??{}};delete y[g],this._value=y,c(d),this.emitChange(y)},T.onchange=()=>{const d=T.value.trim();if(!d||d===g||s[d]!==void 0)return;const y=a();s[d]=s[g],delete s[g];const v={...this._value??{}};v[d]=v[g],delete v[g],this._value=v,c(y),this.emitChange(v)},A.addEventListener("change",d=>{d.stopPropagation();const y={...this._value??{}};y[g]=d.detail.value,this._value=y,this.emitChange(y)}),D.append(T,A,b),n.appendChild(D),m===g&&(D.classList.add("enter"),requestAnimationFrame(()=>D.classList.add("enter-active")),requestAnimationFrame(()=>D.classList.remove("enter")))}),h&&l(h)};c();const u=document.createElement("button");u.type="button",u.className="btn primary",ie(u,"field-button","field-button-primary"),u.textContent=this._i18n.dictAdd??"+",u.onclick=()=>{let h=Object.keys(s).length+1,m=`k${h}`;for(;s[m]!==void 0;)m=`k${++h}`;const g=a();s[m]=Pi(r);const k={...this._value??{},[m]:s[m]};this._value=k,c(g,m),this.emitChange(k)};const f=document.createElement("div");f.className="actions",ie(f,"field-actions"),f.appendChild(u),i.appendChild(n),i.appendChild(f),this.$root.appendChild(i)}}me("schema-form-dict",iu);class nu extends HTMLElement{constructor(){super(),this._i18n={...Kc},this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=et,this.$root.appendChild(e);const i=document.createElement("div");i.className="wrapper",ie(i,"wrapper");const n=document.createElement("form");n.className="form",ie(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:Ig(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=Qc(e);try{this._state=this._schema(null,{autofix:!0})}catch{this._state=Pi(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=Pi(this._schema)}this.render()}refresh(){this.render()}set i18n(e){this._i18n={...this._i18n,...e},this.render()}get i18n(){return this._i18n}render(){if(!this._schema)return;const e=this.$root.querySelector("form");e.innerHTML="";const i=Ci(this._schema,[],this._state,this._i18n.rootLabel,this._i18n);e.appendChild(i)}}me("schema-form",nu);function Ng(){me("schema-form",nu),me("schema-form-string",Yc),me("schema-form-number",Gc),me("schema-form-boolean",Xc),me("schema-form-date",Jc),me("schema-form-const",mo),me("schema-form-union",Zc),me("schema-form-tuple",eu),me("schema-form-object",tu),me("schema-form-array",wr),me("schema-form-dict",iu)}const Mg=Ul({__name:"SchemasteryFormVue",props:Ql({schema:{},value:{},validateOnChange:{type:Boolean,default:!1}},{schema:{required:!0},schemaModifiers:{},value:{required:!1,default:{}},valueModifiers:{}}),emits:Ql(["change"],["update:schema","update:value"]),setup(t,{expose:e,emit:i}){const n=mc(t,"schema"),r=mc(t,"value"),s=i,o=Zp("elRef");let a=!1,l=!1;const c=u=>{if(l)return;const f=o.value,h=t.validateOnChange?f.getData({validate:!0}):u.detail.state;a=!0,r.value=h,or(()=>{a=!1}),s("change",u.detail)};return zl(()=>{Ng()}),Vs(()=>{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)}),Wl(()=>{o.value?.removeEventListener("form-change",c)}),Si(()=>n,u=>{a||o.value&&u&&o.value.schema!==u.value&&(l=!0,o.value.schema=u.value,or(()=>{l=!1}))},{deep:!0,immediate:!0}),Si(()=>r,u=>{if(a||!o.value||u.value===void 0)return;const f=o.value.getData({validate:!1});JSON.stringify(f)!==JSON.stringify(u.value)&&(l=!0,o.value.setData(u.value,{validate:!1}),or(()=>{l=!1}))},{deep:!0,immediate:!0}),e({setData(u,f){const h=o.value;h.setData(u,{validate:!!f?.validate}),f?.emit&&(r.value=h.getData({validate:!!f?.validate}))},getData(u){return o.value.getData(u)},setSchema(u,f=!0){o.value.schema=u,f&&(n.value=u)},refresh(){o.value.refresh()},reset(){o.value.reset()},el:o}),(u,f)=>(Wt(),ki("schema-form",$c({ref_key:"elRef",ref:o},u.$attrs),null,16))}});function ri(t,e=new WeakMap){if(ke(t))return ri(t.value,e);if(t===null||typeof t!="object")return t;if(e.has(t))return e.get(t);if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if(t instanceof Map){const r=new Map;return e.set(t,r),Array.from(t.entries()).forEach(([s,o])=>{r.set(s,ri(o,e))}),r}if(t instanceof Set){const r=new Set;return e.set(t,r),Array.from(t).forEach(s=>{r.add(ri(s,e))}),r}if(Array.isArray(t)){const r=[];e.set(t,r);for(const s of t)r.push(ri(s,e));return r}const i=te(t),n={};e.set(t,n);for(const r of Object.keys(i))n[r]=ri(i[r],e);for(const r of Object.getOwnPropertySymbols(i))n[r]=ri(i[r],e);return n}const Dg={class:"preferences-ui-app"},jg={class:"tabbar"},Ug={class:"tabbar-tabs"},Fg=["onClick","data-value"],Bg={class:"tabbar-content"},qg={key:0},Hg={style:{"max-height":"20em",overflow:"auto"}},zg=((t,e)=>{const i=t.__vccOpts||t;for(const[n,r]of e)i[n]=r;return i})(Ul({__name:"PreferencesForm",setup(t,{expose:e}){const i=Cg(),n=!1,r=Ol([]),s=Ol(""),o=tr([]),a=Tc(()=>o.value.map(u=>u.schema)),l=tr({}),c=tr({});return e({getValue(){return ri(c)}}),Si(s,u=>{u&&(l.value=c.value,o.value=i.preferences.getConfigRegistries(u))},{immediate:!0}),Vs(async()=>{i.inject(["preferences"],async u=>{const f=await u.preferences.getAll();l.value=c.value=f,r.value=u.preferences.getConfigCategories(),s.value=r.value[0].name})}),(u,f)=>(Wt(),ki("div",Dg,[Ei("div",jg,[Ei("div",Ug,[(Wt(!0),ki(at,null,Vl(r.value,h=>(Wt(),ki("a",{class:Vn(["tab",{active:s.value===h.name}]),key:h.name,onClick:m=>s.value=h.name,"data-value":h.name},Cs(h.label),11,Fg))),128))]),Ei("div",Bg,[(Wt(!0),ki(at,null,Vl(a.value,(h,m)=>(Wt(),Sc(Hs(Mg),{key:`${s.value}-${m}`,schema:h,value:l.value,"onUpdate:value":f[0]||(f[0]=g=>c.value=g),"validate-on-change":!1,i18n:{rootLabel:""}},null,8,["schema","value"]))),128))])]),Hs(n)?(Wt(),ki("details",qg,[Ei("pre",Hg,Cs(c.value),1)])):Hm("",!0)]))}}),[["__scopeId","data-v-59cb1172"]]);var Wg=Object.create,go=Object.defineProperty,Kg=Object.getOwnPropertyDescriptor,ru=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),su=t=>{throw TypeError(t)},Vg=(t,e,i)=>e in t?go(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Qg=(t,e)=>go(t,"name",{value:e,configurable:!0}),Yg=t=>[,,,Wg(t?.[ru("metadata")]??null)],Gg=["class","method","getter","setter","accessor","field","value","get","set"],ou=t=>t!==void 0&&typeof t!="function"?su("Function expected"):t,Xg=(t,e,i,n,r)=>({kind:Gg[t],name:e,metadata:n,addInitializer:s=>i._?su("Already initialized"):r.push(ou(s||null))}),Jg=(t,e)=>Vg(e,ru("metadata"),t[3]),Zg=(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},ey=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(r=r.prototype,c<5&&(c>3||!u)&&Kg(r,i));Qg(r,i);for(var g=n.length-1;g>=0;g--)l=Xg(c,i,a={},t[3],h),o=(0,n[g])(r,l),a._=1,ou(o)&&(r=o);return Jg(t,r),m&&go(r,i,m),u?c^4?s:m:r},au,yo,lu;au=[xe(["preferences","modal"])];class vr extends(lu=Ve){constructor(e){super(e,{},"preferences-ui"),this.ctx=e,this._latestModal=null,e.set("preferencesUI",this),e.set("prefsModal",this),e.preferences.defineCategory({name:"about",label:"About",description:"About InPageEdit",index:99}),e.preferences.registerCustomConfig("about",Y.object({about:Y.const(p("div",{className:"prose",children:[p("h2",{children:"✏️ InPageEdit NEXT"}),p("i",{children:["v",this.ctx.version]}),p("h2",{children:"Portals"}),p("div",{style:"display: grid; gap: 0.5em; text-align: center",children:[p("a",{className:"btn primary",style:{display:"inline-block",textDecoration:"none"},href:this.ctx.Endpoints.HOME_URL,target:"_blank",children:"Official Website & Help Center"}),p("a",{className:"btn primary",style:{display:"inline-block",textDecoration:"none"},href:`${this.ctx.Endpoints.UPDATE_LOGS_URL}#${this.ctx.version.split("-")[0]}`,target:"_blank",children:"Update Logs"})]}),p("h2",{children:"Join us"}),p("ul",{children:[p("li",{children:[p("strong",{children:"GitHub"}),":"," ",p("a",{href:this.ctx.Endpoints.GITHUB_URL,target:"_blank",children:"inpageedit/inpageedit-next"})]}),p("li",{children:[p("strong",{children:"QQ Group"}),": 1026023666"]})]}),p("hr",{}),p("p",{children:"🚀 Modular, Extensible Supercharged Plugin for MediaWiki."}),p("p",{children:"InPageEdit-NEXT Copyright © 2025-present dragon-fish"})]})).role("raw-html")}).description(""),"about"),e.inject(["toolbox"],i=>{i.toolbox.addButton({id:"preferences",icon:p("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:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("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:"Configure Preferences",group:"group2",index:1/0,onClick:()=>this.showModal()}),this.addDisposeHandler(n=>{n.toolbox.removeButton("preferences")})})}async start(){Promise.resolve().then(()=>Nb).then(({PluginPrefSync:e})=>{this.ctx.plugin(e)}).catch(this.ctx.logger.warn)}stop(){}showModal(){if(this._latestModal&&!this._latestModal.isDestroyed)return this._latestModal;const e=this.ctx.modal.show({className:"ipe-preference compact-buttons",sizeClass:"small",outSideClose:!1,center:!0,title:`InPageEdit Preferences (${this.ctx.version})`,content:p(Ct,{children:p(jt,{})})});e.get$window().classList.add("dialog");const i=p("div",{id:"ipe-preferences-app",style:{minHeight:"65vh"}});e.setContent(i);const n=this.createForm(),r=n.mount(i);return e.setButtons([{label:"Cancel",className:"is-danger is-ghost",method:()=>{e.close()}},{label:"Save",className:"is-primary is-ghost",method:()=>{const s=r.getValue();this.logger.info("saving preferences",s);try{Object.entries(s).forEach(([o,a])=>{this.ctx.preferences.set(o,a).catch(console.error)})}catch(o){this.logger.error("failed to save preferences",o)}e.close(),this.ctx.modal.notify("success",{title:"Preferences Saved",content:p("p",{children:"Some settings may take effect after reloading the page."})})}}]),this._latestModal=e,e.on(e.Event.Close,()=>{this.logger.debug("preferences modal closed, vue app unmounting"),n.unmount(),this._latestModal=null}),e}closeModal(){this._latestModal?.close()}getExistingModal(){return this._latestModal}createForm(){return Og(this.ctx,zg)}}yo=Yg(lu),vr=ey(yo,0,"PluginPreferencesUI",au,vr),Zg(yo,1,vr);const ty=Object.freeze(Object.defineProperty({__proto__:null,get PluginPreferencesUI(){return vr}},Symbol.toStringTag,{value:"Module"})),iy=Symbol("@@apply"),ny=Symbol("@@ctor");function bo(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[iy]=i,i[ny]=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 _r={mbox:"_mbox_5x43w_1",title:"_title_5x43w_12",content:"_content_5x43w_19",close:"_close_5x43w_27"},pn=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(!f)return Promise.resolve();const{promise:h,resolve:m}=Promise.withResolvers();return f.animate([{opacity:"1",height:f.clientHeight+"px"},{opacity:"0",height:"0px",margin:"0px"}],{duration:300,easing:"ease"}).addEventListener("finish",()=>{f.remove(),m()}),h},f=p("div",{className:`theme-ipe ipe-mbox mbox-type-${e||"default"} ${_r.mbox}`,...l,children:[c&&p("div",{className:`ipe-mbox-title ${_r.title}`,...s,children:c}),p("div",{className:`ipe-mbox-content ${_r.content}`,...o,children:a||n}),r&&p("a",{onClick:u,className:`ipe-mbox-close ${_r.close}`,children:"×"})]});return f.close=u,f},mn=t=>{const{label:e,id:i,name:n,value:r,disabled:s,labelProps:o,inputProps:a,...l}=t;return p("div",{className:"theme-ipe ipe-input-box",...l,children:[p("label",{htmlFor:i,style:{display:"block"},...o,children:e}),p("input",{id:i,name:n,value:r,disabled:s,style:{width:"100%"},...a})]})},ry=t=>{const{id:e,name:i,value:n,label:r,inputProps:s,labelProps:o,children:a,...l}=t;return p("label",{className:"theme-ipe ipe-radio-box",...l,children:[p("input",{type:"radio",id:e,name:i,value:n,...s}),p("span",{className:"ipe-checkbox-box"}),p("span",{...o,children:r||a})]})},Oi=t=>{const{id:e,name:i,label:n,checked:r,inputProps:s,labelProps:o,children:a,...l}=t;return p("label",{className:"theme-ipe ipe-checkbox",...l,children:[p("input",{type:"checkbox",id:e,name:i,checked:r,...s}),p("span",{className:"ipe-checkbox-box"}),p("span",{...o,children:n||a})]})},wo=()=>{},sy=(t=0)=>new Promise(e=>setTimeout(e,t));var oy=Object.create,vo=Object.defineProperty,ay=Object.getOwnPropertyDescriptor,cu=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),uu=t=>{throw TypeError(t)},ly=(t,e,i)=>e in t?vo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,cy=(t,e)=>vo(t,"name",{value:e,configurable:!0}),uy=t=>[,,,oy(t?.[cu("metadata")]??null)],fy=["class","method","getter","setter","accessor","field","value","get","set"],fu=t=>t!==void 0&&typeof t!="function"?uu("Function expected"):t,dy=(t,e,i,n,r)=>({kind:fy[t],name:e,metadata:n,addInitializer:s=>i._?uu("Already initialized"):r.push(fu(s||null))}),hy=(t,e)=>ly(e,cu("metadata"),t[3]),py=(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},my=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(r=r.prototype,c<5&&(c>3||!u)&&ay(r,i));cy(r,i);for(var g=n.length-1;g>=0;g--)l=dy(c,i,a={},t[3],h),o=(0,n[g])(r,l),a._=1,fu(o)&&(r=o);return hy(t,r),m&&vo(r,i,m),u?c^4?s:m:r},du,_o,hu;du=[xe(["api","wikiPage","wikiTitle","currentPage","wiki","modal","preferences"]),pi(Y.object({"quickEdit.editSummary":Y.string().description("Default edit summary for quick edits").default("[IPE-NEXT] Quick edit"),"quickEdit.editMinor":Y.boolean().description('Default to checking "minor edit" option').default(!1),"quickEdit.outSideClose":Y.boolean().description("Close editor modal by clicking outside").default(!0),"quickEdit.watchList":Y.union([Y.const(Je.preferences).description("Follow MW preferences"),Y.const(Je.nochange).description("Keep the current watchlist status"),Y.const(Je.watch).description("Add the page to watchlist"),Y.const(Je.unwatch).description("Remove the page from watchlist")]).description("Watchlist options").default(Je.preferences),"quickEdit.keyshortcut.save":Y.string().default("ctrl-s").description("save button key shortcut (blank to disable)"),"quickEdit.editFont":Y.union([Y.const("preferences").description("Follow MW preferences"),Y.const("monospace").description("Monospace"),Y.const("sans-serif").description("Sans-serif"),Y.const("serif").description("Serif"),Y.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","edit"))];let xr=(oi=class extends(hu=Ve){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",bo(this,"showModal"))}start(){this.ctx.inject(["toolbox"],e=>{this.injectToolbox(e),e.on("dispose",()=>{this.removeToolbox(e)})})}async showModal(e){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 A=new URLSearchParams(window.location.search),b=this.ctx.currentPage.wikiTitle;e={...e,title:b?.getPrefixedDBKey(),revision:A.has("oldid")?Number(A.get("oldid")):void 0,pageId:A.has("curid")?Number(A.get("curid")):void 0}}if(!e.revision&&!e.pageId&&e.title){const A=this.ctx.wikiTitle.resolveSpecialPageTarget(e.title);A&&A.title.getNamespaceId()>=0&&(e.title=A.title.getPrefixedDBKey(),e.section??(e.section=A.section))}const i=await this.ctx.preferences.get("quickEdit.outSideClose"),n=await this.ctx.preferences.get("quickEdit.watchList"),r=typeof e.editSummary=="string"?e.editSummary:await this.ctx.preferences.get("quickEdit.editSummary"),s=typeof e.editMinor=="boolean"?e.editMinor:await this.ctx.preferences.get("quickEdit.editMinor"),o=await this.getEditFontOptions(),a={...this.DEFAULT_OPTIONS,editSummary:r,editMinor:s,...e};a.editSummary||(a.editSummary=await this.ctx.preferences.get("quickEdit.editSummary")||""),this.ctx.emit("quick-edit/init-options",{ctx:this.ctx,options:a});const l=this.ctx.modal.createObject({className:"ipe-quickEdit",sizeClass:"large",center:!1,outSideClose:i}).init();l.setTitle(p(Ct,{children:["Loading: ",p("u",{children:a.title})]})),l.setContent(p("section",{className:"ipe-quickEdit-loading",style:{height:"70vh",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:p(jt,{})})),l.addButton({side:"right",type:"button",className:"is-danger is-ghost",label:"Cancel",method(){l.close()}}),l.show(),this.ctx.emit("quick-edit/show-modal",{ctx:this.ctx,modal:l,options:a});let c;try{if(c=await this.getWikiPageFromPayload(a),c.pageInfo.special)throw new Error("Special page is not editable")}catch(A){l.off(l.Event.Close),l.close(),this.ctx.modal.notify("error",{content:A instanceof Error?A.message:String(A)});return}const u=a.section==="new"?"":c.revisions[0]?.content||"",f=c.revisions[0]?.revid,h=f&&f!==c.lastrevid,m=a.section==="new",g=c.pageid===0;l.setTitle(p(Ct,{children:[m?"New section":`Quick ${g?"Create":"Edit"}`,":"," ",p("u",{children:c.pageInfo.title}),h?` (Revision ${f})`:""]}));const k=[];g&&k.push(p(pn,{title:"Attention",type:"important",children:p("p",{children:"This page does not exist."})})),h&&k.push(p(pn,{title:"Attention",type:"warning",children:p("p",{children:["You are editing a ",p("em",{children:"historical version"}),"; the content is not the latest!"]})})),this.ctx.emit("quick-edit/edit-notice",{ctx:this.ctx,options:a,modal:l,wikiPage:c,editNotices:k});const D=p("form",{className:"ipe-quickEdit__form",children:[p("div",{className:"ipe-quickEdit__notices",children:k}),p("div",{className:"ipe-quickEdit__content",style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[a.section==="new"&&p(Ct,{children:p(mn,{label:"Section title",id:"summary",name:"summary",value:"",inputProps:{placeholder:"Topic for new section, this will be the h2 heading"}})}),p("textarea",{className:`ipe-quickEdit__textarea ${o.className}`,style:{fontFamily:o.fontFamily},name:"text",id:"wpTextbox1",children:u})]}),p("div",{class:"ipe-quickEdit__options",style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[!m&&p(mn,{label:"Summary",id:"summary",name:"summary",value:a.editSummary}),p("div",{className:"ipe-input-box",children:[p("label",{htmlFor:"watchlist",style:{display:"block"},children:"Watchlist"}),p("div",{style:{display:"flex",gap:"1rem"},children:[Je.preferences,Je.nochange,Je.watch,Je.unwatch].map(A=>p(ry,{name:"watchlist",value:A,inputProps:{checked:n===A},children:A},A))})]}),p("div",{style:{display:"flex",gap:"1rem"},children:[p(Oi,{name:"minor",id:"minor",checked:a.editMinor,children:"Minor edit"}),p(Oi,{name:"reloadAfterSave",id:"reloadAfterSave",checked:a.reloadAfterSave,children:"Reload after save"})]})]}),!1]});l.setContent(D),l.addButton({side:"left",className:"is-primary submit-btn",label:"Submit",keyPress:await this.ctx.preferences.get("quickEdit.keyshortcut.save")||void 0,method:()=>{const A=new FormData(D);l.setLoadingState(!0),this.handleSubmit({wikiPage:c,text:A.get("text"),summary:A.get("summary"),minor:A.get("minor")==="on",section:a.section,createonly:c.pageid===0,watchlist:n}).then(async()=>{l.setOptions({beforeClose:wo}),l.close(),this.ctx.modal.notify("success",{title:"Submission Successful",content:"Your changes have been saved."}),A.get("reloadAfterSave")&&(await sy(500),location.reload())}).catch(b=>{this.ctx.modal.notify("error",{title:"Submission Error",content:b instanceof Error?b.message:String(b)}),l.setLoadingState(!1)})}},0),l.setOptions({beforeClose:()=>{const A=c.revisions[0]?.content||"";return(D.querySelector("textarea")?.value||"")===A?!0:(this.ctx.modal.confirm({className:"is-primary",title:"Unsaved Changes",content:"All edit contents will be lost after closing the modal. Are you sure you want to close?",center:!0,okBtn:{label:"Give Up",className:"is-danger is-ghost"},cancelBtn:{label:"Continue Editing",className:"is-primary is-ghost"}},d=>(d&&(l.setOptions({beforeClose:wo}),l.close()),!0)),!1)}}),this.ctx.emit("quick-edit/wiki-page",{ctx:this.ctx,options:a,modal:l,wikiPage:c});const T=A=>D.querySelector("textarea")?.value===u?!0:(A.preventDefault(),"You have unsaved changes. Are you sure you want to leave?");window.addEventListener("beforeunload",T),l.on(l.Event.Close,()=>{window.removeEventListener("beforeunload",T)})}async handleSubmit(e){const i=e.wikiPage,n=e.summary||"",r=e.text||"",s=e.minor,o=e.createonly,a=e.watchlist,l=e.section;return this.ctx.emit("quick-edit/submit",{ctx:this.ctx,wikiPage:i,summary:n,text:r,minor:s,createonly:o,watchlist:a}),i.edit({summary:n,text:r,watchlist:a,section:l},{minor:s,createonly:o})}async getEditFontOptions(){const e=await this.ctx.preferences.get("quickEdit.editFont");return oi.BUILT_IN_FONT_OPTIONS.includes(e)?{className:`mw-editfont-${e==="preferences"?this.ctx.wiki.userOptions?.editfont||"monospace":e}`,fontFamily:""}:{className:"mw-editfont-custom",fontFamily:e}}async getWikiPageFromPayload(e){if(e.revision)return this.ctx.wikiPage.newFromRevision(e.revision,e.section);if(e.pageId)return this.ctx.wikiPage.newFromPageId(e.pageId,e.section);if(e.title)return this.ctx.wikiPage.newFromTitle(e.title,!1,e.section);throw new Error("Invalid payload")}async injectToolbox(e){const i=this.ctx.currentPage.wikiTitle,n=this.ctx.wiki.hasRight("edit")&&i&&i.getNamespaceId()>=0;e.toolbox.addButton({id:"quick-edit",group:"group1",index:0,icon:p("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:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1"}),p("path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z"}),p("path",{d:"M16 5l3 3"})]}),buttonProps:{disabled:!n},tooltip:n?"Quick Edit":"Not editable",onClick:()=>{const r=new URLSearchParams(window.location.search).get("oldid");this.showModal({title:i?.getPrefixedText(),revision:r?Number(r):void 0})}})}removeToolbox(e){e.toolbox.removeButton("quick-edit")}},oi.BUILT_IN_FONT_OPTIONS=["preferences","monospace","sans-serif","serif"],oi);_o=uy(hu),xr=my(_o,0,"PluginQuickEdit",du,xr),py(_o,1,xr);const gy=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickEdit:xr},Symbol.toStringTag,{value:"Module"}));var yy=Object.create,xo=Object.defineProperty,by=Object.getOwnPropertyDescriptor,pu=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),mu=t=>{throw TypeError(t)},wy=(t,e,i)=>e in t?xo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,vy=(t,e)=>xo(t,"name",{value:e,configurable:!0}),_y=t=>[,,,yy(t?.[pu("metadata")]??null)],xy=["class","method","getter","setter","accessor","field","value","get","set"],gu=t=>t!==void 0&&typeof t!="function"?mu("Function expected"):t,Sy=(t,e,i,n,r)=>({kind:xy[t],name:e,metadata:n,addInitializer:s=>i._?mu("Already initialized"):r.push(gu(s||null))}),ky=(t,e)=>wy(e,pu("metadata"),t[3]),Ey=(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},$y=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(r=r.prototype,c<5&&(c>3||!u)&&by(r,i));vy(r,i);for(var g=n.length-1;g>=0;g--)l=Sy(c,i,a={},t[3],h),o=(0,n[g])(r,l),a._=1,gu(o)&&(r=o);return ky(t,r),m&&xo(r,i,m),u?c^4?s:m:r},yu,So,bu;yu=[xe(["api","wikiPage","wikiTitle","currentPage","wiki","modal","preferences"]),pi(Y.object({deleteReason:Y.string().description("Default delete reason for quick delete").default("[IPE-NEXT] Quick delete")}).description("Quick delete options").extra("category","delete"))];class Sr extends(bu=Ve){constructor(e){super(e,{},"quick-delete"),this.ctx=e,this.DEFAULT_OPTIONS={title:"",pageId:0,revision:0,deleteReason:"",reloadAfterDelete:!0},this.ctx.root.set("quickDelete",bo(this,"showModal"))}start(){this.ctx.inject(["toolbox"],e=>{this.injectToolbox(e),e.on("dispose",()=>{this.removeToolbox(e)})}),this.ctx.preferences.defineCategory({label:"Delete",name:"delete",description:"Settings related to deleting pages",index:3})}async showModal(e){if(typeof e>"u"?e={}:typeof e=="string"&&(e={title:e}),!e.title&&!e.pageId&&!e.revision){this.logger.warn("None of the title, pageId or revision provided. Using defaults.");const l=new URLSearchParams(window.location.search),c=this.ctx.currentPage.wikiTitle;e={...e,title:c?.getPrefixedDBKey(),revision:l.has("oldid")?Number(l.get("oldid")):void 0,pageId:l.has("curid")?Number(l.get("curid")):void 0}}const i=typeof e.deleteReason=="string"?e.deleteReason:await this.ctx.preferences.get("deleteReason"),n={...this.DEFAULT_OPTIONS,deleteReason:i,...e};n.deleteReason||(n.deleteReason=await this.ctx.preferences.get("deleteReason")||""),n||this.ctx.emit("quick-delete/init-options",{ctx:this.ctx,options:n});const r=this.ctx.modal.createObject({className:"ipe-quickDelete",sizeClass:"small",center:!0}).init();r.setTitle(p(Ct,{children:["Loading: ",p("u",{children:n.title})]})),r.setContent(p(jt,{})),r.addButton({side:"right",type:"button",className:"is-ghost",label:"Cancel",method(){r.close()}}),r.show(),this.ctx.emit("quick-delete/show-modal",{ctx:this.ctx,modal:r,options:n});let s;try{if(s=await this.getWikiPageFromPayload(n),s.pageInfo.special)throw new Error("Special page cannot be deleted");if(s.pageInfo.pageid===0)throw new Error("Page does not exist, cannot be deleted")}catch(l){r.off(r.Event.Close),r.close(),this.ctx.modal.notify("error",{content:l instanceof Error?l.message:String(l)});return}r.setTitle(p(Ct,{children:["Quick Delete: ",p("u",{children:s.pageInfo.title})]}));const o=[];s.userCan("delete")||o.push(p(pn,{title:"Permission Denied",type:"error",children:p("p",{children:"You do not have permission to delete this page."})})),s.pageInfo.protection&&s.pageInfo.protection.length>0&&o.push(p(pn,{title:"Warning",type:"warning",children:p("p",{children:"This page is protected and may has special use or purpose. Delete it at your own risk."})})),this.ctx.emit("quick-delete/delete-notice",{ctx:this.ctx,options:n,modal:r,wikiPage:s,deleteNotices:o});const a=p("form",{className:"ipe-quickDelete__form",children:[p("div",{className:"ipe-quickDelete__notices",children:o}),p("div",{className:"ipe-quickDelete__content",children:p("div",{className:"ipe-quickDelete__page-info",style:{padding:"1rem",backgroundColor:"#f8f9fa",border:"1px solid #dee2e6",borderRadius:"4px",marginBottom:"1rem"},children:p("ul",{children:[p("li",{children:[p("strong",{children:"Title:"})," ",s.pageInfo.title]}),p("li",{children:[p("strong",{children:"Page ID:"})," ",s.pageInfo.pageid]}),p("li",{children:[p("strong",{children:"Last Revision:"})," ",s.pageInfo.lastrevid]}),p("li",{children:[p("strong",{children:"Length:"})," ",s.pageInfo.length," characters"]})]})})}),p("div",{class:"ipe-quickDelete__options",style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:p(mn,{label:"Delete Reason",id:"reason",name:"reason",value:n.deleteReason,inputProps:{placeholder:"Enter reason for deletion...",required:!0}})}),!1]});r.setContent(a),r.addButton({side:"left",className:"is-danger submit-btn",label:"Delete Page",method:()=>{const c=new FormData(a).get("reason");if(!c||c.trim()===""){this.ctx.modal.notify("error",{title:"Missing Reason",content:"Please provide a reason for deletion."});return}this.ctx.modal.confirm({className:"is-danger",title:"Confirm Deletion",content:p(Ct,{children:p("p",{children:p("strong",{children:s.pageInfo.title})})}),center:!0,okBtn:{label:"Delete it now",className:"is-danger"},cancelBtn:{label:"Cancel",className:"is-ghost"}},u=>(u&&(r.setLoadingState(!0),this.handleSubmit({wikiPage:s,reason:c}).then(async()=>{r.setOptions({beforeClose:wo}),r.close(),this.ctx.modal.notify("success",{title:"Deletion Successful",content:`The page "${s.pageInfo.title}" has been deleted.`}),this.ctx.emit("quick-delete/submit",{ctx:this.ctx,wikiPage:s,reason:c})}).catch(f=>{this.ctx.modal.notify("error",{title:"Deletion Error",content:f instanceof Error?f.message:String(f)}),r.setLoadingState(!1)})),!0))}},0),this.ctx.emit("quick-delete/wiki-page",{ctx:this.ctx,options:n,modal:r,wikiPage:s})}async handleSubmit(e){const i=e.wikiPage,n=e.reason||"";return i.delete(n)}async getWikiPageFromPayload(e){if(e.revision)return this.ctx.wikiPage.newFromRevision(e.revision);if(e.pageId)return this.ctx.wikiPage.newFromPageId(e.pageId);if(e.title)return this.ctx.wikiPage.newFromTitle(e.title,!1);throw new Error("Invalid payload")}async injectToolbox(e){const i=this.ctx.currentPage.wikiTitle,n=i&&this.ctx.wiki.hasRight("delete")&&i.getNamespaceId()>=0;e.toolbox.addButton({id:"quick-delete",group:"group2",icon:p("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-trash",children:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("path",{d:"M4 7l16 0"}),p("path",{d:"M10 11l0 6"}),p("path",{d:"M14 11l0 6"}),p("path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12"}),p("path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"})]}),buttonProps:{disabled:!n},tooltip:n?"Quick Delete":"Not deletable",onClick:()=>{this.showModal({title:i?.getPrefixedText()})}})}removeToolbox(e){e.toolbox.removeButton("quick-delete")}}So=_y(bu),Sr=$y(So,0,"PluginQuickDelete",yu,Sr),Ey(So,1,Sr);const Py=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickDelete(){return Sr}},Symbol.toStringTag,{value:"Module"})),gn={twinSwapInput:"_twinSwapInput_1gdgl_9",inputWrapper:"_inputWrapper_1gdgl_23",inputLeft:"_inputLeft_1gdgl_27",inputRight:"_inputRight_1gdgl_30",swapButton:"_swapButton_1gdgl_46"},wu=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(g=>g&&g.disabled),u=()=>{if(!s[0]||!s[1]||c())return;const g=s[0],k=s[1],D=g.value,T=k.value;g.value=T,k.value=D,g.dispatchEvent(new Event("change")),k.dispatchEvent(new Event("change")),o++,l&&(l.style.transform=`rotateY(${o*-180}deg)`,l.style.transition="transform 200ms ease")},f=g=>{if(!a)return;const k=g??!a.disabled;a.disabled=!k,k&&s.forEach(D=>{D&&(D.disabled=!1)})},h=p("button",{type:"button","aria-label":"Swap values",onClick:u,disabled:c()||!i,ref:g=>a=g,children:p("svg",{ref:g=>l=g,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:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("path",{d:"M20 10h-16l5.5 -6"}),p("path",{d:"M4 14h16l-5.5 6"})]})}),m=p("div",{className:`twin-swap-input ${gn.twinSwapInput}`,...n,children:[r.map((g,k)=>{const{label:D,id:T,name:A,value:b,disabled:d,required:y,inputProps:v}=g,x=k===0,E=T||A;return p("div",{className:`${gn.inputWrapper} ${x?gn.inputLeft:gn.inputRight}`,children:[D&&p("label",{htmlFor:E,children:D}),p("input",{ref:L=>s[k]=L,type:"text",id:E,name:A,value:b,disabled:d,required:y,...v})]})}),p("div",{className:gn.swapButton,children:h})]});return m.swap=u,m.toggleEnableSwap=f,m};var Cy=Object.create,ko=Object.defineProperty,Oy=Object.getOwnPropertyDescriptor,vu=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),_u=t=>{throw TypeError(t)},Iy=(t,e,i)=>e in t?ko(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ay=(t,e)=>ko(t,"name",{value:e,configurable:!0}),Ty=t=>[,,,Cy(t?.[vu("metadata")]??null)],Ry=["class","method","getter","setter","accessor","field","value","get","set"],xu=t=>t!==void 0&&typeof t!="function"?_u("Function expected"):t,Ly=(t,e,i,n,r)=>({kind:Ry[t],name:e,metadata:n,addInitializer:s=>i._?_u("Already initialized"):r.push(xu(s||null))}),Ny=(t,e)=>Iy(e,vu("metadata"),t[3]),My=(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},Dy=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(r=r.prototype,c<5&&(c>3||!u)&&Oy(r,i));Ay(r,i);for(var g=n.length-1;g>=0;g--)l=Ly(c,i,a={},t[3],h),o=(0,n[g])(r,l),a._=1,xu(o)&&(r=o);return Ny(t,r),m&&ko(r,i,m),u?c^4?s:m:r},Su,Eo,ku;Su=[xe(["modal","wiki"])];class kr extends(ku=Ve){constructor(e){super(e,{},"quick-move"),this.ctx=e,e.set("quickMove",this.quickMove.bind(this)),e.set("movePage",this.movePage.bind(this))}start(){this.ctx.inject(["toolbox"],e=>{this.injectToolbox(e)})}injectToolbox(e){const i=window.mw?.config.get("wgPageName")||"",n=window.mw?.config.get("wgIsProbablyEditable");e.toolbox.addButton({id:"quick-move",icon:p("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:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("path",{d:"M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3"}),p("path",{d:"M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3"}),p("path",{d:"M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7"}),p("path",{d:"M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1"}),p("path",{d:"M17 12h.01"}),p("path",{d:"M13 12h.01"})]}),tooltip:"Quick Move",group:"group1",index:1,onClick:()=>{this.quickMove(n?{lockFromField:!0,from:i}:{})}})}quickMove(e){const i=this.ctx.modal.createObject({title:"Quick Move",content:p(jt,{}),className:"quick-move compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let n=null;return i.setContent(p("form",{ref:r=>n=r,style:{display:"flex",flexDirection:"column",gap:"1rem"},onSubmit:r=>{if(r.preventDefault(),n?.checkValidity(),!n?.reportValidity())return;const s=new FormData(n),o={from:s.get("from")?.toString().trim(),to:s.get("to")?.toString().trim(),reason:s.get("reason")||"",movetalk:s.get("movetalk")==="on",movesubpages:s.get("movesubpages")==="on",noredirect:s.get("noredirect")==="on"};if(!o.from||!o.to){this.ctx.modal.notify("error",{title:"Failed to move",content:"From and to are required."});return}this.ctx.emit("quick-move/submit",{ctx:this.ctx,modal:i,payload:o}),i.setLoadingState(!0),this.movePage(o).then(()=>{location.reload()}).catch(a=>{i.setLoadingState(!1),this.ctx.modal.notify("error",{title:"Failed to move",content:a instanceof Error?a.message:String(a)})})},children:[p(wu,{inputs:[{label:"Move from",name:"from",value:e?.from,required:!0},{label:"Move to",name:"to",value:e?.to,required:!0}]}),p("div",{children:p(Oi,{name:"movetalk",id:"movetalk",checked:e?.movetalk,children:"Move talk page"})}),p("div",{children:p(Oi,{name:"movesubpages",id:"movesubpages",checked:e?.movesubpages,children:"Move subpage(s) (up to 100)"})}),this.ctx.wiki.hasRight("suppressredirect")&&p("div",{children:p(Oi,{name:"noredirect",id:"noredirect",checked:e?.noredirect,children:"Move without leaving a redirect"})}),p(mn,{label:"Reason",id:"reason",name:"reason",value:e?.reason})]})),i.setButtons([{label:"Move",className:"is-primary is-ghost",method:()=>{n?.dispatchEvent(new Event("submit"))}}]),i.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)}}Eo=Ty(ku),kr=Dy(Eo,0,"PluginQuickMove",Su,kr),My(Eo,1,kr);const jy=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickMove(){return kr}},Symbol.toStringTag,{value:"Module"}));var Uy=Object.create,$o=Object.defineProperty,Fy=Object.getOwnPropertyDescriptor,Eu=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),$u=t=>{throw TypeError(t)},By=(t,e,i)=>e in t?$o(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,qy=(t,e)=>$o(t,"name",{value:e,configurable:!0}),Hy=t=>[,,,Uy(t?.[Eu("metadata")]??null)],zy=["class","method","getter","setter","accessor","field","value","get","set"],Pu=t=>t!==void 0&&typeof t!="function"?$u("Function expected"):t,Wy=(t,e,i,n,r)=>({kind:zy[t],name:e,metadata:n,addInitializer:s=>i._?$u("Already initialized"):r.push(Pu(s||null))}),Ky=(t,e)=>By(e,Eu("metadata"),t[3]),Vy=(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},Qy=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(r=r.prototype,c<5&&(c>3||!u)&&Fy(r,i));qy(r,i);for(var g=n.length-1;g>=0;g--)l=Wy(c,i,a={},t[3],h),o=(0,n[g])(r,l),a._=1,Pu(o)&&(r=o);return Ky(t,r),m&&$o(r,i,m),u?c^4?s:m:r},Cu,Po,Ou;Cu=[xe(["api","wikiPage","modal","preferences"]),pi(Y.object({"quickPreview.keyshortcut":Y.string().default("ctrl-p").description("Key shortcut to open quick preview in quick edit modal")}).extra("category","edit").description("Quick preview options"))];class Er extends(Ou=Ve){constructor(e){super(e,{},"quickPreview"),this.ctx=e,this.ctx.set("quickPreview",bo(this,"previewWikitext"))}start(){this.ctx.on("quick-edit/wiki-page",this.injectQuickEdit.bind(this)),this.ctx.on("quick-delete/wiki-page",this.injectQuickDelete.bind(this))}stop(){}previewWikitext(e,i,n,r,s){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("Preview - Loading..."),r.setContent(p(jt,{})),r.bringToFront(),this.ctx.emit("quick-preview/show-modal",{ctx:this.ctx,text:e,modal:r,wikiPage:n}),n.preview(e,i).then(o=>{const{data:{parse:a}}=o;r.setTitle(`Preview - ${a.title}`);let l=null;r.setContent(p("section",{children:p("div",{ref:c=>l=c,className:"mw-parser-output",innerHTML:a.text})})),window.mw?.hook("wikipage.content").fire($(l)),this.ctx.emit("quick-preview/loaded",{ctx:this.ctx,modal:r,wikiPage:n,text:e,parseData:a})}).catch(o=>{r.setTitle("Preview - Failed"),r.setContent(p(Ct,{children:[p("p",{children:"Failed to preview"}),p("p",{children:o instanceof Error?o.message:String(o)})]}))}),r}async injectQuickEdit({options:e,modal:i,wikiPage:n}){let r;i.addButton({label:"Preview",side:"left",className:"btn btn-secondary",keyPress:await this.ctx.preferences.get("quickPreview.keyshortcut.quickEdit")||void 0,method:()=>{let s=i.get$content().querySelector('textarea[name="text"]')?.value||"";if(e.section==="new"){const o=i.get$content().querySelector('input[name="summary"]')?.value;o&&(s=`==${o}==
121
- ${s}`)}r=this.previewWikitext(s,void 0,n,r,{backdrop:!1,draggable:!0})}},1),i.on(i.Event.Close,()=>{r?.destroy(),r=void 0})}injectQuickDelete({ctx:e,modal:i,wikiPage:n}){i.addButton({label:"Preview",side:"left",className:"btn btn-secondary",method:()=>{this.logger.warn("To be implemented: preview wikitext for quick delete")}},2)}}Po=Hy(Ou),Er=Qy(Po,0,"PluginQuickPreview",Cu,Er),Vy(Po,1,Er);const Yy=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickPreview(){return Er}},Symbol.toStringTag,{value:"Module"})),Gy=t=>{let{user:e,target:i,ctx:n}=t;const r=n.getUrl.bind(n);return p("span",{className:"mw-userlinks",children:[p("a",{href:r(`User:${e}`),className:"mw-userlink",target:i,children:e})," ",p("span",{className:"mw-usertoollinks",children:["(",p("a",{href:r(`User_talk:${e}`),className:"mw-usertoollinks-talk",target:i,children:"talk"})," | ",p("a",{href:r(`Special:Contributions/${e}`),className:"mw-usertoollinks-contribs",target:i,children:"contribs"})," | ",p("a",{href:r(`Special:Block/${e}`),className:"mw-usertoollinks-block",target:i,children:"block"}),")"]})]})};var $r=(t=>(t.update="ipe:diff-table/update",t.edit="ipe:diff-table/edit",t))($r||{});const Xy=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"medium"}).format,Iu=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 p("td",{colSpan:2,className:e,children:p("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 p("td",{colSpan:2,className:e,children:[p("div",{className:"mw-diff-title--title",children:[t.pagetitle||t.timestamp,t.revid?` (rev#${t.revid})`:""]}),p("div",{className:"mw-diff-title--actions",children:p("a",{href:t.ctx.getUrl("",{action:"edit",oldid:t.revid}),onClick:i,children:[p(Qa,{style:"width: 1em; height: 1em"}),"Quick edit"]})}),p("div",{className:"mw-diff-title--user",children:t.username&&p(Gy,{ctx:t.ctx,user:t.username,target:"_blank"})}),p("div",{className:"mw-diff-title--timestamp",children:t.timestamp&&Xy(new Date(t.timestamp))}),p("div",{className:"mw-diff-title--comment",children:t.parsedcomment&&p(Ct,{children:["(",p("i",{innerHTML:t.parsedcomment}),")"]})})]})},Jy=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 p("tr",{className:"mw-diff-title--navigation",children:[p("td",{colSpan:2,children:e.prev?p("a",{href:t.ctx.getUrl("",{diff:e.prev,oldid:e.fromrevid}),onClick:n=>i(n,e.prev,e.fromrevid),children:"← Previous"}):p("i",{children:"Oldest version"})}),p("td",{colSpan:2,children:e.next?p("a",{href:t.ctx.getUrl("",{diff:e.next,oldid:e.torevid}),onClick:n=>i(n,e.torevid,e.next),children:"Next →"}):p("i",{children:"Newest version"})})]})},Zy=t=>{const{data:e,...i}=t,n=p("table",{className:"theme-ipe diff diff-type-table","data-mw":"interface",...i,children:[p("colgroup",{children:[p("col",{className:"diff-marker"}),p("col",{className:"diff-content"}),p("col",{className:"diff-marker"}),p("col",{className:"diff-content"})]}),p("tbody",{children:[p("tr",{children:[p(Iu,{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}),p(Iu,{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})]}),p(Jy,{data:e,ctx:t.ctx}),p("div",{id:"diffbody"}),p("tr",{className:"diff-size",style:{textAlign:"center"},children:[p("td",{colSpan:2,className:"diff-size-old",children:e.fromsize!==void 0&&`${e.fromsize} bytes`}),p("td",{colSpan:2,className:"diff-size-new",children:e.tosize!==void 0&&`${e.tosize} bytes`})]})]})]});return n.querySelector("#diffbody").outerHTML=e.body||p("tr",{children:p("td",{colSpan:4,children:p("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"5rem"},children:p("i",{children:"No changes"})})})}).outerHTML,n},eb=(t,e=document)=>e.querySelector(t),tb=(t,e=document)=>e.querySelectorAll(t);var ib=Object.create,Co=Object.defineProperty,nb=Object.getOwnPropertyDescriptor,Au=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Tu=t=>{throw TypeError(t)},rb=(t,e,i)=>e in t?Co(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,sb=(t,e)=>Co(t,"name",{value:e,configurable:!0}),ob=t=>[,,,ib(t?.[Au("metadata")]??null)],ab=["class","method","getter","setter","accessor","field","value","get","set"],Ru=t=>t!==void 0&&typeof t!="function"?Tu("Function expected"):t,lb=(t,e,i,n,r)=>({kind:ab[t],name:e,metadata:n,addInitializer:s=>i._?Tu("Already initialized"):r.push(Ru(s||null))}),cb=(t,e)=>rb(e,Au("metadata"),t[3]),ub=(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},fb=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(r=r.prototype,c<5&&(c>3||!u)&&nb(r,i));sb(r,i);for(var g=n.length-1;g>=0;g--)l=lb(c,i,a={},t[3],h),o=(0,n[g])(r,l),a._=1,Ru(o)&&(r=o);return cb(t,r),m&&Co(r,i,m),u?c^4?s:m:r},Lu,Oo,Nu;Lu=[xe(["wiki","getUrl","preferences"]),pi(Y.object({"quickDiff.keyshortcut":Y.string().default("ctrl-d").description("Key shortcut to open quick diff in quick edit modal")}).description("Quick diff options").extra("category","edit"))];class Pr extends(Nu=Ve){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=eb("#mw-history-compare");if(!e)return;tb(".mw-history-compareselectedversions-button",e).forEach(n=>{n.after(p("button",{className:"cdx-button",onClick:r=>{r.preventDefault();const s=new FormData(e),o=Number(s.get("oldid"))||0,a=Number(s.get("diff"))||0;if(!s.get("title")||!o||!a)return this.logger.warn("Missing title or revision IDs");this.comparePages({fromrev:o,torev:a})},children:"Quick Diff"}))})}async injectQuickEdit({modal:e,wikiPage:i,options:n}){if(i.pageid===0||n.section==="new")return;let r;e.addButton({label:"Diff",side:"left",keyPress:await this.ctx.preferences.get("quickDiff.keyshortcut")||void 0,className:"btn btn-secondary",method:()=>{const s=i.title,o=i.revisions?.[0]?.content||"",a=e.get$content().querySelector('textarea[name="text"]')?.value||"";return o===a?this.ctx.modal.notify("info",{title:"Quick Diff",content:"No changes"}):(this.ctx.emit("quick-diff/quick-edit-modal",{ctx:this.ctx,modal:e,wikiPage:i}),r=this.comparePages({fromtitle:s,fromtext:o,totitle:s,totext:a,topst:!0},r,{backdrop:!1,draggable:!0}),r)}},2),e.on(e.Event.Close,()=>{r?.destroy(),r=void 0})}comparePages(e,i,n){return!i||i.isDestroyed?i=this.ctx.modal.createObject({title:"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(p("section",{style:{height:"70vh",display:"flex",justifyContent:"center",alignItems:"center"},children:p(jt,{})})),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(r=>{if(!r.data.compare)throw new Error("No compare data received",{cause:r});const{data:{compare:s}}=r;i.setTitle(s.fromtitle&&s.totitle?`${s.fromtitle}${s.fromrevid?` (${s.fromrevid})`:""} ⇔ ${s.totitle}${s.torevid?` (${s.torevid})`:""}`:"Differences");let o;i.setContent(p("section",{style:{minHeight:"70vh"},children:p(Zy,{ref:a=>o=a,data:s,ctx:this.ctx})})),o.addEventListener($r.update,a=>{a.stopPropagation(),this.comparePages({fromrev:a.detail.fromrev,torev:a.detail.torev},i,n)},{once:!0}),this.ctx.inject(["quickEdit"],a=>{const l=c=>{c.stopPropagation(),a.quickEdit({revision:c.detail.revid})};o.addEventListener($r.edit,l),i.on(i.Event.Close,()=>{o.removeEventListener($r.edit,l)})}),s.fromrevid&&s.torevid&&i.addButton({label:"Original Compare Page",side:"right",className:"btn btn-secondary",method:()=>{window.location.href=this.ctx.getUrl("",{oldid:s.fromrevid,diff:s.torevid})}}),this.ctx.emit("quick-diff/loaded",{ctx:this.ctx,modal:i,compare:s})}).catch(r=>{i.setContent(p(pn,{title:"Failed to load diff",type:"error",children:p("pre",{children:r instanceof Error?r.message:String(r)})}))}),i.show()}}Oo=ob(Nu),Pr=fb(Oo,0,"PluginQuickDiff",Lu,Pr),ub(Oo,1,Pr);const db=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickDiff(){return Pr}},Symbol.toStringTag,{value:"Module"})),Mo=class Mo extends Ve{constructor(e){super(e,{},"quick-redirect"),this.ctx=e}start(){this.ctx.set("quickRedirect",this.quickRedirect.bind(this)),this.ctx.set("redirectPage",this.redirectPage.bind(this));const e=window.mw?.config.get("wgPageName")||"",i=window.mw?.config.get("wgIsProbablyEditable");this.ctx.inject(["toolbox"],n=>{this.ctx=n,n.toolbox.addButton({id:"quick-redirect",icon:p("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:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("path",{d:"M4 21v-4a3 3 0 0 1 3 -3h5"}),p("path",{d:"M9 17l3 -3l-3 -3"}),p("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),p("path",{d:"M5 11v-6a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-9.5"})]}),tooltip:"Quick Redirect",group:"group1",index:2,onClick:()=>{this.quickRedirect(i?{to:e}:{})}}),this.addDisposeHandler(r=>{r.toolbox.removeButton("quick-redirect")})})}stop(){}quickRedirect(e){e||(e={}),this.ctx.emit("quick-redirect/init-options",{ctx:this.ctx,options:e});const i=this.ctx.modal.createObject({title:"Quick Redirect",content:p(jt,{}),className:"quick-redirect compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let n=null;return i.setContent(p("form",{ref:r=>n=r,style:{display:"flex",flexDirection:"column",gap:"1rem"},onSubmit:r=>{if(r.preventDefault(),n?.checkValidity(),!n?.reportValidity())return;const s=new FormData(n),o={from:s.get("from")?.toString().trim(),to:s.get("to")?.toString().trim(),reason:s.get("reason")||"",overwrite:s.get("overwrite")==="on"};if(!o.from||!o.to){this.ctx.modal.notify("error",{title:"Failed to redirect",content:"From and to are required."});return}this.ctx.emit("quick-redirect/submit",{ctx:this.ctx,payload:o}),i.setLoadingState(!0),this.redirectPage(o).then(a=>{i.close(),this.ctx.modal.notify("success",{title:"Redirect successful",content:"The redirect has been created."})}).catch(a=>{i.setLoadingState(!1),this.ctx.modal.notify("error",{title:"Failed to redirect",content:a instanceof Error?a.message:String(a)})})},children:[p(wu,{inputs:[{label:"From",name:"from",value:e?.from,required:!0},{label:"To",name:"to",value:e?.to,required:!0}]}),p(mn,{label:"Reason",id:"reason",name:"reason",value:e?.reason}),p("div",{children:p(Oi,{name:"overwrite",id:"overwrite",checked:e?.overwrite,children:"Force create redirect even if the from page already exists"})})]})),i.setButtons([{label:"Create Redirect",className:"is-primary is-ghost",method:()=>{n?.dispatchEvent(new Event("submit"))}}]),this.ctx.emit("quick-redirect/show-modal",{ctx:this.ctx,modal:i}),i.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})}};Mo.inject=["api","wikiPage","modal"];let Io=Mo;const hb=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickRedirect:Io},Symbol.toStringTag,{value:"Module"}));var pb=Object.create,Ao=Object.defineProperty,mb=Object.getOwnPropertyDescriptor,Mu=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Du=t=>{throw TypeError(t)},gb=(t,e,i)=>e in t?Ao(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,yb=(t,e)=>Ao(t,"name",{value:e,configurable:!0}),bb=t=>[,,,pb(t?.[Mu("metadata")]??null)],wb=["class","method","getter","setter","accessor","field","value","get","set"],ju=t=>t!==void 0&&typeof t!="function"?Du("Function expected"):t,vb=(t,e,i,n,r)=>({kind:wb[t],name:e,metadata:n,addInitializer:s=>i._?Du("Already initialized"):r.push(ju(s||null))}),_b=(t,e)=>gb(e,Mu("metadata"),t[3]),xb=(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},Sb=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(r=r.prototype,c<5&&(c>3||!u)&&mb(r,i));yb(r,i);for(var g=n.length-1;g>=0;g--)l=vb(c,i,a={},t[3],h),o=(0,n[g])(r,l),a._=1,ju(o)&&(r=o);return _b(t,r),m&&Ao(r,i,m),u?c^4?s:m:r},Uu,To,Fu;Uu=[pi(Y.object({toolboxAlwaysShow:Y.boolean().description("Make the toolbox opened by default").default(!1)}).description("Toolbox preferences")),xe(["preferences"])];class Cr extends(Fu=Pt){constructor(e){super(e,"toolbox",!1),this.ctx=e,this.container=void 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.updateButtonDelays()}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 p("div",{id:"ipe-edit-toolbox",children:[p("ul",{className:"btn-group group1",style:{display:"flex",flexDirection:"column"}}),p("ul",{className:"btn-group group2",style:{display:"flex",flexDirection:"row"}}),p("button",{className:"ipe-toolbox-btn",id:"toolbox-toggler",onClick:()=>{this.toggle()},children:p("svg",{xmlns:"http://www.w3.org/2000/svg",width:"448",height:"512",viewBox:"0 0 448 512",children:[p("rect",{width:"448",height:"512",fill:"none"}),p("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,"-")}addButton(e){let{id:i,group:n,icon:r,tooltip:s,itemProps:o,buttonProps:a,onClick:l,index:c}=e;i=this.normalizeButtonId(i);const u=this.container.querySelector(`#${i}`);u&&(this.ctx.logger("toolbox").warn(`Button with id ${i} already exists, replacing it.`),u.remove());let f=null;if(typeof n>"u"||n==="auto"){const m=this.container.querySelector(".btn-group.group1"),g=this.container.querySelector(".btn-group.group2"),k=m?.children.length||0,D=g?.children.length||0;f=k<=D?m:g}else f=this.container.querySelector(`.btn-group.${n}`);if(!f)throw new Error(`Button group ${n} not found`);const h=p("li",{class:"btn-tip-group",id:i,onClick:l,...o,children:[p("div",{class:"btn-tip",children:s}),p("button",{id:`${i}-btn`,"data-id":e.id,class:"ipe-toolbox-btn",...a,children:r})]});return h.addEventListener("click",m=>{this.ctx.emit("toolbox/button-clicked",{ctx:this.ctx,button:m.target,id:e.id})}),typeof c=="number"?c<=0?f.prepend(h):c>=f.children.length?f.appendChild(h):f.children[c]?.before(h):f.appendChild(h),this.ctx.emit("toolbox/button-added",{ctx:this.ctx,button:h}),this.updateButtonDelays(),h}removeButton(e){this.container.querySelector(`.ipe-toolbox-btn#${e}`)?.remove(),this.ctx.emit("toolbox/button-removed",{ctx:this.ctx,id:e}),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})}}To=bb(Fu),Cr=Sb(To,0,"PluginToolbox",Uu,Cr),xb(To,1,Cr);const kb=Object.freeze(Object.defineProperty({__proto__:null,get PluginToolbox(){return Cr}},Symbol.toStringTag,{value:"Module"}));var Eb=Object.create,Ro=Object.defineProperty,$b=Object.getOwnPropertyDescriptor,Bu=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),qu=t=>{throw TypeError(t)},Pb=(t,e,i)=>e in t?Ro(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Cb=(t,e)=>Ro(t,"name",{value:e,configurable:!0}),Ob=t=>[,,,Eb(t?.[Bu("metadata")]??null)],Ib=["class","method","getter","setter","accessor","field","value","get","set"],Hu=t=>t!==void 0&&typeof t!="function"?qu("Function expected"):t,Ab=(t,e,i,n,r)=>({kind:Ib[t],name:e,metadata:n,addInitializer:s=>i._?qu("Already initialized"):r.push(Hu(s||null))}),Tb=(t,e)=>Pb(e,Bu("metadata"),t[3]),Rb=(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},Lb=(t,e,i,n,r,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(r=r.prototype,c<5&&(c>3||!u)&&$b(r,i));Cb(r,i);for(var g=n.length-1;g>=0;g--)l=Ab(c,i,a={},t[3],h),o=(0,n[g])(r,l),a._=1,Hu(o)&&(r=o);return Tb(t,r),m&&Ro(r,i,m),u?c^4?s:m:r},zu,Lo,Wu;zu=[xe(["preferences","wikiPage","wikiTitle","modal","preferencesUI"])];class Or extends(Wu=Ve){constructor(e){super(e,{},"pref-sync"),this.ctx=e,e.set("prefSync",this)}start(){const e=this.ctx;e.preferences.defineCategory({name:"pref-sync",label:"Sync",description:"Import and export preferences",index:98}),e.preferences.registerCustomConfig("pref-sync-user-page",Y.object({"pref-sync-user-page":Y.const(p("section",{children:p("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[p("button",{className:"btn primary",onClick:i=>{i.preventDefault();const n=e.preferencesUI.getExistingModal(),r=i.target;r.disabled=!0,n?.setLoadingState(!0),this.importFromUserPage().then(s=>{this.notifyImportSuccess(s),n?.close?.()}).finally(()=>{r.disabled=!1,n?.setLoadingState(!1)})},children:"Import"}),p("button",{className:"btn primary",onClick:i=>{i.preventDefault();const n=i.target;n.disabled=!0;const r=e.preferencesUI.getExistingModal();r?.setLoadingState(!0),this.exportToUserPage().then(s=>{e.modal.notify("success",{title:"Preferences Exported",content:p("p",{children:["Your preferences have been exported to"," ",p("a",{href:s.getURL().toString(),target:"_blank",children:s.getPrefixedText()}),"."]})}),r?.close?.()}).finally(()=>{n.disabled=!1,r?.setLoadingState(!1)})},children:"Export"})]})})).role("raw-html")}).description("Backup your preferences via user page"),"pref-sync"),e.preferences.registerCustomConfig("pref-sync-manual",Y.object({"pref-sync-manual":Y.const(p("section",{children:p("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[p("button",{className:"btn",onClick:i=>{i.preventDefault();const n=e.preferencesUI.getExistingModal();n?.setLoadingState(!0);const r=document.createElement("input");r.type="file",r.accept="application/json",r.addEventListener("change",async s=>{try{const o=s.target.files?.[0];if(!o)return;const a=await this.importFromFile(o);this.notifyImportSuccess(a),n?.close?.()}catch(o){e.modal.notify("error",{title:"Import failed",content:o instanceof Error?o.message:String(o)})}finally{n?.setLoadingState(!1)}}),r.addEventListener("cancel",()=>{n?.setLoadingState(!1)}),r.click()},children:"Import from file"}),p("button",{className:"btn",onClick:async i=>{i.preventDefault();const n=await e.preferences.getExportableRecord(),r=JSON.stringify(n,null,2);e.modal.dialog({title:"Save to file",content:p("div",{children:[p("label",{htmlFor:"data",children:"Your InPageEdit preferences:"}),p("textarea",{name:"data",id:"data",rows:10,value:r,readOnly:!0,style:{width:"100%"}})]}),buttons:[{label:"Copy",method:()=>{navigator.clipboard.writeText(r),e.modal.notify("success",{content:"Copied to clipboard"})}},{label:"Download",method:()=>{const s=document.createElement("a");s.href=`data:text/json;charset=utf-8,${encodeURIComponent(r)}`,s.download=`ipe-prefs-${new Date().toISOString()}.json`,s.click()}}]},()=>{})},children:"Save to file"})]})})).role("raw-html")}).description("Backup your preferences to file"),"pref-sync")}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"});let n;try{if(n=await fetch(i.toString()),!n.ok){if(n.status===404)return this.logger.debug("User preferences page does not exist"),{};throw new Error(`HTTP ${n.status}: ${n.statusText}`)}}catch(o){if(o instanceof TypeError&&o.message.includes("Failed to fetch"))return this.logger.debug("User preferences page does not exist or network error"),{};throw o}const r=await n.blob(),s=await this.importFromFile(r);return this.logger.info("Loaded preferences from user page:",e),s}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");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:Je.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 importFromFile(e){const i=await e.text(),n=JSON.parse(i);return await this.ctx.preferences.setMany(n)}notifyImportSuccess(e){const i=Object.keys(e??{}),n=i.length;return this.ctx.modal.notify("success",{title:"Preferences Imported",content:p("section",{children:[p("p",{children:["Successfully imported ",n||""," ",n!==1?"settings":"setting",":"]}),p("ol",{style:{listStyle:"auto",paddingLeft:"1em"},children:i.map(r=>p("li",{children:r},r))})]})})}}Lo=Ob(Wu),Or=Lb(Lo,0,"PluginPrefSync",zu,Or),Rb(Lo,1,Or);const Nb=Object.freeze(Object.defineProperty({__proto__:null,get PluginPrefSync(){return Or}},Symbol.toStringTag,{value:"Module"}));X.BasePlugin=Ve,X.InPageEdit=hi,X.Inject=xe,X.Logger=Zo,X.LoggerLevel=zr,X.Schema=Y,X.Service=Pt,X.createLogger=ia,Object.defineProperty(X,Symbol.toStringTag,{value:"Module"})});
12
+ - Documentation: ${ti.HOME_URL}
13
+ - Bug Reports: ${ti.GITHUB_URL}`)}function rl(){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 up(t,e){const i=Symbol.for(t);return window[i]?!1:(window[i]=!0,e(),!0)}var fp=Object.create,As=Object.defineProperty,dp=Object.getOwnPropertyDescriptor,nl=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),sl=t=>{throw TypeError(t)},hp=(t,e,i)=>e in t?As(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,pp=(t,e)=>As(t,"name",{value:e,configurable:!0}),mp=t=>[,,,fp(t?.[nl("metadata")]??null)],gp=["class","method","getter","setter","accessor","field","value","get","set"],ol=t=>t!==void 0&&typeof t!="function"?sl("Function expected"):t,yp=(t,e,i,r,n)=>({kind:gp[t],name:e,metadata:r,addInitializer:s=>i._?sl("Already initialized"):n.push(ol(s||null))}),bp=(t,e)=>hp(e,nl("metadata"),t[3]),wp=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},vp=(t,e,i,r,n,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(n=n.prototype,c<5&&(c>3||!u)&&dp(n,i));pp(n,i);for(var d=r.length-1;d>=0;d--)l=yp(c,i,a={},t[3],h),o=(0,r[d])(n,l),a._=1,ol(o)&&(n=o);return bp(t,n),m&&As(n,i,m),u?c^4?s:m:n},al,Os,ll;al=[ve(["wiki","preferences"])];class Yr extends(ll=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(){this.ctx.preferences.registerCustomConfig("analytics",L.object({"analytics._intro":L.const(p("section",{children:[p("h3",{children:"InPageEdit Analytics"}),p("p",{children:"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."}),p("h4",{children:"What data will be collected?"}),p("ol",{style:{listStyle:"number",paddingLeft:"1em"},children:[p("li",{children:[p("strong",{children:"Usage data"}),": When and which features you use, what pages you edit, etc."]}),p("li",{children:[p("strong",{children:"User information"}),": Your user name and user ID."]}),p("li",{children:[p("strong",{children:"Site information"}),": This wiki's url and site name."]})]}),p("p",{children:p("strong",{children:"NO sensitive data will be collected."})}),p("div",{style:{display:"grid",gap:"0.5rem"},children:[p("a",{href:this.analyticsDashUrl,target:"_blank",rel:"noopener noreferrer",children:p("button",{className:"btn",style:{width:"100%"},children:"Analytics Platform"})}),p("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:p("button",{className:"btn",style:{width:"100%"},children:"View My Data"})})]})]})).role("raw-html"),"analytics.enabled":L.boolean().description("Share my usage data with the community.").default(!1)}).description("Analytics settings"),"general")}get analyticsDashUrl(){return ti.ANALYTICS_DASH_URL}get analyticsApiBase(){return ti.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(){this.ctx.inject(["modal","storage"],async e=>{const i="analytics/confirm-shown",r=await e.storage.simpleKV.get(i),n=await e.preferences.get("analytics.enabled");r||n||e.modal.notify("confirm",{title:"Enable Analytics",content:p("div",{children:[p("p",{children:"Help us improve InPageEdit by sharing your usage data with us."}),p("p",{children:"What data will be collected?"}),p("ul",{style:{listStyle:"auto",paddingLeft:"1.5em"},children:[p("li",{children:"Usage data: What features you use, what pages you edit, etc."}),p("li",{children:"User information: Your username, user ID."}),p("li",{children:"Site information: The wiki you are editing."})]}),p("p",{children:p("strong",{children:"NO sensitive data will be collected."})})]}),okBtn:{label:"Enable"},cancelBtn:{label:"Disable"},closeAfter:0,onClose:()=>{this.ctx.storage.simpleKV.set(i,1)}},s=>{e.preferences.set("analytics.enabled",s),s&&this.addEvent("analytics","enabled")})})}_initPluginListeners(){const e=this.ctx;e.on("in-article-links/anchor-clicked",i=>{this.addEvent("in-article-links",ap(i.action))}),e.on("quick-delete/submit",i=>{this.addEvent("quick-delete","submit",i.wikiPage.title)}),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",i=>{this.addEvent("quick-move","submit")}),e.on("toolbox/button-clicked",i=>{this.addEvent("toolbox",`button-clicked#${i.id||"unknown"}`)})}addEvent(e,i,r){const n={ts:Date.now(),feature:e,subtype:i,page:r};return this._usages.push(n),this._usages.length>=this.MAX_QUEUE_SIZE&&this.sendBeacon(),this}async sendBeacon(){if(this._usages.length===0)return!0;if(!await this.ctx.preferences.get("analytics.enabled",!1))return this.logger.debug("Analytics disabled, skipping"),!0;const i=this._usages.splice(0,this._usages.length),r={siteApi:this.ctx.wiki.getSciprtUrl("api"),siteName:this.ctx.wiki.siteInfo.general.sitename,userId:this.ctx.wiki.userInfo.id,userName:this.ctx.wiki.userInfo.name,version:this.ctx.version.split("-")[0],usages:i},n=JSON.stringify(r),s=`${this.analyticsApiBase}/submit`;if(navigator?.sendBeacon?.(s,n))return this.logger.debug("Beacon sent successfully",r),!0;{this.logger.debug("Beacon failed, sending via XMLHttpRequest");const{promise:a,resolve:l,reject:c}=re();try{const u=new XMLHttpRequest;u.open("POST",s,!0),u.setRequestHeader("Content-Type","application/json"),u.send(n),u.onload=()=>{this.logger.debug("Beacon sent successfully via XMLHttpRequest",r),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()}}Os=mp(ll),Yr=vp(Os,0,"PluginAnalytics",al,Yr),wp(Os,1,Yr);const _p=Object.freeze(Object.defineProperty({__proto__:null,get PluginAnalytics(){return Yr}},Symbol.toStringTag,{value:"Module"}));function ii(t){return function(e){return e.PreferencesSchema=t,e}}const cl=t=>p("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:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),p("path",{d:"M13.5 6.5l4 4"}),p("path",{d:"M19 16l-2 3h4l-2 3"})]});var xp=Object.create,Rs=Object.defineProperty,Sp=Object.getOwnPropertyDescriptor,ul=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),fl=t=>{throw TypeError(t)},kp=(t,e,i)=>e in t?Rs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ep=(t,e)=>Rs(t,"name",{value:e,configurable:!0}),$p=t=>[,,,xp(t?.[ul("metadata")]??null)],Pp=["class","method","getter","setter","accessor","field","value","get","set"],dl=t=>t!==void 0&&typeof t!="function"?fl("Function expected"):t,Cp=(t,e,i,r,n)=>({kind:Pp[t],name:e,metadata:r,addInitializer:s=>i._?fl("Already initialized"):n.push(dl(s||null))}),Ip=(t,e)=>kp(e,ul("metadata"),t[3]),Ap=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Op=(t,e,i,r,n,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(n=n.prototype,c<5&&(c>3||!u)&&Sp(n,i));Ep(n,i);for(var d=r.length-1;d>=0;d--)l=Cp(c,i,a={},t[3],h),o=(0,r[d])(n,l),a._=1,dl(o)&&(n=o);return Ip(t,n),m&&Rs(n,i,m),u?c^4?s:m:n},hl,Ts,pl;hl=[ve(["wiki","wikiTitle","preferences"]),ii(L.object({"inArticleLinks.enable":L.boolean().description("Whether to enable in-article links").default(!0),"inArticleLinks.quickDiff.enable":L.boolean().description("Whether to enable in-article links for quick diff").default(!0),"inArticleLinks.quickEdit.enable":L.boolean().description("Whether to enable in-article links for quick edit").default(!0),"inArticleLinks.quickEdit.redlinks":L.boolean().description("Whether to show quick edit button for redlinks").default(!0)}).description("In-article links preferences").extra("category","in-article-links"))];class Qr extends(pl=je){constructor(e){super(e,{linkClassName:"ipe__in-article-link"},"InArticleLinks"),this._cachedAnchorInfo=new WeakMap,this.ctx.set("inArticleLinks",this),this.ctx.preferences.defineCategory({label:"In Article Links",name:"in-article-links",description:"In-article links preferences",index:9})}async start(){await this.ctx.preferences.get("inArticleLinks.quickEdit.enable")&&this.handleQuickEdit(),await this.ctx.preferences.get("inArticleLinks.quickDiff.enable")&&this.handleQuickDiff()}async stop(){Array.from(document.getElementsByClassName(this.config.linkClassName)).forEach(e=>{e.remove()}),document.querySelectorAll("[data-ipe-edit-mounted]").forEach(e=>{e.dataset.ipeEditMounted=void 0})}parseAnchor(e){if(!(e instanceof HTMLAnchorElement))return null;const i=this._cachedAnchorInfo.get(e);if(i)return i;const r=e.getAttribute("href")||"";if(!this.ctx.wikiTitle.validateHrefAttr(r))return null;const n=e.href||"",s=this.ctx.wikiTitle.parseWikiLink(n);if(!s)return null;const o={$el:e,kind:e.closest('[typeof^="mw:File"]')?"mw:File":"normal",external:e.classList.contains("external")||!!r.startsWith("http"),redlink:e.classList.contains("new")||s.params.has("redlink"),...s};return this._cachedAnchorInfo.set(e,o),this.ctx.emit("in-article-links/anchor-parsed",{ctx:this.ctx,anchor:e,info:o}),o}scanAnchors(e,i){const r=e.querySelectorAll("a[href]");return Array.from(r).map(n=>this.parseAnchor(n)).filter(n=>n!==null&&(!i||i(n)))}async handleQuickEdit(){let e=!1;const i=await this.ctx.preferences.get("inArticleLinks.quickEdit.redlinks");this.ctx.inject(["quickEdit"],r=>{e=!0,r.on("dispose",()=>{e=!1}),window?.mw?.hook?.("wikipage.content").add(n=>{if(!e)return;this.scanAnchors(n.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 h=l?.getPrefixedDBKey()||"",m=u.get("section")?.replace(/^T-/,"")||void 0,d=u.get("oldid"),_=u.has("redlink");let k;m==="new"||l?.isSpecial("newsection")?k="new":m&&/^\d+$/.test(m)&&(k=parseInt(m,10));const E=d?parseInt(d,10):void 0,x={title:h,pageId:c||void 0,section:k,revision:E,createOnly:_},y=p("a",{href:"#ipe://quick-edit/",dataset:x,className:`${this.config.linkClassName} ipe-quick-edit ${_?"ipe-quick-edit--create-only":""}`,style:{userSelect:"none",marginLeft:"0.2em"},onClick:g=>{g.preventDefault(),this.ctx.emit("in-article-links/anchor-clicked",{ctx:this.ctx,anchor:a,info:o,event:g,action:"quickEdit"}),r.quickEdit.showModal(x)},children:p(cl,{className:"ipe-icon"})});a.insertAdjacentElement("afterend",y)})})})}handleQuickDiff(){let e=!1;const i=r=>["prev","next","cur"].includes(r);this.ctx.inject(["quickDiff"],r=>{e=!0,r.on("dispose",()=>{e=!1}),window?.mw?.hook?.("wikipage.content").add(n=>{if(!e)return;this.scanAnchors(n.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,f;if(l?.getNamespaceId()===-1?([,f,u]=l.getMainDBKey().split("/"),u||(u="prev")):(u=c.get("diff"),f=c.get("oldid")),!u||!f)return;const h={};i(u)?(h.fromrev=parseInt(f),h.torelative=u):(h.fromrev=parseInt(f),h.torev=parseInt(u));const m=p("a",{href:"#ipe://quick-diff/",dataset:h,className:`${this.config.linkClassName} ipe-quick-diff`,style:{userSelect:"none",marginLeft:"0.2em"},onClick:d=>{d.preventDefault(),this.ctx.emit("in-article-links/anchor-clicked",{ctx:this.ctx,anchor:a,info:o,event:d,action:"quickDiff"}),r.quickDiff.comparePages(h)},children:p("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-diff ipe-icon",children:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),p("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"}),p("path",{d:"M12 10l0 4"}),p("path",{d:"M10 12l4 0"}),p("path",{d:"M10 17l4 0"})]})});a.insertAdjacentElement("afterend",m)})})})}}Ts=$p(pl),Qr=Op(Ts,0,"PluginInArticleLinks",hl,Qr),Ap(Ts,1,Qr);const Rp=Object.freeze(Object.defineProperty({__proto__:null,get PluginInArticleLinks(){return Qr}},Symbol.toStringTag,{value:"Module"}));function Ls(t){const e=Object.create(null);for(const i of t.split(","))e[i]=1;return i=>i in e}const ie={},vi=[],pt=()=>{},ml=()=>!1,Xr=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&(t.charCodeAt(2)>122||t.charCodeAt(2)<97),Ns=t=>t.startsWith("onUpdate:"),ke=Object.assign,Ms=(t,e)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)},Tp=Object.prototype.hasOwnProperty,ne=(t,e)=>Tp.call(t,e),W=Array.isArray,_i=t=>Jr(t)==="[object Map]",gl=t=>Jr(t)==="[object Set]",V=t=>typeof t=="function",ge=t=>typeof t=="string",Ut=t=>typeof t=="symbol",ue=t=>t!==null&&typeof t=="object",yl=t=>(ue(t)||V(t))&&V(t.then)&&V(t.catch),bl=Object.prototype.toString,Jr=t=>bl.call(t),Lp=t=>Jr(t).slice(8,-1),wl=t=>Jr(t)==="[object Object]",Ds=t=>ge(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,Ji=Ls(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),Zr=t=>{const e=Object.create(null);return(i=>e[i]||(e[i]=t(i)))},Np=/-\w/g,At=Zr(t=>t.replace(Np,e=>e.slice(1).toUpperCase())),Mp=/\B([A-Z])/g,Ft=Zr(t=>t.replace(Mp,"-$1").toLowerCase()),vl=Zr(t=>t.charAt(0).toUpperCase()+t.slice(1)),js=Zr(t=>t?`on${vl(t)}`:""),Ue=(t,e)=>!Object.is(t,e),en=(t,...e)=>{for(let i=0;i<t.length;i++)t[i](...e)},_l=(t,e,i,r=!1)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:r,value:i})},Us=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let xl;const tn=()=>xl||(xl=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Fs(t){if(W(t)){const e={};for(let i=0;i<t.length;i++){const r=t[i],n=ge(r)?Fp(r):Fs(r);if(n)for(const s in n)e[s]=n[s]}return e}else if(ge(t)||ue(t))return t}const Dp=/;(?![^(]*\))/g,jp=/:([^]+)/,Up=/\/\*[^]*?\*\//g;function Fp(t){const e={};return t.replace(Up,"").split(Dp).forEach(i=>{if(i){const r=i.split(jp);r.length>1&&(e[r[0].trim()]=r[1].trim())}}),e}function ri(t){let e="";if(ge(t))e=t;else if(W(t))for(let i=0;i<t.length;i++){const r=ri(t[i]);r&&(e+=r+" ")}else if(ue(t))for(const i in t)t[i]&&(e+=i+" ");return e.trim()}const Bp=Ls("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly");function Sl(t){return!!t||t===""}const kl=t=>!!(t&&t.__v_isRef===!0),Je=t=>ge(t)?t:t==null?"":W(t)||ue(t)&&(t.toString===bl||!V(t.toString))?kl(t)?Je(t.value):JSON.stringify(t,El,2):String(t),El=(t,e)=>kl(e)?El(t,e.value):_i(e)?{[`Map(${e.size})`]:[...e.entries()].reduce((i,[r,n],s)=>(i[Bs(r,s)+" =>"]=n,i),{})}:gl(e)?{[`Set(${e.size})`]:[...e.values()].map(i=>Bs(i))}:Ut(e)?Bs(e):ue(e)&&!W(e)&&!wl(e)?String(e):e,Bs=(t,e="")=>{var i;return Ut(t)?`Symbol(${(i=t.description)!=null?i:e})`:t};let Fe;class qp{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.parent=Fe,!e&&Fe&&(this.index=(Fe.scopes||(Fe.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=Fe;try{return Fe=this,e()}finally{Fe=i}}}on(){++this._on===1&&(this.prevScope=Fe,Fe=this)}off(){this._on>0&&--this._on===0&&(Fe=this.prevScope,this.prevScope=void 0)}stop(e){if(this._active){this._active=!1;let i,r;for(i=0,r=this.effects.length;i<r;i++)this.effects[i].stop();for(this.effects.length=0,i=0,r=this.cleanups.length;i<r;i++)this.cleanups[i]();if(this.cleanups.length=0,this.scopes){for(i=0,r=this.scopes.length;i<r;i++)this.scopes[i].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){const n=this.parent.scopes.pop();n&&n!==this&&(this.parent.scopes[this.index]=n,n.index=this.index)}this.parent=void 0}}}function Hp(){return Fe}let oe;const qs=new WeakSet;class $l{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,Fe&&Fe.active&&Fe.effects.push(this)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,qs.has(this)&&(qs.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||Cl(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,Tl(this),Il(this);const e=oe,i=at;oe=this,at=!0;try{return this.fn()}finally{Al(this),oe=e,at=i,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)Ws(e);this.deps=this.depsTail=void 0,Tl(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?qs.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){Ks(this)&&this.run()}get dirty(){return Ks(this)}}let Pl=0,Zi,er;function Cl(t,e=!1){if(t.flags|=8,e){t.next=er,er=t;return}t.next=Zi,Zi=t}function Hs(){Pl++}function zs(){if(--Pl>0)return;if(er){let e=er;for(er=void 0;e;){const i=e.next;e.next=void 0,e.flags&=-9,e=i}}let t;for(;Zi;){let e=Zi;for(Zi=void 0;e;){const i=e.next;if(e.next=void 0,e.flags&=-9,e.flags&1)try{e.trigger()}catch(r){t||(t=r)}e=i}}if(t)throw t}function Il(t){for(let e=t.deps;e;e=e.nextDep)e.version=-1,e.prevActiveLink=e.dep.activeLink,e.dep.activeLink=e}function Al(t){let e,i=t.depsTail,r=i;for(;r;){const n=r.prevDep;r.version===-1?(r===i&&(i=n),Ws(r),zp(r)):e=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=n}t.deps=e,t.depsTail=i}function Ks(t){for(let e=t.deps;e;e=e.nextDep)if(e.dep.version!==e.version||e.dep.computed&&(Ol(e.dep.computed)||e.dep.version!==e.version))return!0;return!!t._dirty}function Ol(t){if(t.flags&4&&!(t.flags&16)||(t.flags&=-17,t.globalVersion===tr)||(t.globalVersion=tr,!t.isSSR&&t.flags&128&&(!t.deps&&!t._dirty||!Ks(t))))return;t.flags|=2;const e=t.dep,i=oe,r=at;oe=t,at=!0;try{Il(t);const n=t.fn(t._value);(e.version===0||Ue(n,t._value))&&(t.flags|=128,t._value=n,e.version++)}catch(n){throw e.version++,n}finally{oe=i,at=r,Al(t),t.flags&=-3}}function Ws(t,e=!1){const{dep:i,prevSub:r,nextSub:n}=t;if(r&&(r.nextSub=n,t.prevSub=void 0),n&&(n.prevSub=r,t.nextSub=void 0),i.subs===t&&(i.subs=r,!r&&i.computed)){i.computed.flags&=-5;for(let s=i.computed.deps;s;s=s.nextDep)Ws(s,!0)}!e&&!--i.sc&&i.map&&i.map.delete(i.key)}function zp(t){const{prevDep:e,nextDep:i}=t;e&&(e.nextDep=i,t.prevDep=void 0),i&&(i.prevDep=e,t.nextDep=void 0)}let at=!0;const Rl=[];function mt(){Rl.push(at),at=!1}function gt(){const t=Rl.pop();at=t===void 0?!0:t}function Tl(t){const{cleanup:e}=t;if(t.cleanup=void 0,e){const i=oe;oe=void 0;try{e()}finally{oe=i}}}let tr=0;class Kp{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 rn{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(!oe||!at||oe===this.computed)return;let i=this.activeLink;if(i===void 0||i.sub!==oe)i=this.activeLink=new Kp(oe,this),oe.deps?(i.prevDep=oe.depsTail,oe.depsTail.nextDep=i,oe.depsTail=i):oe.deps=oe.depsTail=i,Ll(i);else if(i.version===-1&&(i.version=this.version,i.nextDep)){const r=i.nextDep;r.prevDep=i.prevDep,i.prevDep&&(i.prevDep.nextDep=r),i.prevDep=oe.depsTail,i.nextDep=void 0,oe.depsTail.nextDep=i,oe.depsTail=i,oe.deps===i&&(oe.deps=r)}return i}trigger(e){this.version++,tr++,this.notify(e)}notify(e){Hs();try{for(let i=this.subs;i;i=i.prevSub)i.sub.notify()&&i.sub.dep.notify()}finally{zs()}}}function Ll(t){if(t.dep.sc++,t.sub.flags&4){const e=t.dep.computed;if(e&&!t.dep.subs){e.flags|=20;for(let r=e.deps;r;r=r.nextDep)Ll(r)}const i=t.dep.subs;i!==t&&(t.prevSub=i,i&&(i.nextSub=t)),t.dep.subs=t}}const Vs=new WeakMap,ni=Symbol(""),Gs=Symbol(""),ir=Symbol("");function Ce(t,e,i){if(at&&oe){let r=Vs.get(t);r||Vs.set(t,r=new Map);let n=r.get(i);n||(r.set(i,n=new rn),n.map=r,n.key=i),n.track()}}function Ot(t,e,i,r,n,s){const o=Vs.get(t);if(!o){tr++;return}const a=l=>{l&&l.trigger()};if(Hs(),e==="clear")o.forEach(a);else{const l=W(t),c=l&&Ds(i);if(l&&i==="length"){const u=Number(r);o.forEach((f,h)=>{(h==="length"||h===ir||!Ut(h)&&h>=u)&&a(f)})}else switch((i!==void 0||o.has(void 0))&&a(o.get(i)),c&&a(o.get(ir)),e){case"add":l?c&&a(o.get("length")):(a(o.get(ni)),_i(t)&&a(o.get(Gs)));break;case"delete":l||(a(o.get(ni)),_i(t)&&a(o.get(Gs)));break;case"set":_i(t)&&a(o.get(ni));break}}zs()}function xi(t){const e=te(t);return e===t?e:(Ce(e,"iterate",ir),Ze(t)?e:e.map(Ee))}function nn(t){return Ce(t=te(t),"iterate",ir),t}const Wp={__proto__:null,[Symbol.iterator](){return Ys(this,Symbol.iterator,Ee)},concat(...t){return xi(this).concat(...t.map(e=>W(e)?xi(e):e))},entries(){return Ys(this,"entries",t=>(t[1]=Ee(t[1]),t))},every(t,e){return Rt(this,"every",t,e,void 0,arguments)},filter(t,e){return Rt(this,"filter",t,e,i=>i.map(Ee),arguments)},find(t,e){return Rt(this,"find",t,e,Ee,arguments)},findIndex(t,e){return Rt(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return Rt(this,"findLast",t,e,Ee,arguments)},findLastIndex(t,e){return Rt(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return Rt(this,"forEach",t,e,void 0,arguments)},includes(...t){return Qs(this,"includes",t)},indexOf(...t){return Qs(this,"indexOf",t)},join(t){return xi(this).join(t)},lastIndexOf(...t){return Qs(this,"lastIndexOf",t)},map(t,e){return Rt(this,"map",t,e,void 0,arguments)},pop(){return rr(this,"pop")},push(...t){return rr(this,"push",t)},reduce(t,...e){return Nl(this,"reduce",t,e)},reduceRight(t,...e){return Nl(this,"reduceRight",t,e)},shift(){return rr(this,"shift")},some(t,e){return Rt(this,"some",t,e,void 0,arguments)},splice(...t){return rr(this,"splice",t)},toReversed(){return xi(this).toReversed()},toSorted(t){return xi(this).toSorted(t)},toSpliced(...t){return xi(this).toSpliced(...t)},unshift(...t){return rr(this,"unshift",t)},values(){return Ys(this,"values",Ee)}};function Ys(t,e,i){const r=nn(t),n=r[e]();return r!==t&&!Ze(t)&&(n._next=n.next,n.next=()=>{const s=n._next();return s.done||(s.value=i(s.value)),s}),n}const Vp=Array.prototype;function Rt(t,e,i,r,n,s){const o=nn(t),a=o!==t&&!Ze(t),l=o[e];if(l!==Vp[e]){const f=l.apply(t,s);return a?Ee(f):f}let c=i;o!==t&&(a?c=function(f,h){return i.call(this,Ee(f),h,t)}:i.length>2&&(c=function(f,h){return i.call(this,f,h,t)}));const u=l.call(o,c,r);return a&&n?n(u):u}function Nl(t,e,i,r){const n=nn(t);let s=i;return n!==t&&(Ze(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,Ee(a),l,t)}),n[e](s,...r)}function Qs(t,e,i){const r=te(t);Ce(r,"iterate",ir);const n=r[e](...i);return(n===-1||n===!1)&&eo(i[0])?(i[0]=te(i[0]),r[e](...i)):n}function rr(t,e,i=[]){mt(),Hs();const r=te(t)[e].apply(t,i);return zs(),gt(),r}const Gp=Ls("__proto__,__v_isRef,__isVue"),Ml=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(Ut));function Yp(t){Ut(t)||(t=String(t));const e=te(this);return Ce(e,"has",t),e.hasOwnProperty(t)}class Dl{constructor(e=!1,i=!1){this._isReadonly=e,this._isShallow=i}get(e,i,r){if(i==="__v_skip")return e.__v_skip;const n=this._isReadonly,s=this._isShallow;if(i==="__v_isReactive")return!n;if(i==="__v_isReadonly")return n;if(i==="__v_isShallow")return s;if(i==="__v_raw")return r===(n?s?Hl:ql:s?Bl:Fl).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(r)?e:void 0;const o=W(e);if(!n){let l;if(o&&(l=Wp[i]))return l;if(i==="hasOwnProperty")return Yp}const a=Reflect.get(e,i,Se(e)?e:r);if((Ut(i)?Ml.has(i):Gp(i))||(n||Ce(e,"get",i),s))return a;if(Se(a)){const l=o&&Ds(i)?a:a.value;return n&&ue(l)?Zs(l):l}return ue(a)?n?Zs(a):Js(a):a}}class jl extends Dl{constructor(e=!1){super(!1,e)}set(e,i,r,n){let s=e[i];if(!this._isShallow){const l=Bt(s);if(!Ze(r)&&!Bt(r)&&(s=te(s),r=te(r)),!W(e)&&Se(s)&&!Se(r))return l||(s.value=r),!0}const o=W(e)&&Ds(i)?Number(i)<e.length:ne(e,i),a=Reflect.set(e,i,r,Se(e)?e:n);return e===te(n)&&(o?Ue(r,s)&&Ot(e,"set",i,r):Ot(e,"add",i,r)),a}deleteProperty(e,i){const r=ne(e,i);e[i];const n=Reflect.deleteProperty(e,i);return n&&r&&Ot(e,"delete",i,void 0),n}has(e,i){const r=Reflect.has(e,i);return(!Ut(i)||!Ml.has(i))&&Ce(e,"has",i),r}ownKeys(e){return Ce(e,"iterate",W(e)?"length":ni),Reflect.ownKeys(e)}}class Ul extends Dl{constructor(e=!1){super(!0,e)}set(e,i){return!0}deleteProperty(e,i){return!0}}const Qp=new jl,Xp=new Ul,Jp=new jl(!0),Zp=new Ul(!0),Xs=t=>t,sn=t=>Reflect.getPrototypeOf(t);function em(t,e,i){return function(...r){const n=this.__v_raw,s=te(n),o=_i(s),a=t==="entries"||t===Symbol.iterator&&o,l=t==="keys"&&o,c=n[t](...r),u=i?Xs:e?cn:Ee;return!e&&Ce(s,"iterate",l?Gs:ni),{next(){const{value:f,done:h}=c.next();return h?{value:f,done:h}:{value:a?[u(f[0]),u(f[1])]:u(f),done:h}},[Symbol.iterator](){return this}}}}function on(t){return function(...e){return t==="delete"?!1:t==="clear"?void 0:this}}function tm(t,e){const i={get(n){const s=this.__v_raw,o=te(s),a=te(n);t||(Ue(n,a)&&Ce(o,"get",n),Ce(o,"get",a));const{has:l}=sn(o),c=e?Xs:t?cn:Ee;if(l.call(o,n))return c(s.get(n));if(l.call(o,a))return c(s.get(a));s!==o&&s.get(n)},get size(){const n=this.__v_raw;return!t&&Ce(te(n),"iterate",ni),n.size},has(n){const s=this.__v_raw,o=te(s),a=te(n);return t||(Ue(n,a)&&Ce(o,"has",n),Ce(o,"has",a)),n===a?s.has(n):s.has(n)||s.has(a)},forEach(n,s){const o=this,a=o.__v_raw,l=te(a),c=e?Xs:t?cn:Ee;return!t&&Ce(l,"iterate",ni),a.forEach((u,f)=>n.call(s,c(u),c(f),o))}};return ke(i,t?{add:on("add"),set:on("set"),delete:on("delete"),clear:on("clear")}:{add(n){!e&&!Ze(n)&&!Bt(n)&&(n=te(n));const s=te(this);return sn(s).has.call(s,n)||(s.add(n),Ot(s,"add",n,n)),this},set(n,s){!e&&!Ze(s)&&!Bt(s)&&(s=te(s));const o=te(this),{has:a,get:l}=sn(o);let c=a.call(o,n);c||(n=te(n),c=a.call(o,n));const u=l.call(o,n);return o.set(n,s),c?Ue(s,u)&&Ot(o,"set",n,s):Ot(o,"add",n,s),this},delete(n){const s=te(this),{has:o,get:a}=sn(s);let l=o.call(s,n);l||(n=te(n),l=o.call(s,n)),a&&a.call(s,n);const c=s.delete(n);return l&&Ot(s,"delete",n,void 0),c},clear(){const n=te(this),s=n.size!==0,o=n.clear();return s&&Ot(n,"clear",void 0,void 0),o}}),["keys","values","entries",Symbol.iterator].forEach(n=>{i[n]=em(n,t,e)}),i}function an(t,e){const i=tm(t,e);return(r,n,s)=>n==="__v_isReactive"?!t:n==="__v_isReadonly"?t:n==="__v_raw"?r:Reflect.get(ne(i,n)&&n in r?i:r,n,s)}const im={get:an(!1,!1)},rm={get:an(!1,!0)},nm={get:an(!0,!1)},sm={get:an(!0,!0)},Fl=new WeakMap,Bl=new WeakMap,ql=new WeakMap,Hl=new WeakMap;function om(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function am(t){return t.__v_skip||!Object.isExtensible(t)?0:om(Lp(t))}function Js(t){return Bt(t)?t:ln(t,!1,Qp,im,Fl)}function lm(t){return ln(t,!1,Jp,rm,Bl)}function Zs(t){return ln(t,!0,Xp,nm,ql)}function tv(t){return ln(t,!0,Zp,sm,Hl)}function ln(t,e,i,r,n){if(!ue(t)||t.__v_raw&&!(e&&t.__v_isReactive))return t;const s=am(t);if(s===0)return t;const o=n.get(t);if(o)return o;const a=new Proxy(t,s===2?r:i);return n.set(t,a),a}function Si(t){return Bt(t)?Si(t.__v_raw):!!(t&&t.__v_isReactive)}function Bt(t){return!!(t&&t.__v_isReadonly)}function Ze(t){return!!(t&&t.__v_isShallow)}function eo(t){return t?!!t.__v_raw:!1}function te(t){const e=t&&t.__v_raw;return e?te(e):t}function cm(t){return!ne(t,"__v_skip")&&Object.isExtensible(t)&&_l(t,"__v_skip",!0),t}const Ee=t=>ue(t)?Js(t):t,cn=t=>ue(t)?Zs(t):t;function Se(t){return t?t.__v_isRef===!0:!1}function lt(t){return Kl(t,!1)}function zl(t){return Kl(t,!0)}function Kl(t,e){return Se(t)?t:new um(t,e)}class um{constructor(e,i){this.dep=new rn,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=i?e:te(e),this._value=i?e:Ee(e),this.__v_isShallow=i}get value(){return this.dep.track(),this._value}set value(e){const i=this._rawValue,r=this.__v_isShallow||Ze(e)||Bt(e);e=r?e:te(e),Ue(e,i)&&(this._rawValue=e,this._value=r?e:Ee(e),this.dep.trigger())}}function to(t){return Se(t)?t.value:t}const fm={get:(t,e,i)=>e==="__v_raw"?t:to(Reflect.get(t,e,i)),set:(t,e,i,r)=>{const n=t[e];return Se(n)&&!Se(i)?(n.value=i,!0):Reflect.set(t,e,i,r)}};function Wl(t){return Si(t)?t:new Proxy(t,fm)}class dm{constructor(e){this.__v_isRef=!0,this._value=void 0;const i=this.dep=new rn,{get:r,set:n}=e(i.track.bind(i),i.trigger.bind(i));this._get=r,this._set=n}get value(){return this._value=this._get()}set value(e){this._set(e)}}function hm(t){return new dm(t)}class pm{constructor(e,i,r){this.fn=e,this.setter=i,this._value=void 0,this.dep=new rn(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=tr-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!i,this.isSSR=r}notify(){if(this.flags|=16,!(this.flags&8)&&oe!==this)return Cl(this,!0),!0}get value(){const e=this.dep.track();return Ol(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}}function mm(t,e,i=!1){let r,n;return V(t)?r=t:(r=t.get,n=t.set),new pm(r,n,i)}const un={},fn=new WeakMap;let si;function gm(t,e=!1,i=si){if(i){let r=fn.get(i);r||fn.set(i,r=[]),r.push(t)}}function ym(t,e,i=ie){const{immediate:r,deep:n,once:s,scheduler:o,augmentJob:a,call:l}=i,c=g=>n?g:Ze(g)||n===!1||n===0?Tt(g,1):Tt(g);let u,f,h,m,d=!1,_=!1;if(Se(t)?(f=()=>t.value,d=Ze(t)):Si(t)?(f=()=>c(t),d=!0):W(t)?(_=!0,d=t.some(g=>Si(g)||Ze(g)),f=()=>t.map(g=>{if(Se(g))return g.value;if(Si(g))return c(g);if(V(g))return l?l(g,2):g()})):V(t)?e?f=l?()=>l(t,2):t:f=()=>{if(h){mt();try{h()}finally{gt()}}const g=si;si=u;try{return l?l(t,3,[m]):t(m)}finally{si=g}}:f=pt,e&&n){const g=f,w=n===!0?1/0:n;f=()=>Tt(g(),w)}const k=Hp(),E=()=>{u.stop(),k&&k.active&&Ms(k.effects,u)};if(s&&e){const g=e;e=(...w)=>{g(...w),E()}}let x=_?new Array(t.length).fill(un):un;const y=g=>{if(!(!(u.flags&1)||!u.dirty&&!g))if(e){const w=u.run();if(n||d||(_?w.some((S,C)=>Ue(S,x[C])):Ue(w,x))){h&&h();const S=si;si=u;try{const C=[w,x===un?void 0:_&&x[0]===un?[]:x,m];x=w,l?l(e,3,C):e(...C)}finally{si=S}}}else u.run()};return a&&a(y),u=new $l(f),u.scheduler=o?()=>o(y,!1):y,m=g=>gm(g,!1,u),h=u.onStop=()=>{const g=fn.get(u);if(g){if(l)l(g,4);else for(const w of g)w();fn.delete(u)}},e?r?y(!0):x=u.run():o?o(y.bind(null,!0),!0):u.run(),E.pause=u.pause.bind(u),E.resume=u.resume.bind(u),E.stop=E,E}function Tt(t,e=1/0,i){if(e<=0||!ue(t)||t.__v_skip||(i=i||new Map,(i.get(t)||0)>=e))return t;if(i.set(t,e),e--,Se(t))Tt(t.value,e,i);else if(W(t))for(let r=0;r<t.length;r++)Tt(t[r],e,i);else if(gl(t)||_i(t))t.forEach(r=>{Tt(r,e,i)});else if(wl(t)){for(const r in t)Tt(t[r],e,i);for(const r of Object.getOwnPropertySymbols(t))Object.prototype.propertyIsEnumerable.call(t,r)&&Tt(t[r],e,i)}return t}const nr=[];let io=!1;function iv(t,...e){if(io)return;io=!0,mt();const i=nr.length?nr[nr.length-1].component:null,r=i&&i.appContext.config.warnHandler,n=bm();if(r)ki(r,i,11,[t+e.map(s=>{var o,a;return(a=(o=s.toString)==null?void 0:o.call(s))!=null?a:JSON.stringify(s)}).join(""),i&&i.proxy,n.map(({vnode:s})=>`at <${Hc(i,s.type)}>`).join(`
14
+ `),n]);else{const s=[`[Vue warn]: ${t}`,...e];n.length&&s.push(`
15
+ `,...wm(n))}gt(),io=!1}function bm(){let t=nr[nr.length-1];if(!t)return[];const e=[];for(;t;){const i=e[0];i&&i.vnode===t?i.recurseCount++:e.push({vnode:t,recurseCount:0});const r=t.component&&t.component.parent;t=r&&r.vnode}return e}function wm(t){const e=[];return t.forEach((i,r)=>{e.push(...r===0?[]:[`
16
+ `],...vm(i))}),e}function vm({vnode:t,recurseCount:e}){const i=e>0?`... (${e} recursive calls)`:"",r=t.component?t.component.parent==null:!1,n=` at <${Hc(t.component,t.type,r)}`,s=">"+i;return t.props?[n,..._m(t.props),s]:[n+s]}function _m(t){const e=[],i=Object.keys(t);return i.slice(0,3).forEach(r=>{e.push(...Vl(r,t[r]))}),i.length>3&&e.push(" ..."),e}function Vl(t,e,i){return ge(e)?(e=JSON.stringify(e),i?e:[`${t}=${e}`]):typeof e=="number"||typeof e=="boolean"||e==null?i?e:[`${t}=${e}`]:Se(e)?(e=Vl(t,te(e.value),!0),i?e:[`${t}=Ref<`,e,">"]):V(e)?[`${t}=fn${e.name?`<${e.name}>`:""}`]:(e=te(e),i?e:[`${t}=`,e])}function ki(t,e,i,r){try{return r?t(...r):t()}catch(n){sr(n,e,i)}}function yt(t,e,i,r){if(V(t)){const n=ki(t,e,i,r);return n&&yl(n)&&n.catch(s=>{sr(s,e,i)}),n}if(W(t)){const n=[];for(let s=0;s<t.length;s++)n.push(yt(t[s],e,i,r));return n}}function sr(t,e,i,r=!0){const n=e?e.vnode:null,{errorHandler:s,throwUnhandledErrorInProduction:o}=e&&e.appContext.config||ie;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 f=0;f<u.length;f++)if(u[f](t,l,c)===!1)return}a=a.parent}if(s){mt(),ki(s,null,10,[t,l,c]),gt();return}}xm(t,i,n,r,o)}function xm(t,e,i,r=!0,n=!1){if(n)throw t}const Oe=[];let bt=-1;const Ei=[];let qt=null,$i=0;const Gl=Promise.resolve();let dn=null;function or(t){const e=dn||Gl;return t?e.then(this?t.bind(this):t):e}function Sm(t){let e=bt+1,i=Oe.length;for(;e<i;){const r=e+i>>>1,n=Oe[r],s=ar(n);s<t||s===t&&n.flags&2?e=r+1:i=r}return e}function ro(t){if(!(t.flags&1)){const e=ar(t),i=Oe[Oe.length-1];!i||!(t.flags&2)&&e>=ar(i)?Oe.push(t):Oe.splice(Sm(e),0,t),t.flags|=1,Yl()}}function Yl(){dn||(dn=Gl.then(Jl))}function km(t){W(t)?Ei.push(...t):qt&&t.id===-1?qt.splice($i+1,0,t):t.flags&1||(Ei.push(t),t.flags|=1),Yl()}function Ql(t,e,i=bt+1){for(;i<Oe.length;i++){const r=Oe[i];if(r&&r.flags&2){if(t&&r.id!==t.uid)continue;Oe.splice(i,1),i--,r.flags&4&&(r.flags&=-2),r(),r.flags&4||(r.flags&=-2)}}}function Xl(t){if(Ei.length){const e=[...new Set(Ei)].sort((i,r)=>ar(i)-ar(r));if(Ei.length=0,qt){qt.push(...e);return}for(qt=e,$i=0;$i<qt.length;$i++){const i=qt[$i];i.flags&4&&(i.flags&=-2),i.flags&8||i(),i.flags&=-2}qt=null,$i=0}}const ar=t=>t.id==null?t.flags&2?-1:1/0:t.id;function Jl(t){try{for(bt=0;bt<Oe.length;bt++){const e=Oe[bt];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),ki(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;bt<Oe.length;bt++){const e=Oe[bt];e&&(e.flags&=-2)}bt=-1,Oe.length=0,Xl(),dn=null,(Oe.length||Ei.length)&&Jl()}}let et=null,Zl=null;function hn(t){const e=et;return et=t,Zl=t&&t.type.__scopeId||null,e}function Em(t,e=et,i){if(!e||t._n)return t;const r=(...n)=>{r._d&&Tc(-1);const s=hn(e);let o;try{o=t(...n)}finally{hn(s),r._d&&Tc(1)}return o};return r._n=!0,r._c=!0,r._d=!0,r}function $m(t,e){if(et===null)return t;const i=kn(et),r=t.dirs||(t.dirs=[]);for(let n=0;n<e.length;n++){let[s,o,a,l=ie]=e[n];s&&(V(s)&&(s={mounted:s,updated:s}),s.deep&&Tt(o),r.push({dir:s,instance:i,value:o,oldValue:void 0,arg:a,modifiers:l}))}return t}function oi(t,e,i,r){const n=t.dirs,s=e&&e.dirs;for(let o=0;o<n.length;o++){const a=n[o];s&&(a.oldValue=s[o].value);let l=a.dir[r];l&&(mt(),yt(l,i,8,[t.el,a,t,e]),gt())}}const Pm=Symbol("_vte"),Cm=t=>t.__isTeleport,Im=Symbol("_leaveCb");function no(t,e){t.shapeFlag&6&&t.component?(t.transition=e,no(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 pn(t,e){return V(t)?ke({name:t.name},e,{setup:t}):t}function so(t){t.ids=[t.ids[0]+t.ids[2]+++"-",0,0]}function ec(t){const e=_o(),i=zl(null);if(e){const n=e.refs===ie?e.refs={}:e.refs;Object.defineProperty(n,t,{enumerable:!0,get:()=>i.value,set:s=>i.value=s})}return i}const mn=new WeakMap;function lr(t,e,i,r,n=!1){if(W(t)){t.forEach((d,_)=>lr(d,e&&(W(e)?e[_]:e),i,r,n));return}if(cr(r)&&!n){r.shapeFlag&512&&r.type.__asyncResolved&&r.component.subTree.component&&lr(t,e,i,r.component.subTree);return}const s=r.shapeFlag&4?kn(r.component):r.el,o=n?null:s,{i:a,r:l}=t,c=e&&e.r,u=a.refs===ie?a.refs={}:a.refs,f=a.setupState,h=te(f),m=f===ie?ml:d=>ne(h,d);if(c!=null&&c!==l){if(tc(e),ge(c))u[c]=null,m(c)&&(f[c]=null);else if(Se(c)){c.value=null;const d=e;d.k&&(u[d.k]=null)}}if(V(l))ki(l,a,12,[o,u]);else{const d=ge(l),_=Se(l);if(d||_){const k=()=>{if(t.f){const E=d?m(l)?f[l]:u[l]:l.value;if(n)W(E)&&Ms(E,s);else if(W(E))E.includes(s)||E.push(s);else if(d)u[l]=[s],m(l)&&(f[l]=u[l]);else{const x=[s];l.value=x,t.k&&(u[t.k]=x)}}else d?(u[l]=o,m(l)&&(f[l]=o)):_&&(l.value=o,t.k&&(u[t.k]=o))};if(o){const E=()=>{k(),mn.delete(t)};E.id=-1,mn.set(t,E),We(E,i)}else tc(t),k()}}}function tc(t){const e=mn.get(t);e&&(e.flags|=8,mn.delete(t))}const ic=t=>t.nodeType===8;tn().requestIdleCallback,tn().cancelIdleCallback;function Am(t,e){if(ic(t)&&t.data==="["){let i=1,r=t.nextSibling;for(;r;){if(r.nodeType===1){if(e(r)===!1)break}else if(ic(r))if(r.data==="]"){if(--i===0)break}else r.data==="["&&i++;r=r.nextSibling}}else e(t)}const cr=t=>!!t.type.__asyncLoader;function Om(t){V(t)&&(t={loader:t});const{loader:e,loadingComponent:i,errorComponent:r,delay:n=200,hydrate:s,timeout:o,suspensible:a=!0,onError:l}=t;let c=null,u,f=0;const h=()=>(f++,c=null,m()),m=()=>{let d;return c||(d=c=e().catch(_=>{if(_=_ instanceof Error?_:new Error(String(_)),l)return new Promise((k,E)=>{l(_,()=>k(h()),()=>E(_),f+1)});throw _}).then(_=>d!==c&&c?c:(_&&(_.__esModule||_[Symbol.toStringTag]==="Module")&&(_=_.default),u=_,_)))};return pn({name:"AsyncComponentWrapper",__asyncLoader:m,__asyncHydrate(d,_,k){let E=!1;(_.bu||(_.bu=[])).push(()=>E=!0);const x=()=>{E||k()},y=s?()=>{const g=s(x,w=>Am(d,w));g&&(_.bum||(_.bum=[])).push(g)}:x;u?y():m().then(()=>!_.isUnmounted&&y())},get __asyncResolved(){return u},setup(){const d=Ie;if(so(d),u)return()=>gn(u,d);const _=y=>{c=null,sr(y,d,13,!r)};if(a&&d.suspense||Oi)return m().then(y=>()=>gn(y,d)).catch(y=>(_(y),()=>r?tt(r,{error:y}):null));const k=lt(!1),E=lt(),x=lt(!!n);return n&&setTimeout(()=>{x.value=!1},n),o!=null&&setTimeout(()=>{if(!k.value&&!E.value){const y=new Error(`Async component timed out after ${o}ms.`);_(y),E.value=y}},o),m().then(()=>{k.value=!0,d.parent&&oo(d.parent.vnode)&&d.parent.update()}).catch(y=>{_(y),E.value=y}),()=>{if(k.value&&u)return gn(u,d);if(E.value&&r)return tt(r,{error:E.value});if(i&&!x.value)return gn(i,d)}}})}function gn(t,e){const{ref:i,props:r,children:n,ce:s}=e.vnode,o=tt(t,r,n);return o.ref=i,o.ce=s,delete e.vnode.ce,o}const oo=t=>t.type.__isKeepAlive;function Rm(t,e){rc(t,"a",e)}function Tm(t,e){rc(t,"da",e)}function rc(t,e,i=Ie){const r=t.__wdc||(t.__wdc=()=>{let n=i;for(;n;){if(n.isDeactivated)return;n=n.parent}return t()});if(yn(e,r,i),i){let n=i.parent;for(;n&&n.parent;)oo(n.parent.vnode)&&Lm(r,e,i,n),n=n.parent}}function Lm(t,e,i,r){const n=yn(e,t,r,!0);lo(()=>{Ms(r[e],n)},i)}function yn(t,e,i=Ie,r=!1){if(i){const n=i[t]||(i[t]=[]),s=e.__weh||(e.__weh=(...o)=>{mt();const a=gr(i),l=yt(e,i,t,o);return a(),gt(),l});return r?n.unshift(s):n.push(s),s}}const Lt=t=>(e,i=Ie)=>{(!Oi||t==="sp")&&yn(t,(...r)=>e(...r),i)},nc=Lt("bm"),Pi=Lt("m"),Nm=Lt("bu"),Mm=Lt("u"),ao=Lt("bum"),lo=Lt("um"),Dm=Lt("sp"),jm=Lt("rtg"),Um=Lt("rtc");function Fm(t,e=Ie){yn("ec",t,e)}const Bm=Symbol.for("v-ndc");function sc(t,e,i,r){let n;const s=i,o=W(t);if(o||ge(t)){const a=o&&Si(t);let l=!1,c=!1;a&&(l=!Ze(t),c=Bt(t),t=nn(t)),n=new Array(t.length);for(let u=0,f=t.length;u<f;u++)n[u]=e(l?c?cn(Ee(t[u])):Ee(t[u]):t[u],u,void 0,s)}else if(typeof t=="number"){n=new Array(t);for(let a=0;a<t;a++)n[a]=e(a+1,a,void 0,s)}else if(ue(t))if(t[Symbol.iterator])n=Array.from(t,(a,l)=>e(a,l,void 0,s));else{const a=Object.keys(t);n=new Array(a.length);for(let l=0,c=a.length;l<c;l++){const u=a[l];n[l]=e(t[u],u,l,s)}}else n=[];return n}const co=t=>t?Fc(t)?kn(t):co(t.parent):null,ur=ke(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=>co(t.parent),$root:t=>co(t.root),$host:t=>t.ce,$emit:t=>t.emit,$options:t=>cc(t),$forceUpdate:t=>t.f||(t.f=()=>{ro(t.update)}),$nextTick:t=>t.n||(t.n=or.bind(t.proxy)),$watch:t=>cg.bind(t)}),uo=(t,e)=>t!==ie&&!t.__isScriptSetup&&ne(t,e),qm={get({_:t},e){if(e==="__v_skip")return!0;const{ctx:i,setupState:r,data:n,props:s,accessCache:o,type:a,appContext:l}=t;let c;if(e[0]!=="$"){const m=o[e];if(m!==void 0)switch(m){case 1:return r[e];case 2:return n[e];case 4:return i[e];case 3:return s[e]}else{if(uo(r,e))return o[e]=1,r[e];if(n!==ie&&ne(n,e))return o[e]=2,n[e];if((c=t.propsOptions[0])&&ne(c,e))return o[e]=3,s[e];if(i!==ie&&ne(i,e))return o[e]=4,i[e];fo&&(o[e]=0)}}const u=ur[e];let f,h;if(u)return e==="$attrs"&&Ce(t.attrs,"get",""),u(t);if((f=a.__cssModules)&&(f=f[e]))return f;if(i!==ie&&ne(i,e))return o[e]=4,i[e];if(h=l.config.globalProperties,ne(h,e))return h[e]},set({_:t},e,i){const{data:r,setupState:n,ctx:s}=t;return uo(n,e)?(n[e]=i,!0):r!==ie&&ne(r,e)?(r[e]=i,!0):ne(t.props,e)||e[0]==="$"&&e.slice(1)in t?!1:(s[e]=i,!0)},has({_:{data:t,setupState:e,accessCache:i,ctx:r,appContext:n,propsOptions:s,type:o}},a){let l,c;return!!(i[a]||t!==ie&&a[0]!=="$"&&ne(t,a)||uo(e,a)||(l=s[0])&&ne(l,a)||ne(r,a)||ne(ur,a)||ne(n.config.globalProperties,a)||(c=o.__cssModules)&&c[a])},defineProperty(t,e,i){return i.get!=null?t._.accessCache[e]=0:ne(i,"value")&&this.set(t,e,i.value,null),Reflect.defineProperty(t,e,i)}};function bn(t){return W(t)?t.reduce((e,i)=>(e[i]=null,e),{}):t}function oc(t,e){return!t||!e?t||e:W(t)&&W(e)?t.concat(e):ke({},bn(t),bn(e))}let fo=!0;function Hm(t){const e=cc(t),i=t.proxy,r=t.ctx;fo=!1,e.beforeCreate&&ac(e.beforeCreate,t,"bc");const{data:n,computed:s,methods:o,watch:a,provide:l,inject:c,created:u,beforeMount:f,mounted:h,beforeUpdate:m,updated:d,activated:_,deactivated:k,beforeDestroy:E,beforeUnmount:x,destroyed:y,unmounted:g,render:w,renderTracked:S,renderTriggered:C,errorCaptured:T,serverPrefetch:B,expose:Y,inheritAttrs:Yt,components:Ui,directives:Kn,filters:Jo}=e;if(c&&zm(c,r,null),o)for(const he in o){const le=o[he];V(le)&&(r[he]=le.bind(i))}if(n){const he=n.call(i,i);ue(he)&&(t.data=Js(he))}if(fo=!0,s)for(const he in s){const le=s[he],hi=V(le)?le.bind(i,i):V(le.get)?le.get.bind(i,i):pt,Wn=!V(le)&&V(le.set)?le.set.bind(i):pt,pi=yr({get:hi,set:Wn});Object.defineProperty(r,he,{enumerable:!0,configurable:!0,get:()=>pi.value,set:xt=>pi.value=xt})}if(a)for(const he in a)lc(a[he],r,i,he);if(l){const he=V(l)?l.call(i):l;Reflect.ownKeys(he).forEach(le=>{hc(le,he[le])})}u&&ac(u,t,"c");function Te(he,le){W(le)?le.forEach(hi=>he(hi.bind(i))):le&&he(le.bind(i))}if(Te(nc,f),Te(Pi,h),Te(Nm,m),Te(Mm,d),Te(Rm,_),Te(Tm,k),Te(Fm,T),Te(Um,S),Te(jm,C),Te(ao,x),Te(lo,g),Te(Dm,B),W(Y))if(Y.length){const he=t.exposed||(t.exposed={});Y.forEach(le=>{Object.defineProperty(he,le,{get:()=>i[le],set:hi=>i[le]=hi,enumerable:!0})})}else t.exposed||(t.exposed={});w&&t.render===pt&&(t.render=w),Yt!=null&&(t.inheritAttrs=Yt),Ui&&(t.components=Ui),Kn&&(t.directives=Kn),B&&so(t)}function zm(t,e,i=pt){W(t)&&(t=ho(t));for(const r in t){const n=t[r];let s;ue(n)?"default"in n?s=dr(n.from||r,n.default,!0):s=dr(n.from||r):s=dr(n),Se(s)?Object.defineProperty(e,r,{enumerable:!0,configurable:!0,get:()=>s.value,set:o=>s.value=o}):e[r]=s}}function ac(t,e,i){yt(W(t)?t.map(r=>r.bind(e.proxy)):t.bind(e.proxy),e,i)}function lc(t,e,i,r){let n=r.includes(".")?$c(i,r):()=>i[r];if(ge(t)){const s=e[t];V(s)&&Ii(n,s)}else if(V(t))Ii(n,t.bind(i));else if(ue(t))if(W(t))t.forEach(s=>lc(s,e,i,r));else{const s=V(t.handler)?t.handler.bind(i):e[t.handler];V(s)&&Ii(n,s,t)}}function cc(t){const e=t.type,{mixins:i,extends:r}=e,{mixins:n,optionsCache:s,config:{optionMergeStrategies:o}}=t.appContext,a=s.get(e);let l;return a?l=a:!n.length&&!i&&!r?l=e:(l={},n.length&&n.forEach(c=>wn(l,c,o,!0)),wn(l,e,o)),ue(e)&&s.set(e,l),l}function wn(t,e,i,r=!1){const{mixins:n,extends:s}=e;s&&wn(t,s,i,!0),n&&n.forEach(o=>wn(t,o,i,!0));for(const o in e)if(!(r&&o==="expose")){const a=Km[o]||i&&i[o];t[o]=a?a(t[o],e[o]):e[o]}return t}const Km={data:uc,props:fc,emits:fc,methods:fr,computed:fr,beforeCreate:Re,created:Re,beforeMount:Re,mounted:Re,beforeUpdate:Re,updated:Re,beforeDestroy:Re,beforeUnmount:Re,destroyed:Re,unmounted:Re,activated:Re,deactivated:Re,errorCaptured:Re,serverPrefetch:Re,components:fr,directives:fr,watch:Vm,provide:uc,inject:Wm};function uc(t,e){return e?t?function(){return ke(V(t)?t.call(this,this):t,V(e)?e.call(this,this):e)}:e:t}function Wm(t,e){return fr(ho(t),ho(e))}function ho(t){if(W(t)){const e={};for(let i=0;i<t.length;i++)e[t[i]]=t[i];return e}return t}function Re(t,e){return t?[...new Set([].concat(t,e))]:e}function fr(t,e){return t?ke(Object.create(null),t,e):e}function fc(t,e){return t?W(t)&&W(e)?[...new Set([...t,...e])]:ke(Object.create(null),bn(t),bn(e??{})):e}function Vm(t,e){if(!t)return e;if(!e)return t;const i=ke(Object.create(null),t);for(const r in e)i[r]=Re(t[r],e[r]);return i}function dc(){return{app:null,config:{isNativeTag:ml,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 Gm=0;function Ym(t,e){return function(r,n=null){V(r)||(r=ke({},r)),n!=null&&!ue(n)&&(n=null);const s=dc(),o=new WeakSet,a=[];let l=!1;const c=s.app={_uid:Gm++,_component:r,_props:n,_container:null,_context:s,_instance:null,version:Rg,get config(){return s.config},set config(u){},use(u,...f){return o.has(u)||(u&&V(u.install)?(o.add(u),u.install(c,...f)):V(u)&&(o.add(u),u(c,...f))),c},mixin(u){return s.mixins.includes(u)||s.mixins.push(u),c},component(u,f){return f?(s.components[u]=f,c):s.components[u]},directive(u,f){return f?(s.directives[u]=f,c):s.directives[u]},mount(u,f,h){if(!l){const m=c._ceVNode||tt(r,n);return m.appContext=s,h===!0?h="svg":h===!1&&(h=void 0),t(m,u,h),l=!0,c._container=u,u.__vue_app__=c,kn(m.component)}},onUnmount(u){a.push(u)},unmount(){l&&(yt(a,c._instance,16),t(null,c._container),delete c._container.__vue_app__)},provide(u,f){return s.provides[u]=f,c},runWithContext(u){const f=Ci;Ci=c;try{return u()}finally{Ci=f}}};return c}}let Ci=null;function hc(t,e){if(Ie){let i=Ie.provides;const r=Ie.parent&&Ie.parent.provides;r===i&&(i=Ie.provides=Object.create(r)),i[t]=e}}function dr(t,e,i=!1){const r=_o();if(r||Ci){let n=Ci?Ci._context.provides:r?r.parent==null||r.ce?r.vnode.appContext&&r.vnode.appContext.provides:r.parent.provides:void 0;if(n&&t in n)return n[t];if(arguments.length>1)return i&&V(e)?e.call(r&&r.proxy):e}}const pc={},mc=()=>Object.create(pc),gc=t=>Object.getPrototypeOf(t)===pc;function Qm(t,e,i,r=!1){const n={},s=mc();t.propsDefaults=Object.create(null),yc(t,e,n,s);for(const o in t.propsOptions[0])o in n||(n[o]=void 0);i?t.props=r?n:lm(n):t.type.props?t.props=n:t.props=s,t.attrs=s}function Xm(t,e,i,r){const{props:n,attrs:s,vnode:{patchFlag:o}}=t,a=te(n),[l]=t.propsOptions;let c=!1;if((r||o>0)&&!(o&16)){if(o&8){const u=t.vnode.dynamicProps;for(let f=0;f<u.length;f++){let h=u[f];if(vn(t.emitsOptions,h))continue;const m=e[h];if(l)if(ne(s,h))m!==s[h]&&(s[h]=m,c=!0);else{const d=At(h);n[d]=po(l,a,d,m,t,!1)}else m!==s[h]&&(s[h]=m,c=!0)}}}else{yc(t,e,n,s)&&(c=!0);let u;for(const f in a)(!e||!ne(e,f)&&((u=Ft(f))===f||!ne(e,u)))&&(l?i&&(i[f]!==void 0||i[u]!==void 0)&&(n[f]=po(l,a,f,void 0,t,!0)):delete n[f]);if(s!==a)for(const f in s)(!e||!ne(e,f))&&(delete s[f],c=!0)}c&&Ot(t.attrs,"set","")}function yc(t,e,i,r){const[n,s]=t.propsOptions;let o=!1,a;if(e)for(let l in e){if(Ji(l))continue;const c=e[l];let u;n&&ne(n,u=At(l))?!s||!s.includes(u)?i[u]=c:(a||(a={}))[u]=c:vn(t.emitsOptions,l)||(!(l in r)||c!==r[l])&&(r[l]=c,o=!0)}if(s){const l=te(i),c=a||ie;for(let u=0;u<s.length;u++){const f=s[u];i[f]=po(n,l,f,c[f],t,!ne(c,f))}}return o}function po(t,e,i,r,n,s){const o=t[i];if(o!=null){const a=ne(o,"default");if(a&&r===void 0){const l=o.default;if(o.type!==Function&&!o.skipFactory&&V(l)){const{propsDefaults:c}=n;if(i in c)r=c[i];else{const u=gr(n);r=c[i]=l.call(null,e),u()}}else r=l;n.ce&&n.ce._setProp(i,r)}o[0]&&(s&&!a?r=!1:o[1]&&(r===""||r===Ft(i))&&(r=!0))}return r}const Jm=new WeakMap;function bc(t,e,i=!1){const r=i?Jm:e.propsCache,n=r.get(t);if(n)return n;const s=t.props,o={},a=[];let l=!1;if(!V(t)){const u=f=>{l=!0;const[h,m]=bc(f,e,!0);ke(o,h),m&&a.push(...m)};!i&&e.mixins.length&&e.mixins.forEach(u),t.extends&&u(t.extends),t.mixins&&t.mixins.forEach(u)}if(!s&&!l)return ue(t)&&r.set(t,vi),vi;if(W(s))for(let u=0;u<s.length;u++){const f=At(s[u]);wc(f)&&(o[f]=ie)}else if(s)for(const u in s){const f=At(u);if(wc(f)){const h=s[u],m=o[f]=W(h)||V(h)?{type:h}:ke({},h),d=m.type;let _=!1,k=!0;if(W(d))for(let E=0;E<d.length;++E){const x=d[E],y=V(x)&&x.name;if(y==="Boolean"){_=!0;break}else y==="String"&&(k=!1)}else _=V(d)&&d.name==="Boolean";m[0]=_,m[1]=k,(_||ne(m,"default"))&&a.push(f)}}const c=[o,a];return ue(t)&&r.set(t,c),c}function wc(t){return t[0]!=="$"&&!Ji(t)}const mo=t=>t==="_"||t==="_ctx"||t==="$stable",go=t=>W(t)?t.map(wt):[wt(t)],Zm=(t,e,i)=>{if(e._n)return e;const r=Em((...n)=>go(e(...n)),i);return r._c=!1,r},vc=(t,e,i)=>{const r=t._ctx;for(const n in t){if(mo(n))continue;const s=t[n];if(V(s))e[n]=Zm(n,s,r);else if(s!=null){const o=go(s);e[n]=()=>o}}},_c=(t,e)=>{const i=go(e);t.slots.default=()=>i},xc=(t,e,i)=>{for(const r in e)(i||!mo(r))&&(t[r]=e[r])},eg=(t,e,i)=>{const r=t.slots=mc();if(t.vnode.shapeFlag&32){const n=e._;n?(xc(r,e,i),i&&_l(r,"_",n,!0)):vc(e,r)}else e&&_c(t,e)},tg=(t,e,i)=>{const{vnode:r,slots:n}=t;let s=!0,o=ie;if(r.shapeFlag&32){const a=e._;a?i&&a===1?s=!1:xc(n,e,i):(s=!e.$stable,vc(e,n)),o=e}else e&&(_c(t,e),o={default:1});if(s)for(const a in n)!mo(a)&&o[a]==null&&delete n[a]},We=gg;function ig(t){return rg(t)}function rg(t,e){const i=tn();i.__VUE__=!0;const{insert:r,remove:n,patchProp:s,createElement:o,createText:a,createComment:l,setText:c,setElementText:u,parentNode:f,nextSibling:h,setScopeId:m=pt,insertStaticContent:d}=t,_=(b,v,P,R=null,I=null,A=null,j=void 0,D=null,N=!!v.dynamicChildren)=>{if(b===v)return;b&&!mr(b,v)&&(R=Vn(b),xt(b,I,A,!0),b=null),v.patchFlag===-2&&(N=!1,v.dynamicChildren=null);const{type:O,ref:H,shapeFlag:F}=v;switch(O){case _n:k(b,v,P,R);break;case Ht:E(b,v,P,R);break;case wo:b==null&&x(v,P,R,j);break;case ct:Ui(b,v,P,R,I,A,j,D,N);break;default:F&1?w(b,v,P,R,I,A,j,D,N):F&6?Kn(b,v,P,R,I,A,j,D,N):(F&64||F&128)&&O.process(b,v,P,R,I,A,j,D,N,Ir)}H!=null&&I?lr(H,b&&b.ref,A,v||b,!v):H==null&&b&&b.ref!=null&&lr(b.ref,null,A,b,!0)},k=(b,v,P,R)=>{if(b==null)r(v.el=a(v.children),P,R);else{const I=v.el=b.el;v.children!==b.children&&c(I,v.children)}},E=(b,v,P,R)=>{b==null?r(v.el=l(v.children||""),P,R):v.el=b.el},x=(b,v,P,R)=>{[b.el,b.anchor]=d(b.children,v,P,R,b.el,b.anchor)},y=({el:b,anchor:v},P,R)=>{let I;for(;b&&b!==v;)I=h(b),r(b,P,R),b=I;r(v,P,R)},g=({el:b,anchor:v})=>{let P;for(;b&&b!==v;)P=h(b),n(b),b=P;n(v)},w=(b,v,P,R,I,A,j,D,N)=>{if(v.type==="svg"?j="svg":v.type==="math"&&(j="mathml"),b==null)S(v,P,R,I,A,j,D,N);else{const O=b.el&&b.el._isVueCE?b.el:null;try{O&&O._beginPatch(),B(b,v,I,A,j,D,N)}finally{O&&O._endPatch()}}},S=(b,v,P,R,I,A,j,D)=>{let N,O;const{props:H,shapeFlag:F,transition:q,dirs:G}=b;if(N=b.el=o(b.type,A,H&&H.is,H),F&8?u(N,b.children):F&16&&T(b.children,N,null,R,I,yo(b,A),j,D),G&&oi(b,null,R,"created"),C(N,b,b.scopeId,j,R),H){for(const ce in H)ce!=="value"&&!Ji(ce)&&s(N,ce,null,H[ce],A,R);"value"in H&&s(N,"value",null,H.value,A),(O=H.onVnodeBeforeMount)&&vt(O,R,b)}G&&oi(b,null,R,"beforeMount");const ee=ng(I,q);ee&&q.beforeEnter(N),r(N,v,P),((O=H&&H.onVnodeMounted)||ee||G)&&We(()=>{O&&vt(O,R,b),ee&&q.enter(N),G&&oi(b,null,R,"mounted")},I)},C=(b,v,P,R,I)=>{if(P&&m(b,P),R)for(let A=0;A<R.length;A++)m(b,R[A]);if(I){let A=I.subTree;if(v===A||Rc(A.type)&&(A.ssContent===v||A.ssFallback===v)){const j=I.vnode;C(b,j,j.scopeId,j.slotScopeIds,I.parent)}}},T=(b,v,P,R,I,A,j,D,N=0)=>{for(let O=N;O<b.length;O++){const H=b[O]=D?Kt(b[O]):wt(b[O]);_(null,H,v,P,R,I,A,j,D)}},B=(b,v,P,R,I,A,j)=>{const D=v.el=b.el;let{patchFlag:N,dynamicChildren:O,dirs:H}=v;N|=b.patchFlag&16;const F=b.props||ie,q=v.props||ie;let G;if(P&&ai(P,!1),(G=q.onVnodeBeforeUpdate)&&vt(G,P,v,b),H&&oi(v,b,P,"beforeUpdate"),P&&ai(P,!0),(F.innerHTML&&q.innerHTML==null||F.textContent&&q.textContent==null)&&u(D,""),O?Y(b.dynamicChildren,O,D,P,R,yo(v,I),A):j||le(b,v,D,null,P,R,yo(v,I),A,!1),N>0){if(N&16)Yt(D,F,q,P,I);else if(N&2&&F.class!==q.class&&s(D,"class",null,q.class,I),N&4&&s(D,"style",F.style,q.style,I),N&8){const ee=v.dynamicProps;for(let ce=0;ce<ee.length;ce++){const se=ee[ce],qe=F[se],He=q[se];(He!==qe||se==="value")&&s(D,se,qe,He,I,P)}}N&1&&b.children!==v.children&&u(D,v.children)}else!j&&O==null&&Yt(D,F,q,P,I);((G=q.onVnodeUpdated)||H)&&We(()=>{G&&vt(G,P,v,b),H&&oi(v,b,P,"updated")},R)},Y=(b,v,P,R,I,A,j)=>{for(let D=0;D<v.length;D++){const N=b[D],O=v[D],H=N.el&&(N.type===ct||!mr(N,O)||N.shapeFlag&198)?f(N.el):P;_(N,O,H,null,R,I,A,j,!0)}},Yt=(b,v,P,R,I)=>{if(v!==P){if(v!==ie)for(const A in v)!Ji(A)&&!(A in P)&&s(b,A,v[A],null,I,R);for(const A in P){if(Ji(A))continue;const j=P[A],D=v[A];j!==D&&A!=="value"&&s(b,A,D,j,I,R)}"value"in P&&s(b,"value",v.value,P.value,I)}},Ui=(b,v,P,R,I,A,j,D,N)=>{const O=v.el=b?b.el:a(""),H=v.anchor=b?b.anchor:a("");let{patchFlag:F,dynamicChildren:q,slotScopeIds:G}=v;G&&(D=D?D.concat(G):G),b==null?(r(O,P,R),r(H,P,R),T(v.children||[],P,H,I,A,j,D,N)):F>0&&F&64&&q&&b.dynamicChildren?(Y(b.dynamicChildren,q,P,I,A,j,D),(v.key!=null||I&&v===I.subTree)&&Sc(b,v,!0)):le(b,v,P,H,I,A,j,D,N)},Kn=(b,v,P,R,I,A,j,D,N)=>{v.slotScopeIds=D,b==null?v.shapeFlag&512?I.ctx.activate(v,P,R,j,N):Jo(v,P,R,I,A,j,N):bf(b,v,N)},Jo=(b,v,P,R,I,A,j)=>{const D=b.component=Sg(b,R,I);if(oo(b)&&(D.ctx.renderer=Ir),kg(D,!1,j),D.asyncDep){if(I&&I.registerDep(D,Te,j),!b.el){const N=D.subTree=tt(Ht);E(null,N,v,P),b.placeholder=N.el}}else Te(D,b,v,P,I,A,j)},bf=(b,v,P)=>{const R=v.component=b.component;if(pg(b,v,P))if(R.asyncDep&&!R.asyncResolved){he(R,v,P);return}else R.next=v,R.update();else v.el=b.el,R.vnode=v},Te=(b,v,P,R,I,A,j)=>{const D=()=>{if(b.isMounted){let{next:F,bu:q,u:G,parent:ee,vnode:ce}=b;{const kt=kc(b);if(kt){F&&(F.el=ce.el,he(b,F,j)),kt.asyncDep.then(()=>{b.isUnmounted||D()});return}}let se=F,qe;ai(b,!1),F?(F.el=ce.el,he(b,F,j)):F=ce,q&&en(q),(qe=F.props&&F.props.onVnodeBeforeUpdate)&&vt(qe,ee,F,ce),ai(b,!0);const He=Ac(b),St=b.subTree;b.subTree=He,_(St,He,f(St.el),Vn(St),b,I,A),F.el=He.el,se===null&&mg(b,He.el),G&&We(G,I),(qe=F.props&&F.props.onVnodeUpdated)&&We(()=>vt(qe,ee,F,ce),I)}else{let F;const{el:q,props:G}=v,{bm:ee,m:ce,parent:se,root:qe,type:He}=b,St=cr(v);ai(b,!1),ee&&en(ee),!St&&(F=G&&G.onVnodeBeforeMount)&&vt(F,se,v),ai(b,!0);{qe.ce&&qe.ce._def.shadowRoot!==!1&&qe.ce._injectChildStyle(He);const kt=b.subTree=Ac(b);_(null,kt,P,R,b,I,A),v.el=kt.el}if(ce&&We(ce,I),!St&&(F=G&&G.onVnodeMounted)){const kt=v;We(()=>vt(F,se,kt),I)}(v.shapeFlag&256||se&&cr(se.vnode)&&se.vnode.shapeFlag&256)&&b.a&&We(b.a,I),b.isMounted=!0,v=P=R=null}};b.scope.on();const N=b.effect=new $l(D);b.scope.off();const O=b.update=N.run.bind(N),H=b.job=N.runIfDirty.bind(N);H.i=b,H.id=b.uid,N.scheduler=()=>ro(H),ai(b,!0),O()},he=(b,v,P)=>{v.component=b;const R=b.vnode.props;b.vnode=v,b.next=null,Xm(b,v.props,R,P),tg(b,v.children,P),mt(),Ql(b),gt()},le=(b,v,P,R,I,A,j,D,N=!1)=>{const O=b&&b.children,H=b?b.shapeFlag:0,F=v.children,{patchFlag:q,shapeFlag:G}=v;if(q>0){if(q&128){Wn(O,F,P,R,I,A,j,D,N);return}else if(q&256){hi(O,F,P,R,I,A,j,D,N);return}}G&8?(H&16&&Cr(O,I,A),F!==O&&u(P,F)):H&16?G&16?Wn(O,F,P,R,I,A,j,D,N):Cr(O,I,A,!0):(H&8&&u(P,""),G&16&&T(F,P,R,I,A,j,D,N))},hi=(b,v,P,R,I,A,j,D,N)=>{b=b||vi,v=v||vi;const O=b.length,H=v.length,F=Math.min(O,H);let q;for(q=0;q<F;q++){const G=v[q]=N?Kt(v[q]):wt(v[q]);_(b[q],G,P,null,I,A,j,D,N)}O>H?Cr(b,I,A,!0,!1,F):T(v,P,R,I,A,j,D,N,F)},Wn=(b,v,P,R,I,A,j,D,N)=>{let O=0;const H=v.length;let F=b.length-1,q=H-1;for(;O<=F&&O<=q;){const G=b[O],ee=v[O]=N?Kt(v[O]):wt(v[O]);if(mr(G,ee))_(G,ee,P,null,I,A,j,D,N);else break;O++}for(;O<=F&&O<=q;){const G=b[F],ee=v[q]=N?Kt(v[q]):wt(v[q]);if(mr(G,ee))_(G,ee,P,null,I,A,j,D,N);else break;F--,q--}if(O>F){if(O<=q){const G=q+1,ee=G<H?v[G].el:R;for(;O<=q;)_(null,v[O]=N?Kt(v[O]):wt(v[O]),P,ee,I,A,j,D,N),O++}}else if(O>q)for(;O<=F;)xt(b[O],I,A,!0),O++;else{const G=O,ee=O,ce=new Map;for(O=ee;O<=q;O++){const Qe=v[O]=N?Kt(v[O]):wt(v[O]);Qe.key!=null&&ce.set(Qe.key,O)}let se,qe=0;const He=q-ee+1;let St=!1,kt=0;const Ar=new Array(He);for(O=0;O<He;O++)Ar[O]=0;for(O=G;O<=F;O++){const Qe=b[O];if(qe>=He){xt(Qe,I,A,!0);continue}let Et;if(Qe.key!=null)Et=ce.get(Qe.key);else for(se=ee;se<=q;se++)if(Ar[se-ee]===0&&mr(Qe,v[se])){Et=se;break}Et===void 0?xt(Qe,I,A,!0):(Ar[Et-ee]=O+1,Et>=kt?kt=Et:St=!0,_(Qe,v[Et],P,null,I,A,j,D,N),qe++)}const _f=St?sg(Ar):vi;for(se=_f.length-1,O=He-1;O>=0;O--){const Qe=ee+O,Et=v[Qe],xf=v[Qe+1],Sf=Qe+1<H?xf.el||xf.placeholder:R;Ar[O]===0?_(null,Et,P,Sf,I,A,j,D,N):St&&(se<0||O!==_f[se]?pi(Et,P,Sf,2):se--)}}},pi=(b,v,P,R,I=null)=>{const{el:A,type:j,transition:D,children:N,shapeFlag:O}=b;if(O&6){pi(b.component.subTree,v,P,R);return}if(O&128){b.suspense.move(v,P,R);return}if(O&64){j.move(b,v,P,Ir);return}if(j===ct){r(A,v,P);for(let F=0;F<N.length;F++)pi(N[F],v,P,R);r(b.anchor,v,P);return}if(j===wo){y(b,v,P);return}if(R!==2&&O&1&&D)if(R===0)D.beforeEnter(A),r(A,v,P),We(()=>D.enter(A),I);else{const{leave:F,delayLeave:q,afterLeave:G}=D,ee=()=>{b.ctx.isUnmounted?n(A):r(A,v,P)},ce=()=>{A._isLeaving&&A[Im](!0),F(A,()=>{ee(),G&&G()})};q?q(A,ee,ce):ce()}else r(A,v,P)},xt=(b,v,P,R=!1,I=!1)=>{const{type:A,props:j,ref:D,children:N,dynamicChildren:O,shapeFlag:H,patchFlag:F,dirs:q,cacheIndex:G}=b;if(F===-2&&(I=!1),D!=null&&(mt(),lr(D,null,P,b,!0),gt()),G!=null&&(v.renderCache[G]=void 0),H&256){v.ctx.deactivate(b);return}const ee=H&1&&q,ce=!cr(b);let se;if(ce&&(se=j&&j.onVnodeBeforeUnmount)&&vt(se,v,b),H&6)Qw(b.component,P,R);else{if(H&128){b.suspense.unmount(P,R);return}ee&&oi(b,null,v,"beforeUnmount"),H&64?b.type.remove(b,v,P,Ir,R):O&&!O.hasOnce&&(A!==ct||F>0&&F&64)?Cr(O,v,P,!1,!0):(A===ct&&F&384||!I&&H&16)&&Cr(N,v,P),R&&wf(b)}(ce&&(se=j&&j.onVnodeUnmounted)||ee)&&We(()=>{se&&vt(se,v,b),ee&&oi(b,null,v,"unmounted")},P)},wf=b=>{const{type:v,el:P,anchor:R,transition:I}=b;if(v===ct){Yw(P,R);return}if(v===wo){g(b);return}const A=()=>{n(P),I&&!I.persisted&&I.afterLeave&&I.afterLeave()};if(b.shapeFlag&1&&I&&!I.persisted){const{leave:j,delayLeave:D}=I,N=()=>j(P,A);D?D(b.el,A,N):N()}else A()},Yw=(b,v)=>{let P;for(;b!==v;)P=h(b),n(b),b=P;n(v)},Qw=(b,v,P)=>{const{bum:R,scope:I,job:A,subTree:j,um:D,m:N,a:O}=b;Ec(N),Ec(O),R&&en(R),I.stop(),A&&(A.flags|=8,xt(j,b,v,P)),D&&We(D,v),We(()=>{b.isUnmounted=!0},v)},Cr=(b,v,P,R=!1,I=!1,A=0)=>{for(let j=A;j<b.length;j++)xt(b[j],v,P,R,I)},Vn=b=>{if(b.shapeFlag&6)return Vn(b.component.subTree);if(b.shapeFlag&128)return b.suspense.next();const v=h(b.anchor||b.el),P=v&&v[Pm];return P?h(P):v};let Zo=!1;const vf=(b,v,P)=>{b==null?v._vnode&&xt(v._vnode,null,null,!0):_(v._vnode||null,b,v,null,null,null,P),v._vnode=b,Zo||(Zo=!0,Ql(),Xl(),Zo=!1)},Ir={p:_,um:xt,m:pi,r:wf,mt:Jo,mc:T,pc:le,pbc:Y,n:Vn,o:t};return{render:vf,hydrate:void 0,createApp:Ym(vf)}}function yo({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 ai({effect:t,job:e},i){i?(t.flags|=32,e.flags|=4):(t.flags&=-33,e.flags&=-5)}function ng(t,e){return(!t||t&&!t.pendingBranch)&&e&&!e.persisted}function Sc(t,e,i=!1){const r=t.children,n=e.children;if(W(r)&&W(n))for(let s=0;s<r.length;s++){const o=r[s];let a=n[s];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=n[s]=Kt(n[s]),a.el=o.el),!i&&a.patchFlag!==-2&&Sc(o,a)),a.type===_n&&a.patchFlag!==-1&&(a.el=o.el),a.type===Ht&&!a.el&&(a.el=o.el)}}function sg(t){const e=t.slice(),i=[0];let r,n,s,o,a;const l=t.length;for(r=0;r<l;r++){const c=t[r];if(c!==0){if(n=i[i.length-1],t[n]<c){e[r]=n,i.push(r);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[r]=i[s-1]),i[s]=r)}}for(s=i.length,o=i[s-1];s-- >0;)i[s]=o,o=e[o];return i}function kc(t){const e=t.subTree.component;if(e)return e.asyncDep&&!e.asyncResolved?e:kc(e)}function Ec(t){if(t)for(let e=0;e<t.length;e++)t[e].flags|=8}const og=Symbol.for("v-scx"),ag=()=>dr(og);function lg(t,e){return bo(t,null,{flush:"sync"})}function Ii(t,e,i){return bo(t,e,i)}function bo(t,e,i=ie){const{immediate:r,deep:n,flush:s,once:o}=i,a=ke({},i),l=e&&r||!e&&s!=="post";let c;if(Oi){if(s==="sync"){const m=ag();c=m.__watcherHandles||(m.__watcherHandles=[])}else if(!l){const m=()=>{};return m.stop=pt,m.resume=pt,m.pause=pt,m}}const u=Ie;a.call=(m,d,_)=>yt(m,u,d,_);let f=!1;s==="post"?a.scheduler=m=>{We(m,u&&u.suspense)}:s!=="sync"&&(f=!0,a.scheduler=(m,d)=>{d?m():ro(m)}),a.augmentJob=m=>{e&&(m.flags|=4),f&&(m.flags|=2,u&&(m.id=u.uid,m.i=u))};const h=ym(t,e,a);return Oi&&(c?c.push(h):l&&h()),h}function cg(t,e,i){const r=this.proxy,n=ge(t)?t.includes(".")?$c(r,t):()=>r[t]:t.bind(r,r);let s;V(e)?s=e:(s=e.handler,i=e);const o=gr(this),a=bo(n,s.bind(r),i);return o(),a}function $c(t,e){const i=e.split(".");return()=>{let r=t;for(let n=0;n<i.length&&r;n++)r=r[i[n]];return r}}function Pc(t,e,i=ie){const r=_o(),n=At(e),s=Ft(e),o=Cc(t,n),a=hm((l,c)=>{let u,f=ie,h;return lg(()=>{const m=t[n];Ue(u,m)&&(u=m,c())}),{get(){return l(),i.get?i.get(u):u},set(m){const d=i.set?i.set(m):m;if(!Ue(d,u)&&!(f!==ie&&Ue(m,f)))return;const _=r.vnode.props;_&&(e in _||n in _||s in _)&&(`onUpdate:${e}`in _||`onUpdate:${n}`in _||`onUpdate:${s}`in _)||(u=m,c()),r.emit(`update:${e}`,d),Ue(m,d)&&Ue(m,f)&&!Ue(d,h)&&c(),f=m,h=d}}});return a[Symbol.iterator]=()=>{let l=0;return{next(){return l<2?{value:l++?o||ie:a,done:!1}:{done:!0}}}},a}const Cc=(t,e)=>e==="modelValue"||e==="model-value"?t.modelModifiers:t[`${e}Modifiers`]||t[`${At(e)}Modifiers`]||t[`${Ft(e)}Modifiers`];function ug(t,e,...i){if(t.isUnmounted)return;const r=t.vnode.props||ie;let n=i;const s=e.startsWith("update:"),o=s&&Cc(r,e.slice(7));o&&(o.trim&&(n=i.map(u=>ge(u)?u.trim():u)),o.number&&(n=i.map(Us)));let a,l=r[a=js(e)]||r[a=js(At(e))];!l&&s&&(l=r[a=js(Ft(e))]),l&&yt(l,t,6,n);const c=r[a+"Once"];if(c){if(!t.emitted)t.emitted={};else if(t.emitted[a])return;t.emitted[a]=!0,yt(c,t,6,n)}}const fg=new WeakMap;function Ic(t,e,i=!1){const r=i?fg:e.emitsCache,n=r.get(t);if(n!==void 0)return n;const s=t.emits;let o={},a=!1;if(!V(t)){const l=c=>{const u=Ic(c,e,!0);u&&(a=!0,ke(o,u))};!i&&e.mixins.length&&e.mixins.forEach(l),t.extends&&l(t.extends),t.mixins&&t.mixins.forEach(l)}return!s&&!a?(ue(t)&&r.set(t,null),null):(W(s)?s.forEach(l=>o[l]=null):ke(o,s),ue(t)&&r.set(t,o),o)}function vn(t,e){return!t||!Xr(e)?!1:(e=e.slice(2).replace(/Once$/,""),ne(t,e[0].toLowerCase()+e.slice(1))||ne(t,Ft(e))||ne(t,e))}function rv(){}function Ac(t){const{type:e,vnode:i,proxy:r,withProxy:n,propsOptions:[s],slots:o,attrs:a,emit:l,render:c,renderCache:u,props:f,data:h,setupState:m,ctx:d,inheritAttrs:_}=t,k=hn(t);let E,x;try{if(i.shapeFlag&4){const g=n||r,w=g;E=wt(c.call(w,g,u,f,m,h,d)),x=a}else{const g=e;E=wt(g.length>1?g(f,{attrs:a,slots:o,emit:l}):g(f,null)),x=e.props?a:dg(a)}}catch(g){hr.length=0,sr(g,t,1),E=tt(Ht)}let y=E;if(x&&_!==!1){const g=Object.keys(x),{shapeFlag:w}=y;g.length&&w&7&&(s&&g.some(Ns)&&(x=hg(x,s)),y=Ai(y,x,!1,!0))}return i.dirs&&(y=Ai(y,null,!1,!0),y.dirs=y.dirs?y.dirs.concat(i.dirs):i.dirs),i.transition&&no(y,i.transition),E=y,hn(k),E}const dg=t=>{let e;for(const i in t)(i==="class"||i==="style"||Xr(i))&&((e||(e={}))[i]=t[i]);return e},hg=(t,e)=>{const i={};for(const r in t)(!Ns(r)||!(r.slice(9)in e))&&(i[r]=t[r]);return i};function pg(t,e,i){const{props:r,children:n,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 r?Oc(r,o,c):!!o;if(l&8){const u=e.dynamicProps;for(let f=0;f<u.length;f++){const h=u[f];if(o[h]!==r[h]&&!vn(c,h))return!0}}}else return(n||a)&&(!a||!a.$stable)?!0:r===o?!1:r?o?Oc(r,o,c):!0:!!o;return!1}function Oc(t,e,i){const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!0;for(let n=0;n<r.length;n++){const s=r[n];if(e[s]!==t[s]&&!vn(i,s))return!0}return!1}function mg({vnode:t,parent:e},i){for(;e;){const r=e.subTree;if(r.suspense&&r.suspense.activeBranch===t&&(r.el=t.el),r===t)(t=e.vnode).el=i,e=e.parent;else break}}const Rc=t=>t.__isSuspense;function gg(t,e){e&&e.pendingBranch?W(t)?e.effects.push(...t):e.effects.push(t):km(t)}const ct=Symbol.for("v-fgt"),_n=Symbol.for("v-txt"),Ht=Symbol.for("v-cmt"),wo=Symbol.for("v-stc"),hr=[];let Ve=null;function _e(t=!1){hr.push(Ve=t?null:[])}function yg(){hr.pop(),Ve=hr[hr.length-1]||null}let pr=1;function Tc(t,e=!1){pr+=t,t<0&&Ve&&e&&(Ve.hasOnce=!0)}function Lc(t){return t.dynamicChildren=pr>0?Ve||vi:null,yg(),pr>0&&Ve&&Ve.push(t),t}function $e(t,e,i,r,n,s){return Lc(de(t,e,i,r,n,s,!0))}function Nc(t,e,i,r,n){return Lc(tt(t,e,i,r,n,!0))}function Mc(t){return t?t.__v_isVNode===!0:!1}function mr(t,e){return t.type===e.type&&t.key===e.key}const Dc=({key:t})=>t??null,xn=({ref:t,ref_key:e,ref_for:i})=>(typeof t=="number"&&(t=""+t),t!=null?ge(t)||Se(t)||V(t)?{i:et,r:t,k:e,f:!!i}:t:null);function de(t,e=null,i=null,r=0,n=null,s=t===ct?0:1,o=!1,a=!1){const l={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&Dc(e),ref:e&&xn(e),scopeId:Zl,slotScopeIds:null,children:i,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:s,patchFlag:r,dynamicProps:n,dynamicChildren:null,appContext:null,ctx:et};return a?(vo(l,i),s&128&&t.normalize(l)):i&&(l.shapeFlag|=ge(i)?8:16),pr>0&&!o&&Ve&&(l.patchFlag>0||s&6)&&l.patchFlag!==32&&Ve.push(l),l}const tt=bg;function bg(t,e=null,i=null,r=0,n=null,s=!1){if((!t||t===Bm)&&(t=Ht),Mc(t)){const a=Ai(t,e,!0);return i&&vo(a,i),pr>0&&!s&&Ve&&(a.shapeFlag&6?Ve[Ve.indexOf(t)]=a:Ve.push(a)),a.patchFlag=-2,a}if(Og(t)&&(t=t.__vccOpts),e){e=wg(e);let{class:a,style:l}=e;a&&!ge(a)&&(e.class=ri(a)),ue(l)&&(eo(l)&&!W(l)&&(l=ke({},l)),e.style=Fs(l))}const o=ge(t)?1:Rc(t)?128:Cm(t)?64:ue(t)?4:V(t)?2:0;return de(t,e,i,r,n,o,s,!0)}function wg(t){return t?eo(t)||gc(t)?ke({},t):t:null}function Ai(t,e,i=!1,r=!1){const{props:n,ref:s,patchFlag:o,children:a,transition:l}=t,c=e?jc(n||{},e):n,u={__v_isVNode:!0,__v_skip:!0,type:t.type,props:c,key:c&&Dc(c),ref:e&&e.ref?i&&s?W(s)?s.concat(xn(e)):[s,xn(e)]:xn(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!==ct?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&&Ai(t.ssContent),ssFallback:t.ssFallback&&Ai(t.ssFallback),placeholder:t.placeholder,el:t.el,anchor:t.anchor,ctx:t.ctx,ce:t.ce};return l&&r&&no(u,l.clone(u)),u}function vg(t=" ",e=0){return tt(_n,null,t,e)}function zt(t="",e=!1){return e?(_e(),Nc(Ht,null,t)):tt(Ht,null,t)}function wt(t){return t==null||typeof t=="boolean"?tt(Ht):W(t)?tt(ct,null,t.slice()):Mc(t)?Kt(t):tt(_n,null,String(t))}function Kt(t){return t.el===null&&t.patchFlag!==-1||t.memo?t:Ai(t)}function vo(t,e){let i=0;const{shapeFlag:r}=t;if(e==null)e=null;else if(W(e))i=16;else if(typeof e=="object")if(r&65){const n=e.default;n&&(n._c&&(n._d=!1),vo(t,n()),n._c&&(n._d=!0));return}else{i=32;const n=e._;!n&&!gc(e)?e._ctx=et:n===3&&et&&(et.slots._===1?e._=1:(e._=2,t.patchFlag|=1024))}else V(e)?(e={default:e,_ctx:et},i=32):(e=String(e),r&64?(i=16,e=[vg(e)]):i=8);t.children=e,t.shapeFlag|=i}function jc(...t){const e={};for(let i=0;i<t.length;i++){const r=t[i];for(const n in r)if(n==="class")e.class!==r.class&&(e.class=ri([e.class,r.class]));else if(n==="style")e.style=Fs([e.style,r.style]);else if(Xr(n)){const s=e[n],o=r[n];o&&s!==o&&!(W(s)&&s.includes(o))&&(e[n]=s?[].concat(s,o):o)}else n!==""&&(e[n]=r[n])}return e}function vt(t,e,i,r=null){yt(t,e,7,[i,r])}const _g=dc();let xg=0;function Sg(t,e,i){const r=t.type,n=(e?e.appContext:t.appContext)||_g,s={uid:xg++,vnode:t,type:r,parent:e,appContext:n,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new qp(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:e?e.provides:Object.create(n.provides),ids:e?e.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:bc(r,n),emitsOptions:Ic(r,n),emit:null,emitted:null,propsDefaults:ie,inheritAttrs:r.inheritAttrs,ctx:ie,data:ie,props:ie,attrs:ie,slots:ie,refs:ie,setupState:ie,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=ug.bind(null,s),t.ce&&t.ce(s),s}let Ie=null;const _o=()=>Ie||et;let Sn,xo;{const t=tn(),e=(i,r)=>{let n;return(n=t[i])||(n=t[i]=[]),n.push(r),s=>{n.length>1?n.forEach(o=>o(s)):n[0](s)}};Sn=e("__VUE_INSTANCE_SETTERS__",i=>Ie=i),xo=e("__VUE_SSR_SETTERS__",i=>Oi=i)}const gr=t=>{const e=Ie;return Sn(t),t.scope.on(),()=>{t.scope.off(),Sn(e)}},Uc=()=>{Ie&&Ie.scope.off(),Sn(null)};function Fc(t){return t.vnode.shapeFlag&4}let Oi=!1;function kg(t,e=!1,i=!1){e&&xo(e);const{props:r,children:n}=t.vnode,s=Fc(t);Qm(t,r,s,e),eg(t,n,i||e);const o=s?Eg(t,e):void 0;return e&&xo(!1),o}function Eg(t,e){const i=t.type;t.accessCache=Object.create(null),t.proxy=new Proxy(t.ctx,qm);const{setup:r}=i;if(r){mt();const n=t.setupContext=r.length>1?Pg(t):null,s=gr(t),o=ki(r,t,0,[t.props,n]),a=yl(o);if(gt(),s(),(a||t.sp)&&!cr(t)&&so(t),a){if(o.then(Uc,Uc),e)return o.then(l=>{Bc(t,l)}).catch(l=>{sr(l,t,0)});t.asyncDep=o}else Bc(t,o)}else qc(t)}function Bc(t,e,i){V(e)?t.type.__ssrInlineRender?t.ssrRender=e:t.render=e:ue(e)&&(t.setupState=Wl(e)),qc(t)}function qc(t,e,i){const r=t.type;t.render||(t.render=r.render||pt);{const n=gr(t);mt();try{Hm(t)}finally{gt(),n()}}}const $g={get(t,e){return Ce(t,"get",""),t[e]}};function Pg(t){const e=i=>{t.exposed=i||{}};return{attrs:new Proxy(t.attrs,$g),slots:t.slots,emit:t.emit,expose:e}}function kn(t){return t.exposed?t.exposeProxy||(t.exposeProxy=new Proxy(Wl(cm(t.exposed)),{get(e,i){if(i in e)return e[i];if(i in ur)return ur[i](t)},has(e,i){return i in e||i in ur}})):t.proxy}const Cg=/(?:^|[-_])\w/g,Ig=t=>t.replace(Cg,e=>e.toUpperCase()).replace(/[-_]/g,"");function Ag(t,e=!0){return V(t)?t.displayName||t.name:t.name||e&&t.__name}function Hc(t,e,i=!1){let r=Ag(e);if(!r&&e.__file){const n=e.__file.match(/([^/\\]+)\.\w+$/);n&&(r=n[1])}if(!r&&t&&t.parent){const n=s=>{for(const o in s)if(s[o]===e)return o};r=n(t.components||t.parent.type.components)||n(t.appContext.components)}return r?Ig(r):i?"App":"Anonymous"}function Og(t){return V(t)&&"__vccOpts"in t}const yr=(t,e)=>mm(t,e,Oi),Rg="3.5.24";let So;const zc=typeof window<"u"&&window.trustedTypes;if(zc)try{So=zc.createPolicy("vue",{createHTML:t=>t})}catch{}const Kc=So?t=>So.createHTML(t):t=>t,Tg="http://www.w3.org/2000/svg",Lg="http://www.w3.org/1998/Math/MathML",Nt=typeof document<"u"?document:null,Wc=Nt&&Nt.createElement("template"),Ng={insert:(t,e,i)=>{e.insertBefore(t,i||null)},remove:t=>{const e=t.parentNode;e&&e.removeChild(t)},createElement:(t,e,i,r)=>{const n=e==="svg"?Nt.createElementNS(Tg,t):e==="mathml"?Nt.createElementNS(Lg,t):i?Nt.createElement(t,{is:i}):Nt.createElement(t);return t==="select"&&r&&r.multiple!=null&&n.setAttribute("multiple",r.multiple),n},createText:t=>Nt.createTextNode(t),createComment:t=>Nt.createComment(t),setText:(t,e)=>{t.nodeValue=e},setElementText:(t,e)=>{t.textContent=e},parentNode:t=>t.parentNode,nextSibling:t=>t.nextSibling,querySelector:t=>Nt.querySelector(t),setScopeId(t,e){t.setAttribute(e,"")},insertStaticContent(t,e,i,r,n,s){const o=i?i.previousSibling:e.lastChild;if(n&&(n===s||n.nextSibling))for(;e.insertBefore(n.cloneNode(!0),i),!(n===s||!(n=n.nextSibling)););else{Wc.innerHTML=Kc(r==="svg"?`<svg>${t}</svg>`:r==="mathml"?`<math>${t}</math>`:t);const a=Wc.content;if(r==="svg"||r==="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]}},Mg=Symbol("_vtc");function Dg(t,e,i){const r=t[Mg];r&&(e=(e?[e,...r]:[...r]).join(" ")),e==null?t.removeAttribute("class"):i?t.setAttribute("class",e):t.className=e}const Vc=Symbol("_vod"),jg=Symbol("_vsh"),Ug=Symbol(""),Fg=/(?:^|;)\s*display\s*:/;function Bg(t,e,i){const r=t.style,n=ge(i);let s=!1;if(i&&!n){if(e)if(ge(e))for(const o of e.split(";")){const a=o.slice(0,o.indexOf(":")).trim();i[a]==null&&En(r,a,"")}else for(const o in e)i[o]==null&&En(r,o,"");for(const o in i)o==="display"&&(s=!0),En(r,o,i[o])}else if(n){if(e!==i){const o=r[Ug];o&&(i+=";"+o),r.cssText=i,s=Fg.test(i)}}else e&&t.removeAttribute("style");Vc in t&&(t[Vc]=s?r.display:"",t[jg]&&(r.display="none"))}const Gc=/\s*!important$/;function En(t,e,i){if(W(i))i.forEach(r=>En(t,e,r));else if(i==null&&(i=""),e.startsWith("--"))t.setProperty(e,i);else{const r=qg(t,e);Gc.test(i)?t.setProperty(Ft(r),i.replace(Gc,""),"important"):t[r]=i}}const Yc=["Webkit","Moz","ms"],ko={};function qg(t,e){const i=ko[e];if(i)return i;let r=At(e);if(r!=="filter"&&r in t)return ko[e]=r;r=vl(r);for(let n=0;n<Yc.length;n++){const s=Yc[n]+r;if(s in t)return ko[e]=s}return e}const Qc="http://www.w3.org/1999/xlink";function Xc(t,e,i,r,n,s=Bp(e)){r&&e.startsWith("xlink:")?i==null?t.removeAttributeNS(Qc,e.slice(6,e.length)):t.setAttributeNS(Qc,e,i):i==null||s&&!Sl(i)?t.removeAttribute(e):t.setAttribute(e,s?"":Ut(i)?String(i):i)}function Jc(t,e,i,r,n){if(e==="innerHTML"||e==="textContent"){i!=null&&(t[e]=e==="innerHTML"?Kc(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=Sl(i):i==null&&a==="string"?(i="",o=!0):a==="number"&&(i=0,o=!0)}try{t[e]=i}catch{}o&&t.removeAttribute(n||e)}function Ri(t,e,i,r){t.addEventListener(e,i,r)}function Hg(t,e,i,r){t.removeEventListener(e,i,r)}const Zc=Symbol("_vei");function zg(t,e,i,r,n=null){const s=t[Zc]||(t[Zc]={}),o=s[e];if(r&&o)o.value=r;else{const[a,l]=Kg(e);if(r){const c=s[e]=Gg(r,n);Ri(t,a,c,l)}else o&&(Hg(t,a,o,l),s[e]=void 0)}}const eu=/(?:Once|Passive|Capture)$/;function Kg(t){let e;if(eu.test(t)){e={};let r;for(;r=t.match(eu);)t=t.slice(0,t.length-r[0].length),e[r[0].toLowerCase()]=!0}return[t[2]===":"?t.slice(3):Ft(t.slice(2)),e]}let Eo=0;const Wg=Promise.resolve(),Vg=()=>Eo||(Wg.then(()=>Eo=0),Eo=Date.now());function Gg(t,e){const i=r=>{if(!r._vts)r._vts=Date.now();else if(r._vts<=i.attached)return;yt(Yg(r,i.value),e,5,[r])};return i.value=t,i.attached=Vg(),i}function Yg(t,e){if(W(e)){const i=t.stopImmediatePropagation;return t.stopImmediatePropagation=()=>{i.call(t),t._stopped=!0},e.map(r=>n=>!n._stopped&&r&&r(n))}else return e}const tu=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)>96&&t.charCodeAt(2)<123,Qg=(t,e,i,r,n,s)=>{const o=n==="svg";e==="class"?Dg(t,r,o):e==="style"?Bg(t,i,r):Xr(e)?Ns(e)||zg(t,e,i,r,s):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):Xg(t,e,r,o))?(Jc(t,e,r),!t.tagName.includes("-")&&(e==="value"||e==="checked"||e==="selected")&&Xc(t,e,r,o,s,e!=="value")):t._isVueCE&&(/[A-Z]/.test(e)||!ge(r))?Jc(t,At(e),r,s,e):(e==="true-value"?t._trueValue=r:e==="false-value"&&(t._falseValue=r),Xc(t,e,r,o))};function Xg(t,e,i,r){if(r)return!!(e==="innerHTML"||e==="textContent"||e in t&&tu(e)&&V(i));if(e==="spellcheck"||e==="draggable"||e==="translate"||e==="autocorrect"||e==="sandbox"&&t.tagName==="IFRAME"||e==="form"||e==="list"&&t.tagName==="INPUT"||e==="type"&&t.tagName==="TEXTAREA")return!1;if(e==="width"||e==="height"){const n=t.tagName;if(n==="IMG"||n==="VIDEO"||n==="CANVAS"||n==="SOURCE")return!1}return tu(e)&&ge(i)?!1:e in t}const iu=t=>{const e=t.props["onUpdate:modelValue"]||!1;return W(e)?i=>en(e,i):e};function Jg(t){t.target.composing=!0}function ru(t){const e=t.target;e.composing&&(e.composing=!1,e.dispatchEvent(new Event("input")))}const $o=Symbol("_assign");function nu(t,e,i){return e&&(t=t.trim()),i&&(t=Us(t)),t}const Zg={created(t,{modifiers:{lazy:e,trim:i,number:r}},n){t[$o]=iu(n);const s=r||n.props&&n.props.type==="number";Ri(t,e?"change":"input",o=>{o.target.composing||t[$o](nu(t.value,i,s))}),(i||s)&&Ri(t,"change",()=>{t.value=nu(t.value,i,s)}),e||(Ri(t,"compositionstart",Jg),Ri(t,"compositionend",ru),Ri(t,"change",ru))},mounted(t,{value:e}){t.value=e??""},beforeUpdate(t,{value:e,oldValue:i,modifiers:{lazy:r,trim:n,number:s}},o){if(t[$o]=iu(o),t.composing)return;const a=(s||t.type==="number")&&!/^0\d/.test(t.value)?Us(t.value):t.value,l=e??"";a!==l&&(document.activeElement===t&&t.type!=="range"&&(r&&e===i||n&&t.value.trim()===l)||(t.value=l))}},ey=ke({patchProp:Qg},Ng);let su;function ty(){return su||(su=ig(ey))}const iy=((...t)=>{const e=ty().createApp(...t),{mount:i}=e;return e.mount=r=>{const n=ny(r);if(!n)return;const s=e._component;!V(s)&&!s.render&&!s.template&&(s.template=n.innerHTML),n.nodeType===1&&(n.textContent="");const o=i(n,!1,ry(n));return n instanceof Element&&(n.removeAttribute("v-cloak"),n.setAttribute("data-v-app","")),o},e});function ry(t){if(t instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&t instanceof MathMLElement)return"mathml"}function ny(t){return ge(t)?document.querySelector(t):t}const sy=1;var $n;(t=>{t.PackageLoader=new L(L.object({kind:L.union(["autoload","module","umd","styles"]).required().default("autoload"),entry:L.string(),styles:L.array(L.string()),main_export:L.string()})),t.Package=new L(L.object({id:L.string().required(),name:L.string().required(),version:L.string().required(),description:L.string(),author:L.string(),license:L.string(),loader:t.PackageLoader.required()})),t.RegistryMaintainer=new L(L.object({name:L.string().required(),email:L.string()})),t.RegistryRepository=new L(L.object({type:L.union(["git"]).required().default("git"),url:L.string().required()})),t.Registry=new L(L.object({manifest_version:L.number().min(sy).required(),name:L.string().required(),base_url:L.string().required(),homepage:L.string(),maintainers:L.array(t.RegistryMaintainer),repository:t.RegistryRepository,packages:L.array(t.Package).required()}))})($n||($n={}));const Po=Symbol("IPEInjectKey"),oy=(t,e)=>(e?e.provide(Po,t):hc(Po,t),t),ou=()=>{const t=dr(Po);if(!t)throw new Error("InPageEdit instance is not provided");return t},au=(t,...e)=>{const i=iy(...e);return oy(t,i),i};var ay=Object.create,Co=Object.defineProperty,ly=Object.getOwnPropertyDescriptor,lu=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),cu=t=>{throw TypeError(t)},cy=(t,e,i)=>e in t?Co(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,uy=(t,e)=>Co(t,"name",{value:e,configurable:!0}),fy=t=>[,,,ay(t?.[lu("metadata")]??null)],dy=["class","method","getter","setter","accessor","field","value","get","set"],uu=t=>t!==void 0&&typeof t!="function"?cu("Function expected"):t,hy=(t,e,i,r,n)=>({kind:dy[t],name:e,metadata:r,addInitializer:s=>i._?cu("Already initialized"):n.push(uu(s||null))}),py=(t,e)=>cy(e,lu("metadata"),t[3]),my=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},gy=(t,e,i,r,n,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(n=n.prototype,c<5&&(c>3||!u)&&ly(n,i));uy(n,i);for(var d=r.length-1;d>=0;d--)l=hy(c,i,a={},t[3],h),o=(0,r[d])(n,l),a._=1,uu(o)&&(n=o);return py(t,n),m&&Co(n,i,m),u?c^4?s:m:n},fu,Io,du;const hu=t=>{if(!t)return null;try{return t.split(".").reduce((e,i)=>e==null?e:e[i],globalThis)}catch{return null}},pu=(t,e,i)=>{if(/^https?:\/\//i.test(t))return t;const r=o=>o.endsWith("/")?o:o+"/";if(/^https?:\/\//i.test(e)){const o=r(e);return new URL(t,o).href}const n=(()=>{try{return new URL(i).href}catch{return new URL(i,location.origin).href}})(),s=new URL(r(e),n).href;return new URL(t,s).href};fu=[ve(["storage","preferences","resourceLoader"])];let Pn=(Gt=class extends(du=je){constructor(e){super(e,{},"plugin-store"),this.ctx=e,this.registryInfoDB=void 0,this._installedPlugins=new Map,this._registryUpdateCheckCaches=new Map,e.set("store",this),this.registryInfoDB=e.storage.createDatabase("plugin-store-registry",Gt.REGISTRY_CACHE_TTL,1)}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)}async _createManagementApp(){const e=await this.ctx.withInject(["store"]);return au(e,Om(()=>Promise.resolve().then(()=>Mw)))}async _injectPreferenceUI(){const e=this.ctx;e.preferences.defineCategory({name:"plugin-store",label:"Plugin Store",description:"Plugin Store",index:90,customRenderer:async({onUnmount:i})=>{const r=p("div",{id:"ipe-plugin-store-preferences-vue"}),n=await this._createManagementApp();return n.mount(r),i(()=>{n.unmount(),this.ctx.logger.debug("Plugin Store preferences app unmounted")}),p("section",{children:[r,p("div",{className:"theme-ipe-prose",children:[p("hr",{}),p("div",{style:{textAlign:"center",marginBottom:"1em",fontSize:"0.8em"},children:"🚫 DO NOT edit fields below manually 🚫"})]})]})}}),e.preferences.registerCustomConfig("plugin-store",L.object({"pluginStore.registries":L.array(L.string()).default([ti.PLUGIN_REGISTRY_URL]).description("Registry URLs"),"pluginStore.cdnForNpm":L.string().description("CDN to install packages from npm").default('https://cdn.jsdelivr.net/npm/{{ package }}{{ version ? "@" + version : "" }}'),"pluginStore.plugins":L.array(L.object({source:L.union(["online_manifest","npm"]).default("online_manifest"),registry:L.string().required(),id:L.string().required()})).description("Installed plugins").default([]).hidden()}),"plugin-store")}async showModal(){const e=this.ctx.modal.show({title:"Plugin Store",sizeClass:"small"}),i=p("section",{id:"ipe-plugin-store-vue"});e.setContent(i);const r=await this._createManagementApp();return r.mount(i),e.on(e.Event.Close,()=>{r.unmount()}),e}async install(e,i,r="online_manifest"){const n=await this.getRegistryInfo(e),s=`${e}:${i}`;if(this._installedPlugins.has(s))return await this._installedPlugins.get(s)??null;const o=this._installOneByRegistryInfo(e,n,i);return this._installedPlugins.set(s,o),await o}async uninstall(e,i){const r=this._installedPlugins.get(`${e}:${i}`);if(r===void 0)return!0;this._installedPlugins.delete(`${e}:${i}`);const n=await r;return n?n.dispose?.()??!0:!0}async addToPreferences(e,i){let r=await this.ctx.preferences.get("pluginStore.plugins")||[];return r.some(s=>s.registry===e&&s.id===i)||(r.push({registry:e,id:i}),await this.ctx.preferences.set("pluginStore.plugins",r)),!0}async removeFromPreferences(e,i){let r=await this.ctx.preferences.get("pluginStore.plugins")||[];return r=r.filter(n=>n.registry!==e||n.id!==i),await this.ctx.preferences.set("pluginStore.plugins",r),!0}async installAndSetPreference(e,i){return await this.addToPreferences(e,i),this.install(e,i)}async uninstallAndRemovePreference(e,i){return await this.removeFromPreferences(e,i),this.uninstall(e,i)}async _installOneByRegistryInfo(e,i,r){const n=i.base_url,s=i.packages.find(d=>d.id===r);if(!s)return this.ctx.logger.warn(`Package ${r} not found in registry ${e}`),null;const o=s.loader,{kind:a,entry:l="index.js",styles:c=[],main_export:u=null}=o;let f=null;if(a!=="styles"){if(!l)return this.ctx.logger.warn(`Entry url missing for ${r}`,o),null;try{f=pu(l,n,e)}catch(d){return this.ctx.logger.warn(`Failed to resolve entry "${l}" with base "${n}" and registry "${e}"`,d),null}}const h={"data-plugin-registry":e,"data-plugin-id":r};let m=null;switch(a){case"autoload":{m=this.ctx.plugin({inject:["resourceLoader"],name:`plugin-store-${e}-${r}`,apply:d=>{f&&d.resourceLoader.loadScript(f,{...h})}});break}case"module":{if(!f)return this.ctx.logger.warn(`Entry url missing for module kind, package ${r}`),null;const d=await import(f).then(_=>(u?_[u]:_.default)??_);if(!d)return this.ctx.logger.warn(`Main export ${u} not found in module ${f}`),null;m=this.ctx.plugin(d);break}case"umd":{let d=hu(u);if(!d){if(!f)return this.ctx.logger.warn(`Entry url missing for umd kind, package ${r}`),null;await this.ctx.resourceLoader.loadScript(f,{...h}),d=hu(u)}if(!d)return this.ctx.logger.warn(`Main export ${u} not found on globalThis after loading ${f}`),null;m=this.ctx.plugin(d);break}}if(c&&c.length>0){let d=[];try{d=c.map(_=>pu(_,n,e)).filter(Boolean)}catch(_){this.ctx.logger.warn(`Failed to resolve styles for ${r}`,c,_)}m||(m=this.ctx.plugin({name:`plugin-store-${e}-${r}`,apply(){}})),m.ctx.plugin({inject:["resourceLoader"],name:`plugin-store-${e}-${r}-styles`,apply:_=>{d.forEach(k=>_.resourceLoader.loadStyle(k,{...h})),_.on("dispose",()=>{try{d.forEach(k=>_.resourceLoader.removeStyle(k))}catch{}})}})}return m}validateRegistry(e){return $n.Registry(e)}async getRegistryInfo(e){const i=await this.getRegistryCache(e);if(i)return i;const r=await this._fetchOnlineRegistryInfo(e);return await this.setRegistryCache(e,r),r}async _fetchOnlineRegistryInfo(e){const r=await(await fetch(e)).json(),n=this.validateRegistry(r);return this.ctx.storage.simpleKV.set(`plugin-store-last-fetch/${e}`,Date.now()),n}async _checkIfOnlineRegistryUpdated(e){if(this._registryUpdateCheckCaches.has(e))return this._registryUpdateCheckCaches.get(e);const i=(async()=>{try{const n=await fetch(e,{method:"HEAD"});if(!n.ok)throw new Error(n.statusText,{cause:n});if(n.status===304)return this.ctx.logger.debug("Registry not modified:",e),!1;const s=n.headers.get("Last-Modified");if(s){const o=Date.parse(s);if(!isNaN(o))return!1;const a=await this.ctx.storage.simpleKV.get(`plugin-store-last-fetch/${e}`);return!a||o>a?(await this.ctx.storage.simpleKV.set(`plugin-store-last-fetch/${e}`,o),!0):!1}}catch(n){this.ctx.logger.warn("Failed to fetch registry HEAD for last-modified",e,n)}return!1})();return this._registryUpdateCheckCaches.set(e,i),await i}async getRegistryCache(e){const i=await this.registryInfoDB.get(e);if(i)try{return await this._checkIfOnlineRegistryUpdated(e)?(this.ctx.logger.debug("Registry updated online, ignoring cache:",e),this.deleteRegistryCache(e),null):this.validateRegistry(i)}catch(r){this.ctx.logger.warn("Invalid cached registry",r,i),this.registryInfoDB.delete(e)}return null}async setRegistryCache(e,i){return this.registryInfoDB.set(e,i)}async deleteRegistryCache(e){await Promise.all([this.registryInfoDB.delete(e),this.ctx.storage.simpleKV.delete(`plugin-store-last-fetch/${e}`)])}async clearAllRegistryCaches(){await Promise.all([this.registryInfoDB.clear(),this.ctx.storage.simpleKV.clear()]),this.ctx.logger.debug("All registry caches cleared")}async refreshRegistryCache(e){await this.deleteRegistryCache(e);const i=await this._fetchOnlineRegistryInfo(e);return await this.setRegistryCache(e,i),this.ctx.logger.debug("Registry cache refreshed:",e),i}async refreshAllRegistryCaches(){const e=await this.ctx.preferences.get("pluginStore.registries")||[],r=(await Promise.allSettled(e.map(n=>this.refreshRegistryCache(n)))).filter(n=>n.status==="fulfilled").map(n=>n.value);return this.ctx.logger.debug(`Refreshed ${r.length} registry caches`),r}},Gt.PluginStoreSchemas=$n,Gt.REGISTRY_CACHE_TTL=1e3*60*60*24,Gt);Io=fy(du),Pn=gy(Io,0,"PluginPluginStore",fu,Pn),my(Io,1,Pn);const yy=Object.freeze(Object.defineProperty({__proto__:null,PluginPluginStore:Pn},Symbol.toStringTag,{value:"Module"})),Ge='@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}';const mu={arrayAdd:"+",arrayMoveUp:"↑",arrayMoveDown:"↓",arrayRemove:"×",dictAdd:"+",dictRemove:"×",rootLabel:"root"},fe=(t,e)=>{customElements.get(t)||customElements.define(t,e)},by=(t,e,i)=>{if(!e.length)return;let r=t,n=null,s=null;for(let a=0;a<e.length-1;a++){const l=e[a];let c=r?.[l];c==null?(c=typeof e[a+1]=="number"?[]:{},r[l]=c):typeof c!="object"&&(c=typeof e[a+1]=="number"?[]:{},r[l]=c),n=r,s=l,r=c}const o=e[e.length-1];if(r==null||typeof r!="object"){const a=typeof o=="number"?[]:{};if(n)n[s]=a,r=a;else return}try{r[o]=i}catch{try{const a=Array.isArray(r)?r.slice():{...r};a[o]=i,n&&(n[s]=a)}catch{}}},br=t=>t.map(String).join("."),wy=t=>t.replace(/[^a-zA-Z0-9_-]/g,"_"),Wt=t=>`schema_${wy(br(t)||"root")}`,li=t=>br(t),Z=(t,...e)=>{const i=new Set(e);i.size&&t.setAttribute("part",Array.from(i).join(" "))},vy=["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 Ao(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 gu(t){return typeof t=="function"&&!!t?.type}function yu(t){if(!t)throw new Error("schema is required");if(gu(t))return t;try{const e=Schema.from(t);if(gu(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 it(t){return t?.meta??{}}function _y(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 r=e.type;try{const n=t();if(n!==void 0)return n}catch{}switch(r){case"string":return"";case"number":case"natural":case"percent":return 0;case"boolean":return!1;case"array":return[];case"tuple":return[];case"object":return{};case"dict":return{};case"union":{const n=e.list||[];return n.length?ci(n[0]):void 0}case"const":return e.value;case"date":return;case"intersect":{const n=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 n)o=s(o,ci(a));return o}default:return}}class ut extends HTMLElement{constructor(){super(),this._path=[],this._i18n=mu,this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=Ge,this.$root.appendChild(e)}makeFieldContainer(e,i){const r=document.createElement("div");if(r.className=`field schema-form-item schema-type-${e}`,r.setAttribute("data-path",br(this._path)),Z(r,"field",`field-${e}`),this._label){const n=document.createElement("label");n.className="label",n.textContent=this._label,Z(n,"field-label"),r.appendChild(n)}if(i&&i!==this._label){const n=document.createElement("div");n.className="helper",n.textContent=i,Z(n,"field-helper"),r.appendChild(n)}return r}set schema(e){this._schema=yu(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 bu extends ut{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>${Ge}</style>`;const e=it(this._schema),i=this.makeFieldContainer("string",e.description),r=document.createElement("input");this.$input=r,r.className="input",Z(r,"field-input","field-input-text"),r.type="text",r.name=li(this._path),r.id=Wt(this._path),e?.pattern?.source&&(r.pattern=e.pattern.source),e?.max!=null&&(r.maxLength=e.max),r.value=this._value??"",r.oninput=()=>this.emitChange(Ao("string",r.value));const n=i.querySelector("label.label");n&&(n.htmlFor=r.id),i.appendChild(r),this.$root.appendChild(i)}}fe("schema-form-string",bu);class wu extends ut{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>${Ge}</style>`;const e=this._schema?.type??"number",i=it(this._schema),r=this.makeFieldContainer("number",i.description),n=document.createElement("input");this.$input=n,n.className="input",Z(n,"field-input","field-input-number"),n.name=li(this._path),n.id=Wt(this._path),i?.min!=null&&(n.min=String(i.min)),i?.max!=null&&(n.max=String(i.max)),i?.step!=null&&(n.step=String(i.step)),e==="percent"&&!n.step&&(n.step="0.01"),n.value=this._value??"",n.oninput=()=>this.emitChange(Ao(e,n.value));const s=r.querySelector("label.label");s&&(s.htmlFor=n.id),i.role==="slider"?n.type="range":n.type="number",r.appendChild(n),this.$root.appendChild(r)}}fe("schema-form-number",wu);class vu extends ut{render(){this.$root.innerHTML=`<style>${Ge}</style>`;const e=it(this._schema),i=this.makeFieldContainer("boolean",e.description),r=document.createElement("label");r.className="checkbox",Z(r,"field-checkbox");const n=document.createElement("input");n.type="checkbox",n.checked=!!this._value,n.name=li(this._path),n.id=Wt(this._path),Z(n,"field-input","field-input-checkbox");const s=document.createElement("span");s.textContent=e.description??this._label??"",Z(s,"field-checkbox-text"),n.onchange=()=>this.emitChange(n.checked);const o=i.querySelector("label.label");o&&(o.htmlFor=n.id),r.append(n,s),i.appendChild(r),this.$root.appendChild(i)}}fe("schema-form-boolean",vu);function Cn(t){return String(t).padStart(2,"0")}function wr(t){return`${t.getFullYear()}-${Cn(t.getMonth()+1)}-${Cn(t.getDate())}`}function Oo(t){return`${Cn(t.getHours())}:${Cn(t.getMinutes())}`}function In(t){return`${wr(t)}T${Oo(t)}`}class _u extends ut{render(){if(this.$input&&this.$root.contains(this.$input)){const o=!!this.$root.querySelector("label.label");if(!(this._label&&!o)){const a=it(this._schema).role||"date";if(document.activeElement!==this.$input)if(this._value instanceof Date)a==="date"?this.$input.value=wr(this._value):a==="time"?this.$input.value=Oo(this._value):a==="datetime"&&(this.$input.value=In(this._value));else if(typeof this._value=="string"&&a!=="time"){const l=new Date(this._value);isNaN(+l)||(a==="date"?this.$input.value=wr(l):a==="datetime"&&(this.$input.value=In(l)))}else this._value||(this.$input.value="");return}}this.$root.innerHTML=`<style>${Ge}</style>`;const e=it(this._schema),i=this.makeFieldContainer("date",e.description),r=document.createElement("input");this.$input=r,r.className="input",Z(r,"field-input","field-input-date");const n=e.role||"date";if(n==="datetime"?r.type="datetime-local":n==="time"?r.type="time":r.type="date",r.name=li(this._path),r.id=Wt(this._path),this._value instanceof Date)n==="date"?r.value=wr(this._value):n==="time"?r.value=Oo(this._value):n==="datetime"&&(r.value=In(this._value));else if(typeof this._value=="string"&&n!=="time"){const o=new Date(this._value);isNaN(+o)||(n==="date"?r.value=wr(o):n==="datetime"&&(r.value=In(o)))}r.oninput=()=>{e.role;let o;if(!r.value)o=void 0;else{const a=new Date(r.value);o=Number.isNaN(+a)?void 0:a}this.emitChange(o)};const s=i.querySelector("label.label");s&&(s.htmlFor=r.id),i.appendChild(r),this.$root.appendChild(i)}}fe("schema-form-date",_u);class Ro extends ut{render(){this.$root.innerHTML=`<style>${Ge}</style>`;const e=it(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),Z(o,"field-const-value"),this.$root.appendChild(o);return}}const r=this.makeFieldContainer("const",e.description),n=document.createElement("section");n.className="const content",n.textContent=String(i),n.id=Wt(this._path),Z(n,"field-const-value");const s=r.querySelector("label.label");s&&(s.htmlFor=n.id),r.appendChild(n),this.$root.appendChild(r)}}fe("schema-form-const",Ro);class xu extends ut{render(){this.$root.innerHTML=`<style>${Ge}</style>`;const e=it(this._schema),i=this.makeFieldContainer("intersect",e.description);i.classList.remove("field");const r=document.createElement("div");r.classList.add("group"),Z(r,"field-group");const n=this._schema.list||[],s=n.length>0&&n.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:{};n.forEach((l,c)=>{const u=l?.meta?.description??"",f=Vt(l,this._path,a,u,this._i18n);f.addEventListener("change",h=>{h.stopPropagation();const m=o(this._value??{},h.detail.value);this.emitChange(m)}),r.appendChild(f)})}else{const a=n[n.length-1],l=Vt(a,this._path,this._value,this._label,this._i18n);l.addEventListener("change",c=>{c.stopPropagation(),this.emitChange(c.detail.value)}),r.appendChild(l)}i.appendChild(r),this.$root.appendChild(i)}}fe("schema-form-intersect",xu);function xy(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 Vt(t,e,i,r,n){const s=xy(t),o=document.createElement(s);return o.schema=t,o.path=e,o.label=r,n&&(o.i18n=n),o.setValue?.(i),o.setAttribute("exportparts",vy),o}class Su extends ut{render(){this.$root.innerHTML=`<style>${Ge}</style>`;const e=it(this._schema),i=this.makeFieldContainer("union",e.description),r=this._schema.list||[];if(_y(r)){const n=document.createElement("select");n.className="input",Z(n,"field-input","field-input-select"),n.name=li(this._path),n.id=Wt(this._path),r.forEach(o=>{const a=document.createElement("option");a.value=String(o.value),a.textContent=String(o.meta?.description||o.value||o.type),this._value===o.value&&(a.selected=!0),n.appendChild(a)}),n.onchange=()=>this.emitChange(Ao("string",n.value));const s=i.querySelector("label.label");s&&(s.htmlFor=n.id),i.appendChild(n)}else{const n=document.createElement("div");n.className="toolbar",Z(n,"field-toolbar");const s=document.createElement("select");s.className="input",Z(s,"field-input","field-input-select","field-toolbar-select"),s.name=li(this._path)+".__type",s.id=Wt(this._path)+"__type";let o=0;r.forEach((u,f)=>{const h=document.createElement("option");h.value=String(f),h.textContent=String(u.meta?.description||u.value||u.type),s.appendChild(h)}),s.onchange=()=>{o=Number(s.value);const u=r[o],f=ci(u);this.emitChange(f),c()};const a=i.querySelector("label.label");a&&(a.htmlFor=s.id),n.appendChild(s),i.appendChild(n);const l=document.createElement("div");l.className="group",Z(l,"field-group");const c=()=>{l.innerHTML="";const u=r[o],f=Vt(u,this._path,this._value,this._label);f instanceof Ro||(f.addEventListener("change",h=>{h.stopPropagation(),this.emitChange(h.detail.value)}),l.appendChild(f))};c(),i.appendChild(l)}this.$root.appendChild(i)}}fe("schema-form-union",Su);class ku extends ut{render(){this.$root.innerHTML=`<style>${Ge}</style>`;const e=it(this._schema),i=this.makeFieldContainer("tuple",e.description),r=document.createElement("div");r.className="group",Z(r,"field-group");const n=Array.isArray(this._value)?this._value:[];(this._schema.list||[]).forEach((s,o)=>{const a=Vt(s,[...this._path,o],n[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)}),r.appendChild(a)}),i.appendChild(r),this.$root.appendChild(i)}}fe("schema-form-tuple",ku);class Eu extends ut{render(){this.$root.innerHTML=`<style>${Ge}</style>`;const e=it(this._schema),i=this.makeFieldContainer("object",e.description),r=document.createElement("div");r.className="group",Z(r,"field-group");const n=this._schema.dict||{};Object.keys(n).forEach(s=>{if(n[s]?.meta?.hidden)return;const o=(this._value??{})[s],a=Vt(n[s],[...this._path,s],o,s);a.addEventListener("change",l=>{l.stopPropagation();const c={...this._value??{}};c[s]=l.detail.value,this.emitChange(c)}),r.appendChild(a)}),i.appendChild(r),this.$root.appendChild(i)}}fe("schema-form-object",Eu);const Hn=class Hn extends ut{constructor(){super(...arguments),this._itemIds=[]}generateItemId(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return"i"+Hn._idCounter++}ensureItemIds(e){for(;this._itemIds.length<e;)this._itemIds.push(this.generateItemId());this._itemIds.length>e&&(this._itemIds.length=e)}capturePositions(e){const i={};return e.querySelectorAll(".row").forEach(r=>{const n=r.dataset.uid;n&&(i[n]=r.getBoundingClientRect())}),i}playFLIP(e,i){Array.from(e.querySelectorAll(".row")).forEach(r=>{const n=r.dataset.uid;if(!n)return;const s=i[n];if(!s)return;const o=r.getBoundingClientRect(),a=s.left-o.left,l=s.top-o.top;(a||l)&&(r.style.transition="none",r.style.transform=`translate(${a}px, ${l}px)`,requestAnimationFrame(()=>{r.style.transition="transform .25s ease",r.style.transform=""}))})}render(){this.$root.innerHTML=`<style>${Ge}</style>`;const e=it(this._schema),i=this.makeFieldContainer("array",e.description),r=document.createElement("div");r.className="group",Z(r,"field-group");const n=this._schema.inner,s=()=>Array.isArray(this._value)?this._value:[];this.ensureItemIds(s().length);const o=(c,u)=>{r.innerHTML="",s().forEach((f,h)=>{const m=[...this._path,h],d=document.createElement("div");d.className="row schema-collection-row",Z(d,"field-row","collection-row");const _=this._itemIds[h];d.dataset.uid=_,d.setAttribute("data-path",br(m));const k=Vt(n,m,f,`${this._label??""}[${h}]`);k.addEventListener("change",w=>{w.stopPropagation();const S=s().slice();S[h]=w.detail.value,this._value=S,this.emitChange(S)});const E=document.createElement("div");E.className="actions",Z(E,"field-actions");const x=document.createElement("button");x.type="button",x.className="btn",Z(x,"field-button","field-button-secondary"),x.textContent=this._i18n.arrayMoveUp??"↑",x.onclick=()=>{if(h<=0)return;const w=this.capturePositions(r),S=s().slice();[S[h-1],S[h]]=[S[h],S[h-1]],[this._itemIds[h-1],this._itemIds[h]]=[this._itemIds[h],this._itemIds[h-1]],this._value=S,o(w),this.emitChange(S)};const y=document.createElement("button");y.type="button",y.className="btn",Z(y,"field-button","field-button-secondary"),y.textContent=this._i18n.arrayMoveDown??"↓",y.onclick=()=>{const w=s();if(h>=w.length-1)return;const S=this.capturePositions(r),C=w.slice();[C[h+1],C[h]]=[C[h],C[h+1]],[this._itemIds[h+1],this._itemIds[h]]=[this._itemIds[h],this._itemIds[h+1]],this._value=C,o(S),this.emitChange(C)};const g=document.createElement("button");g.type="button",g.className="btn danger",Z(g,"field-button","field-button-danger"),g.textContent=this._i18n.arrayRemove??"×",g.onclick=()=>{d.classList.add("leaving");const w=250;let S=!1;const C=()=>{if(S)return;S=!0,clearTimeout(T);const B=s().filter((Yt,Ui)=>Ui!==h);this._itemIds.splice(h,1);const Y=this.capturePositions(r);this._value=B,o(Y),this.emitChange(B)};d.addEventListener("transitionend",C,{once:!0});const T=setTimeout(C,w+80)},E.append(x,y,g),d.appendChild(k),d.appendChild(E),r.appendChild(d),u&&u===_&&(d.classList.add("enter"),requestAnimationFrame(()=>{d.classList.add("enter-active")}),requestAnimationFrame(()=>{d.classList.remove("enter")}))}),c&&this.playFLIP(r,c)};o();const a=document.createElement("button");a.type="button",a.className="btn primary",Z(a,"field-button","field-button-primary"),a.textContent=this._i18n.arrayAdd??"+",a.onclick=()=>{const c=this.capturePositions(r),u=s().slice(),f=ci(n);u.push(f);const h=this.generateItemId();this._itemIds.push(h),this._value=u,o(c,h),this.emitChange(u)};const l=document.createElement("div");l.className="actions",Z(l,"field-actions"),l.appendChild(a),i.appendChild(r),i.appendChild(l),this.$root.appendChild(i)}};Hn._idCounter=0;let An=Hn;fe("schema-form-array",An);class $u extends ut{render(){this.$root.innerHTML=`<style>${Ge}</style>`;const e=it(this._schema),i=this.makeFieldContainer("dict",e.description),r=document.createElement("div");r.className="group",Z(r,"field-group");const n=this._schema.inner,s=this._value??{},o=h=>`d_${h}`,a=()=>{const h={};return r.querySelectorAll(".kv").forEach(m=>{const d=m.dataset.uid;d&&(h[d]=m.getBoundingClientRect())}),h},l=h=>{r.querySelectorAll(".kv").forEach(m=>{const d=m.dataset.uid;if(!d)return;const _=h[d];if(!_)return;const k=m.getBoundingClientRect(),E=_.left-k.left,x=_.top-k.top;(E||x)&&(m.style.transition="none",m.style.transform=`translate(${E}px, ${x}px)`,requestAnimationFrame(()=>{m.style.transition="transform .25s ease",m.style.transform=""}))})},c=(h,m)=>{r.innerHTML="",Object.keys(s).forEach(d=>{const _=[...this._path,d],k=document.createElement("div");k.className="kv schema-collection-row",Z(k,"field-row","collection-row"),k.dataset.uid=o(d),k.setAttribute("data-path",br(_));const E=document.createElement("input");E.className="input",Z(E,"field-input","field-input-text"),E.value=d,E.name=li(_)+".__key",E.id=Wt(_)+"__key";const x=Vt(n,_,s[d],`${this._label??""}[${d}]`),y=document.createElement("button");y.type="button",y.className="btn danger",Z(y,"field-button","field-button-danger"),y.textContent=this._i18n.dictRemove??"×",y.onclick=()=>{const g=a();delete s[d];const w={...this._value??{}};delete w[d],this._value=w,c(g),this.emitChange(w)},E.onchange=()=>{const g=E.value.trim();if(!g||g===d||s[g]!==void 0)return;const w=a();s[g]=s[d],delete s[d];const S={...this._value??{}};S[g]=S[d],delete S[d],this._value=S,c(w),this.emitChange(S)},x.addEventListener("change",g=>{g.stopPropagation();const w={...this._value??{}};w[d]=g.detail.value,this._value=w,this.emitChange(w)}),k.append(E,x,y),r.appendChild(k),m===d&&(k.classList.add("enter"),requestAnimationFrame(()=>k.classList.add("enter-active")),requestAnimationFrame(()=>k.classList.remove("enter")))}),h&&l(h)};c();const u=document.createElement("button");u.type="button",u.className="btn primary",Z(u,"field-button","field-button-primary"),u.textContent=this._i18n.dictAdd??"+",u.onclick=()=>{let h=Object.keys(s).length+1,m=`k${h}`;for(;s[m]!==void 0;)m=`k${++h}`;const d=a();s[m]=ci(n);const _={...this._value??{},[m]:s[m]};this._value=_,c(d,m),this.emitChange(_)};const f=document.createElement("div");f.className="actions",Z(f,"field-actions"),f.appendChild(u),i.appendChild(r),i.appendChild(f),this.$root.appendChild(i)}}fe("schema-form-dict",$u);class Pu extends HTMLElement{constructor(){super(),this._i18n={...mu},this._i18nCommitted=!1,this.$root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=Ge,this.$root.appendChild(e);const i=document.createElement("div");i.className="wrapper",Z(i,"wrapper");const r=document.createElement("form");r.className="form",Z(r,"form"),i.appendChild(r),this.$root.appendChild(i),this.addEventListener("change",n=>{if(!n?.detail)return;const{path:s,value:o}=n.detail;Array.isArray(s)&&s.length===0?this._state=o:by(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=yu(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 r=i.validate?this._schema(e??null,{autofix:i.autofix}):e;this._state=r,this.render()}getData(e={validate:!0,autofix:!0}){if(!this._schema)throw new Error("请先设置 schema");const i=this._state;return e.validate?this._schema(i??null,{autofix:e.autofix}):i}reset(){try{this._state=this._schema(null,{autofix:!0})}catch{this._state=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=Vt(this._schema,[],this._state,this._i18n.rootLabel,this._i18n);e.appendChild(i)}}fe("schema-form",Pu);function Sy(){fe("schema-form",Pu),fe("schema-form-string",bu),fe("schema-form-number",wu),fe("schema-form-boolean",vu),fe("schema-form-date",_u),fe("schema-form-const",Ro),fe("schema-form-union",Su),fe("schema-form-tuple",ku),fe("schema-form-object",Eu),fe("schema-form-array",An),fe("schema-form-dict",$u),fe("schema-form-intersect",xu)}const ky=pn({__name:"SchemasteryFormVue",props:oc({schema:{},value:{},validateOnChange:{type:Boolean,default:!1}},{schema:{required:!0},schemaModifiers:{},value:{required:!1,default:{}},valueModifiers:{}}),emits:oc(["change"],["update:schema","update:value"]),setup(t,{expose:e,emit:i}){const r=Pc(t,"schema"),n=Pc(t,"value"),s=i,o=ec("elRef");let a=!1,l=!1;const c=u=>{if(l)return;const f=o.value,h=t.validateOnChange?f.getData({validate:!0}):u.detail.state;a=!0,n.value=h,or(()=>{a=!1}),s("change",u.detail)};return nc(()=>{Sy()}),Pi(()=>{const u=o.value;r.value&&(u.schema=r.value),n.value!==void 0&&u.setData(n.value,{validate:!1,autofix:!0}),u.addEventListener("form-change",c)}),ao(()=>{o.value?.removeEventListener("form-change",c)}),Ii(r,u=>{a||o.value&&u&&o.value.schema!==u&&(l=!0,o.value.schema=u,or(()=>{l=!1}))},{deep:!0,immediate:!0}),Ii(n,u=>{if(a||!o.value||u===void 0)return;const f=o.value.getData({validate:!1});JSON.stringify(f)!==JSON.stringify(u)&&(l=!0,o.value.setData(u,{validate:!1}),or(()=>{l=!1}))},{deep:!0,immediate:!0}),e({setData(u,f){const h=o.value;h.setData(u,{validate:!!f?.validate}),f?.emit&&(n.value=h.getData({validate:!!f?.validate}))},getData(u){return o.value.getData(u)},setSchema(u,f=!0){o.value.schema=u,f&&(r.value=u)},refresh(){o.value.refresh()},reset(){o.value.reset()},el:o}),(u,f)=>(_e(),$e("schema-form",jc({ref_key:"elRef",ref:o},u.$attrs),null,16))}});function ui(t,e=new WeakMap){if(Se(t))return ui(t.value,e);if(t===null||typeof t!="object")return t;if(e.has(t))return e.get(t);if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if(t instanceof Map){const n=new Map;return e.set(t,n),Array.from(t.entries()).forEach(([s,o])=>{n.set(s,ui(o,e))}),n}if(t instanceof Set){const n=new Set;return e.set(t,n),Array.from(t).forEach(s=>{n.add(ui(s,e))}),n}if(Array.isArray(t)){const n=[];e.set(t,n);for(const s of t)n.push(ui(s,e));return n}const i=te(t),r={};e.set(t,r);for(const n of Object.keys(i))r[n]=ui(i[n],e);for(const n of Object.getOwnPropertySymbols(i))r[n]=ui(i[n],e);return r}const On=()=>{},Ey={id:"preferences-ui-app"},$y={class:"tabbar"},Py={class:"tabbar-tabs"},Cy=["onClick","data-value"],Iy={class:"tabbar-content"},Ay={key:0},Oy={style:{"max-height":"20em",overflow:"auto"}},Ry=pn({__name:"PreferencesApp",setup(t,{expose:e}){const i=ou(),r=!1,n=zl([]),s=lt([]),o=lt(""),a=yr(()=>s.value.find(d=>d.name===o.value)||null),l=yr(()=>{const d=n.value.filter(_=>_.category===o.value).map(_=>_.schema);return d.length===0?null:L.intersect(d)}),c=yr(()=>a.value&&typeof a.value.autoGenerateForm=="boolean"?a.value.autoGenerateForm:!0),u=lt({});e({getValue(){return ui(u)},mergeValue(d){u.value={...u.value,...d}},selectTab(d){o.value=d}}),Pi(async()=>{i.inject(["preferences"],async d=>{const _=await d.preferences.getAll();u.value=_,s.value=d.preferences.getConfigCategories(),n.value=d.preferences.getConfigRegistries(),o.value=s.value[0].name})});const f=(d,_)=>{d.preventDefault(),o.value=_;const k=d.currentTarget;k&&k.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},h=ec("customRenderContainerRef"),m=lt([]);return lo(()=>{m.value.forEach(d=>d()),m.value=[]}),Ii(a,async d=>{m.value.forEach(k=>k()),m.value=[],await or();const _=h.value;if(_&&(_.innerText="",d&&typeof d.customRenderer=="function")){let k=On;const E=g=>{k=g},x=g=>{m.value.push(g)},y=await d.customRenderer({ctx:i,onMounted:E,onUnmount:x});y&&(_.appendChild(y),k?.(_))}},{immediate:!0,deep:!1}),(d,_)=>(_e(),$e("div",Ey,[de("div",$y,[de("div",Py,[(_e(!0),$e(ct,null,sc(s.value,k=>(_e(),$e("a",{class:ri(["tab",{active:o.value===k.name}]),key:k.name,onClick:E=>f(E,k.name),"data-value":k.name},Je(k.label),11,Cy))),128))]),de("div",Iy,[a.value&&a.value.customRenderer?(_e(),$e("div",{class:"custom-render-container",ref_key:"customRenderContainerRef",ref:h,key:o.value})):zt("",!0),c.value&&l.value?(_e(),Nc(to(ky),{class:"auto-schema-form",key:o.value,"data-category":o.value,schema:l.value,value:u.value,"onUpdate:value":_[0]||(_[0]=k=>u.value={...u.value,...k}),"validate-on-change":!1,i18n:{rootLabel:""}},null,8,["data-category","schema","value"])):zt("",!0)])]),to(r)?(_e(),$e("details",Ay,[de("pre",Oy,Je(u.value),1)])):zt("",!0)]))}}),Cu=(t,e)=>{const i=t.__vccOpts||t;for(const[r,n]of e)i[r]=n;return i},Ty=Cu(Ry,[["__scopeId","data-v-7f07706b"]]);var Ly=Object.create,To=Object.defineProperty,Ny=Object.getOwnPropertyDescriptor,Iu=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Au=t=>{throw TypeError(t)},My=(t,e,i)=>e in t?To(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Dy=(t,e)=>To(t,"name",{value:e,configurable:!0}),jy=t=>[,,,Ly(t?.[Iu("metadata")]??null)],Uy=["class","method","getter","setter","accessor","field","value","get","set"],Ou=t=>t!==void 0&&typeof t!="function"?Au("Function expected"):t,Fy=(t,e,i,r,n)=>({kind:Uy[t],name:e,metadata:r,addInitializer:s=>i._?Au("Already initialized"):n.push(Ou(s||null))}),By=(t,e)=>My(e,Iu("metadata"),t[3]),qy=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Hy=(t,e,i,r,n,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(n=n.prototype,c<5&&(c>3||!u)&&Ny(n,i));Dy(n,i);for(var d=r.length-1;d>=0;d--)l=Fy(c,i,a={},t[3],h),o=(0,r[d])(n,l),a._=1,Ou(o)&&(n=o);return By(t,n),m&&To(n,i,m),u?c^4?s:m:n},Ru,Lo,Tu;Ru=[ve(["preferences","modal"])];class Rn extends(Tu=je){constructor(e){super(e,{},"preferences-ui"),this.ctx=e,this._modal=null,this._form=null,e.set("preferencesUI",this),e.preferences.defineCategory({name:"about",label:"About",description:"About InPageEdit",index:99,customRenderer:()=>p("section",{className:"theme-ipe-prose",children:[p("h2",{children:"✏️ InPageEdit NEXT"}),p("p",{children:"🚀 Modular, Extensible Supercharged Plugin for MediaWiki."}),p("h3",{children:"Portals"}),p("ul",{children:[p("li",{children:p("a",{href:this.ctx.Endpoints.HOME_URL,target:"_blank",children:"Official Website & Help Center"})}),p("li",{children:p("a",{href:`${this.ctx.Endpoints.UPDATE_LOGS_URL}#${this.ctx.version.split("-")[0]}`,target:"_blank",children:"Update Logs"})})]}),p("h3",{children:"Join us"}),p("ul",{children:[p("li",{children:[p("strong",{children:"GitHub"}),":"," ",p("a",{href:this.ctx.Endpoints.GITHUB_URL,target:"_blank",children:"inpageedit/inpageedit-next"})]}),p("li",{children:[p("strong",{children:"QQ Group"}),": 1026023666"]})]}),p("hr",{}),p("p",{style:{textAlign:"center"},children:["InPageEdit-NEXT Copyright © 2025-",new Date().getFullYear()," dragon-fish"]}),p("hr",{})]})}),e.inject(["toolbox"],i=>{i.toolbox.addButton({id:"preferences",icon:p("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:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("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:"Configure Preferences",group:"group2",index:99,onClick:()=>this.showModal()}),this.addDisposeHandler(r=>{r.toolbox.removeButton("preferences")})})}async start(){Promise.resolve().then(()=>Gw).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(){if(this._modal&&!this._modal.isDestroyed)return this._modal;const e=this.ctx.modal.show({className:"ipe-preference compact-buttons",sizeClass:"small",outSideClose:!1,center:!0,title:`InPageEdit Preferences (${this.ctx.version})`,content:p(Ct,{children:p(jt,{})})});e.get$window().classList.add("dialog");const i=p("div",{id:"ipe-preferences-app",style:{minHeight:"calc(85dvh - var(--ipe-modal-spacing) * 2)"}});e.setContent(i),this.ctx.emit("preferences-ui/modal-shown",{ctx:this.ctx,modal:e});const r=this.createPreferencesUIApp(),n=r.mount(i);return this._form=n,this.ctx.emit("preferences-ui/vue-app-mounted",{ctx:this.ctx,app:r,form:n}),e.setButtons([{label:"Close",className:"is-ghost",method:()=>{e.close()}},{label:"Save",className:"is-primary is-ghost",method:async()=>{const s=n.getValue();try{const o=await this.ctx.preferences.setMany(s);this.logger.info("preferences saved",s,o)}catch(o){this.logger.error("failed to save preferences",o)}e.close(),this.ctx.modal.notify("success",{title:"Preferences Saved",content:p("p",{children:"Some settings may take effect after reloading the page."})})}}]),this._modal=e,e.on(e.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:e})}),e}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 au(this.ctx,Ty)}}Lo=jy(Tu),Rn=Hy(Lo,0,"PluginPreferencesUI",Ru,Rn),qy(Lo,1,Rn);const zy=Object.freeze(Object.defineProperty({__proto__:null,get PluginPreferencesUI(){return Rn}},Symbol.toStringTag,{value:"Module"})),Ky=Symbol("@@apply"),Wy=Symbol("@@ctor");function No(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[Ky]=i,i[Wy]=t;const r=t?.constructor?.name;return r&&(i[Symbol.toStringTag]=r),new Proxy(i,{get(s,o,a){return o==="prototype"?Reflect.get(i,o,a):Reflect.get(t,o,t)},set(s,o,a){return Reflect.set(t,o,a)},has(s,o){return Reflect.has(t,o)},deleteProperty(s,o){return Reflect.deleteProperty(t,o)},ownKeys(){return Reflect.ownKeys(t)},getOwnPropertyDescriptor(s,o){return Object.getOwnPropertyDescriptor(t,o)},defineProperty(s,o,a){return Object.defineProperty(t,o,a)}})}const Tn={mbox:"_mbox_5x43w_1",title:"_title_5x43w_12",content:"_content_5x43w_19",close:"_close_5x43w_27"},vr=t=>{const{type:e="default",title:i,content:r,closeable:n=!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(!f)return Promise.resolve();const{promise:h,resolve:m}=Promise.withResolvers();return f.animate([{opacity:"1",height:f.clientHeight+"px"},{opacity:"0",height:"0px",margin:"0px"}],{duration:300,easing:"ease"}).addEventListener("finish",()=>{f.remove(),m()}),h},f=p("div",{className:`theme-ipe ipe-mbox mbox-type-${e||"default"} ${Tn.mbox}`,...l,children:[c&&p("div",{className:`ipe-mbox-title ${Tn.title}`,...s,children:c}),p("div",{className:`ipe-mbox-content ${Tn.content}`,...o,children:a||r}),n&&p("a",{onClick:u,className:`ipe-mbox-close ${Tn.close}`,children:"×"})]});return f.close=u,f},_r=t=>{const{label:e,id:i,name:r,value:n,disabled:s,labelProps:o,inputProps:a,...l}=t;return p("div",{className:"theme-ipe ipe-input-box",...l,children:[p("label",{htmlFor:i,style:{display:"block"},...o,children:e}),p("input",{id:i,name:r,value:n,disabled:s,style:{width:"100%"},...a})]})},Vy=t=>{const{id:e,name:i,value:r,label:n,inputProps:s,labelProps:o,children:a,...l}=t;return p("label",{className:"theme-ipe ipe-radio-box",...l,children:[p("input",{type:"radio",id:e,name:i,value:r,...s}),p("span",{className:"ipe-checkbox-box"}),p("span",{...o,children:n||a})]})},Ti=t=>{const{id:e,name:i,label:r,checked:n,inputProps:s,labelProps:o,children:a,...l}=t;return p("label",{className:"theme-ipe ipe-checkbox",...l,children:[p("input",{type:"checkbox",id:e,name:i,checked:n,...s}),p("span",{className:"ipe-checkbox-box"}),p("span",{...o,children:r||a})]})},Gy=(t=0)=>new Promise(e=>setTimeout(e,t));var Yy=Object.create,Mo=Object.defineProperty,Qy=Object.getOwnPropertyDescriptor,Lu=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Nu=t=>{throw TypeError(t)},Xy=(t,e,i)=>e in t?Mo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Jy=(t,e)=>Mo(t,"name",{value:e,configurable:!0}),Zy=t=>[,,,Yy(t?.[Lu("metadata")]??null)],eb=["class","method","getter","setter","accessor","field","value","get","set"],Mu=t=>t!==void 0&&typeof t!="function"?Nu("Function expected"):t,tb=(t,e,i,r,n)=>({kind:eb[t],name:e,metadata:r,addInitializer:s=>i._?Nu("Already initialized"):n.push(Mu(s||null))}),ib=(t,e)=>Xy(e,Lu("metadata"),t[3]),rb=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},nb=(t,e,i,r,n,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(n=n.prototype,c<5&&(c>3||!u)&&Qy(n,i));Jy(n,i);for(var d=r.length-1;d>=0;d--)l=tb(c,i,a={},t[3],h),o=(0,r[d])(n,l),a._=1,Mu(o)&&(n=o);return ib(t,n),m&&Mo(n,i,m),u?c^4?s:m:n},Du,Do,ju;Du=[ve(["api","wikiPage","wikiTitle","currentPage","wiki","modal","preferences"]),ii(L.object({"quickEdit.editSummary":L.string().description("Default edit summary for quick edits").default("[IPE-NEXT] Quick edit"),"quickEdit.editMinor":L.boolean().description('Default to checking "minor edit" option').default(!1),"quickEdit.outSideClose":L.boolean().description("Close editor modal by clicking outside").default(!0),"quickEdit.watchList":L.union([L.const(Xe.preferences).description("Follow MW preferences"),L.const(Xe.nochange).description("Keep the current watchlist status"),L.const(Xe.watch).description("Add the page to watchlist"),L.const(Xe.unwatch).description("Remove the page from watchlist")]).description("Watchlist options").default(Xe.preferences),"quickEdit.keyshortcut.save":L.string().default("ctrl-s").description("save button key shortcut (blank to disable)"),"quickEdit.editFont":L.union([L.const("preferences").description("Follow MW preferences"),L.const("monospace").description("Monospace"),L.const("sans-serif").description("Sans-serif"),L.const("serif").description("Serif"),L.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 Ln=(di=class extends(ju=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",No(this,"showModal"))}start(){this.ctx.inject(["toolbox"],e=>{this.injectToolbox(e),e.on("dispose",()=>{this.removeToolbox(e)})})}async showModal(e){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 x=new URLSearchParams(window.location.search),y=this.ctx.currentPage.wikiTitle;e={...e,title:y?.getPrefixedDBKey(),revision:x.has("oldid")?Number(x.get("oldid")):void 0,pageId:x.has("curid")?Number(x.get("curid")):void 0}}if(!e.revision&&!e.pageId&&e.title){const x=this.ctx.wikiTitle.resolveSpecialPageTarget(e.title);x&&x.title.getNamespaceId()>=0&&(e.title=x.title.getPrefixedDBKey(),e.section??(e.section=x.section))}const i=await this.ctx.preferences.get("quickEdit.outSideClose"),r=await this.ctx.preferences.get("quickEdit.watchList"),n=typeof e.editSummary=="string"?e.editSummary:await this.ctx.preferences.get("quickEdit.editSummary"),s=typeof e.editMinor=="boolean"?e.editMinor:await this.ctx.preferences.get("quickEdit.editMinor"),o=await this.getEditFontOptions(),a={...this.DEFAULT_OPTIONS,editSummary:n,editMinor:s,...e};a.editSummary||(a.editSummary=await this.ctx.preferences.get("quickEdit.editSummary")||""),this.ctx.emit("quick-edit/init-options",{ctx:this.ctx,options:a});const l=this.ctx.modal.createObject({className:"ipe-quickEdit",sizeClass:"large",center:!1,outSideClose:i}).init();l.setTitle(p(Ct,{children:["Loading: ",p("u",{children:a.title})]})),l.setContent(p("section",{className:"ipe-quickEdit-loading",style:{height:"70vh",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:p(jt,{})})),l.addButton({side:"right",type:"button",className:"is-danger is-ghost",label:"Cancel",method(){l.close()}}),l.show(),this.ctx.emit("quick-edit/show-modal",{ctx:this.ctx,modal:l,options:a});let c;try{if(c=await this.getWikiPageFromPayload(a),c.pageInfo.special)throw new Error("Special page is not editable")}catch(x){l.off(l.Event.Close),l.close(),this.ctx.modal.notify("error",{content:x instanceof Error?x.message:String(x)});return}const u=a.section==="new"?"":c.revisions[0]?.content||"",f=c.revisions[0]?.revid,h=f&&f!==c.lastrevid,m=a.section==="new",d=c.pageid===0;l.setTitle(p(Ct,{children:[m?"New section":`Quick ${d?"Create":"Edit"}`,":"," ",p("u",{children:c.pageInfo.title}),h?` (Revision ${f})`:""]}));const _=[];d&&_.push(p(vr,{title:"Attention",type:"important",children:p("p",{children:"This page does not exist."})})),h&&_.push(p(vr,{title:"Attention",type:"warning",children:p("p",{children:["You are editing a ",p("em",{children:"historical version"}),"; the content is not the latest!"]})})),this.ctx.emit("quick-edit/edit-notice",{ctx:this.ctx,options:a,modal:l,wikiPage:c,editNotices:_});const k=p("form",{className:"ipe-quickEdit__form",children:[p("div",{className:"ipe-quickEdit__notices",children:_}),p("div",{className:"ipe-quickEdit__content",style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[a.section==="new"&&p(Ct,{children:p(_r,{label:"Section title",id:"summary",name:"summary",value:"",inputProps:{placeholder:"Topic for new section, this will be the h2 heading"}})}),p("textarea",{className:`ipe-quickEdit__textarea ${o.className}`,style:{fontFamily:o.fontFamily},name:"text",id:"wpTextbox1",children:u})]}),p("div",{class:"ipe-quickEdit__options",style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:[!m&&p(_r,{label:"Summary",id:"summary",name:"summary",value:a.editSummary}),p("div",{className:"ipe-input-box",children:[p("label",{htmlFor:"watchlist",style:{display:"block"},children:"Watchlist"}),p("div",{style:{display:"flex",gap:"1rem"},children:[Xe.preferences,Xe.nochange,Xe.watch,Xe.unwatch].map(x=>p(Vy,{name:"watchlist",value:x,inputProps:{checked:r===x},children:x},x))})]}),p("div",{style:{display:"flex",gap:"1rem"},children:[p(Ti,{name:"minor",id:"minor",checked:a.editMinor,children:"Minor edit"}),p(Ti,{name:"reloadAfterSave",id:"reloadAfterSave",checked:a.reloadAfterSave,children:"Reload after save"})]})]}),!1]});l.setContent(k),l.addButton({side:"left",className:"is-primary submit-btn",label:"Submit",keyPress:await this.ctx.preferences.get("quickEdit.keyshortcut.save")||void 0,method:()=>{const x=new FormData(k);l.setLoadingState(!0),this.handleSubmit({wikiPage:c,text:x.get("text"),summary:x.get("summary"),minor:x.get("minor")==="on",section:a.section,createonly:c.pageid===0,watchlist:r}).then(async()=>{l.setOptions({beforeClose:On}),l.close(),this.ctx.modal.notify("success",{title:"Submission Successful",content:"Your changes have been saved."}),x.get("reloadAfterSave")&&(await Gy(500),location.reload())}).catch(y=>{this.ctx.modal.notify("error",{title:"Submission Error",content:y instanceof Error?y.message:String(y)}),l.setLoadingState(!1)})}},0),l.setOptions({beforeClose:()=>{const x=c.revisions[0]?.content||"";return(k.querySelector("textarea")?.value||"")===x?!0:(this.ctx.modal.confirm({className:"is-primary",title:"Unsaved Changes",content:"All edit contents will be lost after closing the modal. Are you sure you want to close?",center:!0,okBtn:{label:"Give Up",className:"is-danger is-ghost"},cancelBtn:{label:"Continue Editing",className:"is-primary is-ghost"}},g=>(g&&(l.setOptions({beforeClose:On}),l.close()),!0)),!1)}}),this.ctx.emit("quick-edit/wiki-page",{ctx:this.ctx,options:a,modal:l,wikiPage:c});const E=x=>k.querySelector("textarea")?.value===u?!0:(x.preventDefault(),"You have unsaved changes. Are you sure you want to leave?");window.addEventListener("beforeunload",E),l.on(l.Event.Close,()=>{window.removeEventListener("beforeunload",E)})}async handleSubmit(e){const i=e.wikiPage,r=e.summary||"",n=e.text||"",s=e.minor,o=e.createonly,a=e.watchlist,l=e.section;return this.ctx.emit("quick-edit/submit",{ctx:this.ctx,wikiPage:i,summary:r,text:n,minor:s,createonly:o,watchlist:a}),i.edit({summary:r,text:n,watchlist:a,section:l},{minor:s,createonly:o})}async getEditFontOptions(){const e=await this.ctx.preferences.get("quickEdit.editFont");return di.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.currentPage.wikiTitle,r=this.ctx.wiki.hasRight("edit")&&i&&i.getNamespaceId()>=0;e.toolbox.addButton({id:"quick-edit",group:"group1",index:0,icon:p("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:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1"}),p("path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z"}),p("path",{d:"M16 5l3 3"})]}),buttonProps:{disabled:!r},tooltip:r?"Quick Edit":"Not editable",onClick:()=>{const n=new URLSearchParams(window.location.search).get("oldid");this.showModal({title:i?.getPrefixedText(),revision:n?Number(n):void 0})}})}removeToolbox(e){e.toolbox.removeButton("quick-edit")}},di.BUILT_IN_FONT_OPTIONS=["preferences","monospace","sans-serif","serif"],di);Do=Zy(ju),Ln=nb(Do,0,"PluginQuickEdit",Du,Ln),rb(Do,1,Ln);const sb=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickEdit:Ln},Symbol.toStringTag,{value:"Module"}));var ob=Object.create,jo=Object.defineProperty,ab=Object.getOwnPropertyDescriptor,Uu=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Fu=t=>{throw TypeError(t)},lb=(t,e,i)=>e in t?jo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,cb=(t,e)=>jo(t,"name",{value:e,configurable:!0}),ub=t=>[,,,ob(t?.[Uu("metadata")]??null)],fb=["class","method","getter","setter","accessor","field","value","get","set"],Bu=t=>t!==void 0&&typeof t!="function"?Fu("Function expected"):t,db=(t,e,i,r,n)=>({kind:fb[t],name:e,metadata:r,addInitializer:s=>i._?Fu("Already initialized"):n.push(Bu(s||null))}),hb=(t,e)=>lb(e,Uu("metadata"),t[3]),pb=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},mb=(t,e,i,r,n,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(n=n.prototype,c<5&&(c>3||!u)&&ab(n,i));cb(n,i);for(var d=r.length-1;d>=0;d--)l=db(c,i,a={},t[3],h),o=(0,r[d])(n,l),a._=1,Bu(o)&&(n=o);return hb(t,n),m&&jo(n,i,m),u?c^4?s:m:n},qu,Uo,Hu;qu=[ve(["api","wikiPage","wikiTitle","currentPage","wiki","modal","preferences"]),ii(L.object({deleteReason:L.string().description("Default delete reason for quick delete").default("[IPE-NEXT] Quick delete")}).description("Quick delete options").extra("category","editor"))];class Nn extends(Hu=je){constructor(e){super(e,{},"quick-delete"),this.ctx=e,this.DEFAULT_OPTIONS={title:"",pageId:0,revision:0,deleteReason:"",reloadAfterDelete:!0},this.ctx.root.set("quickDelete",No(this,"showModal"))}start(){this.ctx.inject(["toolbox"],e=>{this.injectToolbox(e),e.on("dispose",()=>{this.removeToolbox(e)})})}async showModal(e){if(typeof e>"u"?e={}:typeof e=="string"&&(e={title:e}),!e.title&&!e.pageId&&!e.revision){this.logger.warn("None of the title, pageId or revision provided. Using defaults.");const l=new URLSearchParams(window.location.search),c=this.ctx.currentPage.wikiTitle;e={...e,title:c?.getPrefixedDBKey(),revision:l.has("oldid")?Number(l.get("oldid")):void 0,pageId:l.has("curid")?Number(l.get("curid")):void 0}}const i=typeof e.deleteReason=="string"?e.deleteReason:await this.ctx.preferences.get("quickDelete.reason"),r={...this.DEFAULT_OPTIONS,deleteReason:i,...e};r.deleteReason||(r.deleteReason=await this.ctx.preferences.get("quickDelete.reason")||""),r||this.ctx.emit("quick-delete/init-options",{ctx:this.ctx,options:r});const n=this.ctx.modal.createObject({className:"ipe-quickDelete",sizeClass:"small",center:!0}).init();n.setTitle(p(Ct,{children:["Loading: ",p("u",{children:r.title})]})),n.setContent(p(jt,{})),n.addButton({side:"right",type:"button",className:"is-ghost",label:"Cancel",method(){n.close()}}),n.show(),this.ctx.emit("quick-delete/show-modal",{ctx:this.ctx,modal:n,options:r});let s;try{if(s=await this.getWikiPageFromPayload(r),s.pageInfo.special)throw new Error("Special page cannot be deleted");if(s.pageInfo.pageid===0)throw new Error("Page does not exist, cannot be deleted")}catch(l){n.off(n.Event.Close),n.close(),this.ctx.modal.notify("error",{content:l instanceof Error?l.message:String(l)});return}n.setTitle(p(Ct,{children:["Quick Delete: ",p("u",{children:s.pageInfo.title})]}));const o=[];s.userCan("delete")||o.push(p(vr,{title:"Permission Denied",type:"error",children:p("p",{children:"You do not have permission to delete this page."})})),s.pageInfo.protection&&s.pageInfo.protection.length>0&&o.push(p(vr,{title:"Warning",type:"warning",children:p("p",{children:"This page is protected and may has special use or purpose. Delete it at your own risk."})})),this.ctx.emit("quick-delete/delete-notice",{ctx:this.ctx,options:r,modal:n,wikiPage:s,deleteNotices:o});const a=p("form",{className:"ipe-quickDelete__form",children:[p("div",{className:"ipe-quickDelete__notices",children:o}),p("div",{className:"ipe-quickDelete__content",children:p("div",{className:"ipe-quickDelete__page-info",style:{padding:"1rem",backgroundColor:"#f8f9fa",border:"1px solid #dee2e6",borderRadius:"4px",marginBottom:"1rem"},children:p("ul",{children:[p("li",{children:[p("strong",{children:"Title:"})," ",s.pageInfo.title]}),p("li",{children:[p("strong",{children:"Page ID:"})," ",s.pageInfo.pageid]}),p("li",{children:[p("strong",{children:"Last Revision:"})," ",s.pageInfo.lastrevid]}),p("li",{children:[p("strong",{children:"Length:"})," ",s.pageInfo.length," characters"]})]})})}),p("div",{class:"ipe-quickDelete__options",style:{display:"flex",flexDirection:"column",gap:"1rem",marginTop:"1rem"},children:p(_r,{label:"Delete Reason",id:"reason",name:"reason",value:r.deleteReason,inputProps:{placeholder:"Enter reason for deletion...",required:!0}})}),!1]});n.setContent(a),n.addButton({side:"left",className:"is-danger submit-btn",label:"Delete Page",method:()=>{const c=new FormData(a).get("reason");if(!c||c.trim()===""){this.ctx.modal.notify("error",{title:"Missing Reason",content:"Please provide a reason for deletion."});return}this.ctx.modal.confirm({className:"is-danger",title:"Confirm Deletion",content:p(Ct,{children:p("p",{children:p("strong",{children:s.pageInfo.title})})}),center:!0,okBtn:{label:"Delete it now",className:"is-danger"},cancelBtn:{label:"Cancel",className:"is-ghost"}},u=>(u&&(n.setLoadingState(!0),this.handleSubmit({wikiPage:s,reason:c}).then(async()=>{n.setOptions({beforeClose:On}),n.close(),this.ctx.modal.notify("success",{title:"Deletion Successful",content:`The page "${s.pageInfo.title}" has been deleted.`}),this.ctx.emit("quick-delete/submit",{ctx:this.ctx,wikiPage:s,reason:c})}).catch(f=>{this.ctx.modal.notify("error",{title:"Deletion Error",content:f instanceof Error?f.message:String(f)}),n.setLoadingState(!1)})),!0))}},0),this.ctx.emit("quick-delete/wiki-page",{ctx:this.ctx,options:r,modal:n,wikiPage:s})}async handleSubmit(e){const i=e.wikiPage,r=e.reason||"";return i.delete(r)}async getWikiPageFromPayload(e){if(e.revision)return this.ctx.wikiPage.newFromRevision(e.revision);if(e.pageId)return this.ctx.wikiPage.newFromPageId(e.pageId);if(e.title)return this.ctx.wikiPage.newFromTitle(e.title,!1);throw new Error("Invalid payload")}async injectToolbox(e){const i=this.ctx.currentPage.wikiTitle,r=i&&this.ctx.wiki.hasRight("delete")&&i.getNamespaceId()>=0;e.toolbox.addButton({id:"quick-delete",group:"group2",icon:p("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-trash",children:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("path",{d:"M4 7l16 0"}),p("path",{d:"M10 11l0 6"}),p("path",{d:"M14 11l0 6"}),p("path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12"}),p("path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"})]}),buttonProps:{disabled:!r},tooltip:r?"Quick Delete":"Not deletable",onClick:()=>{this.showModal({title:i?.getPrefixedText()})}})}removeToolbox(e){e.toolbox.removeButton("quick-delete")}}Uo=ub(Hu),Nn=mb(Uo,0,"PluginQuickDelete",qu,Nn),pb(Uo,1,Nn);const gb=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickDelete(){return Nn}},Symbol.toStringTag,{value:"Module"})),xr={twinSwapInput:"_twinSwapInput_1gdgl_9",inputWrapper:"_inputWrapper_1gdgl_23",inputLeft:"_inputLeft_1gdgl_27",inputRight:"_inputRight_1gdgl_30",swapButton:"_swapButton_1gdgl_46"},zu=t=>{const{inputs:e,enableSwap:i=!0,...r}=t,n=e?.length===2?e:[e?.[0]??{},e?.[1]??{}],s=[null,null];let o=0,a=null,l=null;const c=()=>s.some(d=>d&&d.disabled),u=()=>{if(!s[0]||!s[1]||c())return;const d=s[0],_=s[1],k=d.value,E=_.value;d.value=E,_.value=k,d.dispatchEvent(new Event("change")),_.dispatchEvent(new Event("change")),o++,l&&(l.style.transform=`rotateY(${o*-180}deg)`,l.style.transition="transform 200ms ease")},f=d=>{if(!a)return;const _=d??!a.disabled;a.disabled=!_,_&&s.forEach(k=>{k&&(k.disabled=!1)})},h=p("button",{type:"button","aria-label":"Swap values",onClick:u,disabled:c()||!i,ref:d=>a=d,children:p("svg",{ref:d=>l=d,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:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("path",{d:"M20 10h-16l5.5 -6"}),p("path",{d:"M4 14h16l-5.5 6"})]})}),m=p("div",{className:`twin-swap-input ${xr.twinSwapInput}`,...r,children:[n.map((d,_)=>{const{label:k,id:E,name:x,value:y,disabled:g,required:w,inputProps:S}=d,C=_===0,T=E||x;return p("div",{className:`${xr.inputWrapper} ${C?xr.inputLeft:xr.inputRight}`,children:[k&&p("label",{htmlFor:T,children:k}),p("input",{ref:B=>s[_]=B,type:"text",id:T,name:x,value:y,disabled:g,required:w,...S})]})}),p("div",{className:xr.swapButton,children:h})]});return m.swap=u,m.toggleEnableSwap=f,m};var yb=Object.create,Fo=Object.defineProperty,bb=Object.getOwnPropertyDescriptor,Ku=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Wu=t=>{throw TypeError(t)},wb=(t,e,i)=>e in t?Fo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,vb=(t,e)=>Fo(t,"name",{value:e,configurable:!0}),_b=t=>[,,,yb(t?.[Ku("metadata")]??null)],xb=["class","method","getter","setter","accessor","field","value","get","set"],Vu=t=>t!==void 0&&typeof t!="function"?Wu("Function expected"):t,Sb=(t,e,i,r,n)=>({kind:xb[t],name:e,metadata:r,addInitializer:s=>i._?Wu("Already initialized"):n.push(Vu(s||null))}),kb=(t,e)=>wb(e,Ku("metadata"),t[3]),Eb=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},$b=(t,e,i,r,n,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(n=n.prototype,c<5&&(c>3||!u)&&bb(n,i));vb(n,i);for(var d=r.length-1;d>=0;d--)l=Sb(c,i,a={},t[3],h),o=(0,r[d])(n,l),a._=1,Vu(o)&&(n=o);return kb(t,n),m&&Fo(n,i,m),u?c^4?s:m:n},Gu,Bo,Yu;Gu=[ii(L.object({"quickMove.reason":L.string().default("[IPE-NEXT] Quick move")}).description("Quick move options").extra("category","editor")),ve(["modal","wiki"])];class Mn extends(Yu=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=window.mw?.config.get("wgPageName")||"",r=window.mw?.config.get("wgIsProbablyEditable");e.toolbox.addButton({id:"quick-move",icon:p("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:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("path",{d:"M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3"}),p("path",{d:"M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3"}),p("path",{d:"M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7"}),p("path",{d:"M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1"}),p("path",{d:"M17 12h.01"}),p("path",{d:"M13 12h.01"})]}),tooltip:"Quick Move",group:"group1",index:1,onClick:()=>{this.showModal(r?{lockFromField:!0,from:i}:{})}})}async showModal(e){const i=await this.ctx.preferences.get("quickMove.reason"),r=this.ctx.modal.createObject({title:"Quick Move",content:p(jt,{}),className:"quick-move compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let n=null;return r.setContent(p("form",{ref:s=>n=s,style:{display:"flex",flexDirection:"column",gap:"1rem"},onSubmit:s=>{if(s.preventDefault(),n?.checkValidity(),!n?.reportValidity())return;const o=new FormData(n),a={from:o.get("from")?.toString().trim(),to:o.get("to")?.toString().trim(),reason:o.get("reason")||"",movetalk:o.get("movetalk")==="on",movesubpages:o.get("movesubpages")==="on",noredirect:o.get("noredirect")==="on"};if(!a.from||!a.to){this.ctx.modal.notify("error",{title:"Failed to move",content:"From and to are required."});return}this.ctx.emit("quick-move/submit",{ctx:this.ctx,modal:r,payload:a}),r.setLoadingState(!0),this.movePage(a).then(()=>{location.reload()}).catch(l=>{r.setLoadingState(!1),this.ctx.modal.notify("error",{title:"Failed to move",content:l instanceof Error?l.message:String(l)})})},children:[p(zu,{inputs:[{label:"Move from",name:"from",value:e?.from,required:!0},{label:"Move to",name:"to",value:e?.to,required:!0}]}),p("div",{children:p(Ti,{name:"movetalk",id:"movetalk",checked:e?.movetalk,children:"Move talk page"})}),p("div",{children:p(Ti,{name:"movesubpages",id:"movesubpages",checked:e?.movesubpages,children:"Move subpage(s) (up to 100)"})}),this.ctx.wiki.hasRight("suppressredirect")&&p("div",{children:p(Ti,{name:"noredirect",id:"noredirect",checked:e?.noredirect,children:"Move without leaving a redirect"})}),p(_r,{label:"Reason",id:"reason",name:"reason",value:e?.reason??i??""})]})),r.setButtons([{label:"Move",className:"is-primary is-ghost",method:()=>{n?.dispatchEvent(new Event("submit"))}}]),r.show()}async movePage(e){const{from:i,to:r,reason:n="",...s}=e;if(!i||!r)throw new Error("From and to titles are required.");if(i===r)throw new Error("From and to titles cannot be the same.");return(await this.ctx.wikiPage.newFromTitle(i)).moveTo(r,n,s)}}Bo=_b(Yu),Mn=$b(Bo,0,"PluginQuickMove",Gu,Mn),Eb(Bo,1,Mn);const Pb=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickMove(){return Mn}},Symbol.toStringTag,{value:"Module"}));var Cb=Object.create,qo=Object.defineProperty,Ib=Object.getOwnPropertyDescriptor,Qu=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Xu=t=>{throw TypeError(t)},Ab=(t,e,i)=>e in t?qo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ob=(t,e)=>qo(t,"name",{value:e,configurable:!0}),Rb=t=>[,,,Cb(t?.[Qu("metadata")]??null)],Tb=["class","method","getter","setter","accessor","field","value","get","set"],Ju=t=>t!==void 0&&typeof t!="function"?Xu("Function expected"):t,Lb=(t,e,i,r,n)=>({kind:Tb[t],name:e,metadata:r,addInitializer:s=>i._?Xu("Already initialized"):n.push(Ju(s||null))}),Nb=(t,e)=>Ab(e,Qu("metadata"),t[3]),Mb=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Db=(t,e,i,r,n,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(n=n.prototype,c<5&&(c>3||!u)&&Ib(n,i));Ob(n,i);for(var d=r.length-1;d>=0;d--)l=Lb(c,i,a={},t[3],h),o=(0,r[d])(n,l),a._=1,Ju(o)&&(n=o);return Nb(t,n),m&&qo(n,i,m),u?c^4?s:m:n},Zu,Ho,ef;Zu=[ve(["api","wikiPage","modal","preferences"]),ii(L.object({"quickPreview.keyshortcut":L.string().default("ctrl-p").description("Key shortcut to open quick preview in quick edit modal")}).extra("category","editor").description("Quick preview options"))];class Dn extends(ef=je){constructor(e){super(e,{},"quickPreview"),this.ctx=e,this.ctx.set("quickPreview",No(this,"previewWikitext"))}start(){this.ctx.on("quick-edit/wiki-page",this.injectQuickEdit.bind(this)),this.ctx.on("quick-delete/wiki-page",this.injectQuickDelete.bind(this))}stop(){}previewWikitext(e,i,r,n,s){return r||(r=this.ctx.wikiPage.newBlankPage({title:"API"})),(!n||n.isDestroyed)&&(n=this.ctx.modal.createObject({className:"in-page-edit ipe-quickPreview",sizeClass:"large",center:!1,...s}).init()),n.show(),n.setTitle("Preview - Loading..."),n.setContent(p(jt,{})),n.bringToFront(),this.ctx.emit("quick-preview/show-modal",{ctx:this.ctx,text:e,modal:n,wikiPage:r}),r.preview(e,i).then(o=>{const{data:{parse:a}}=o;n.setTitle(`Preview - ${a.title}`);let l=null;n.setContent(p("section",{children:p("div",{ref:c=>l=c,className:"mw-parser-output",innerHTML:a.text})})),window.mw?.hook("wikipage.content").fire($(l)),this.ctx.emit("quick-preview/loaded",{ctx:this.ctx,modal:n,wikiPage:r,text:e,parseData:a})}).catch(o=>{n.setTitle("Preview - Failed"),n.setContent(p(Ct,{children:[p("p",{children:"Failed to preview"}),p("p",{children:o instanceof Error?o.message:String(o)})]}))}),n}async injectQuickEdit({options:e,modal:i,wikiPage:r}){let n;i.addButton({label:"Preview",side:"left",className:"btn btn-secondary",keyPress:await this.ctx.preferences.get("quickPreview.keyshortcut.quickEdit")||void 0,method:()=>{let s=i.get$content().querySelector('textarea[name="text"]')?.value||"";if(e.section==="new"){const o=i.get$content().querySelector('input[name="summary"]')?.value;o&&(s=`==${o}==
17
+ ${s}`)}n=this.previewWikitext(s,void 0,r,n,{backdrop:!1,draggable:!0})}},1),i.on(i.Event.Close,()=>{n?.destroy(),n=void 0})}injectQuickDelete({ctx:e,modal:i,wikiPage:r}){i.addButton({label:"Preview",side:"left",className:"btn btn-secondary",method:()=>{this.logger.warn("To be implemented: preview wikitext for quick delete")}},2)}}Ho=Rb(ef),Dn=Db(Ho,0,"PluginQuickPreview",Zu,Dn),Mb(Ho,1,Dn);const jb=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickPreview(){return Dn}},Symbol.toStringTag,{value:"Module"})),Ub=t=>{let{user:e,target:i,ctx:r}=t;const n=r.getUrl.bind(r);return p("span",{className:"mw-userlinks",children:[p("a",{href:n(`User:${e}`),className:"mw-userlink",target:i,children:e})," ",p("span",{className:"mw-usertoollinks",children:["(",p("a",{href:n(`User_talk:${e}`),className:"mw-usertoollinks-talk",target:i,children:"talk"})," | ",p("a",{href:n(`Special:Contributions/${e}`),className:"mw-usertoollinks-contribs",target:i,children:"contribs"})," | ",p("a",{href:n(`Special:Block/${e}`),className:"mw-usertoollinks-block",target:i,children:"block"}),")"]})]})};var jn=(t=>(t.update="ipe:diff-table/update",t.edit="ipe:diff-table/edit",t))(jn||{});const Fb=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"medium"}).format,tf=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 p("td",{colSpan:2,className:e,children:p("div",{className:"mw-diff-title--title",children:t.type==="from"?"Original content":t.type==="to"?"Your content":""})});const i=r=>{r.preventDefault(),r.target.dispatchEvent(new CustomEvent("ipe:diff-table/edit",{detail:{revid:t.revid},bubbles:!0}))};return p("td",{colSpan:2,className:e,children:[p("div",{className:"mw-diff-title--title",children:[t.pagetitle||t.timestamp,t.revid?` (rev#${t.revid})`:""]}),p("div",{className:"mw-diff-title--actions",children:p("a",{href:t.ctx.getUrl("",{action:"edit",oldid:t.revid}),onClick:i,children:[p(cl,{style:"width: 1em; height: 1em"}),"Quick edit"]})}),p("div",{className:"mw-diff-title--user",children:t.username&&p(Ub,{ctx:t.ctx,user:t.username,target:"_blank"})}),p("div",{className:"mw-diff-title--timestamp",children:t.timestamp&&Fb(new Date(t.timestamp))}),p("div",{className:"mw-diff-title--comment",children:t.parsedcomment&&p(Ct,{children:["(",p("i",{innerHTML:t.parsedcomment}),")"]})})]})},Bb=t=>{const e=t.data;if(!e.prev&&!e.next)return null;const i=(r,n,s)=>{r.preventDefault(),r.target.dispatchEvent(new CustomEvent("ipe:diff-table/update",{detail:{fromrev:n,torev:s},bubbles:!0}))};return p("tr",{className:"mw-diff-title--navigation",children:[p("td",{colSpan:2,children:e.prev?p("a",{href:t.ctx.getUrl("",{diff:e.prev,oldid:e.fromrevid}),onClick:r=>i(r,e.prev,e.fromrevid),children:"← Previous"}):p("i",{children:"Oldest version"})}),p("td",{colSpan:2,children:e.next?p("a",{href:t.ctx.getUrl("",{diff:e.next,oldid:e.torevid}),onClick:r=>i(r,e.torevid,e.next),children:"Next →"}):p("i",{children:"Newest version"})})]})},qb=t=>{const{data:e,...i}=t,r=p("table",{className:"theme-ipe diff diff-type-table","data-mw":"interface",...i,children:[p("colgroup",{children:[p("col",{className:"diff-marker"}),p("col",{className:"diff-content"}),p("col",{className:"diff-marker"}),p("col",{className:"diff-content"})]}),p("tbody",{children:[p("tr",{children:[p(tf,{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}),p(tf,{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})]}),p(Bb,{data:e,ctx:t.ctx}),p("div",{id:"diffbody"}),p("tr",{className:"diff-size",style:{textAlign:"center"},children:[p("td",{colSpan:2,className:"diff-size-old",children:e.fromsize!==void 0&&`${e.fromsize} bytes`}),p("td",{colSpan:2,className:"diff-size-new",children:e.tosize!==void 0&&`${e.tosize} bytes`})]})]})]});return r.querySelector("#diffbody").outerHTML=e.body||p("tr",{children:p("td",{colSpan:4,children:p("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"5rem"},children:p("i",{children:"No changes"})})})}).outerHTML,r},Hb=(t,e=document)=>e.querySelector(t),zb=(t,e=document)=>e.querySelectorAll(t);var Kb=Object.create,zo=Object.defineProperty,Wb=Object.getOwnPropertyDescriptor,rf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),nf=t=>{throw TypeError(t)},Vb=(t,e,i)=>e in t?zo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Gb=(t,e)=>zo(t,"name",{value:e,configurable:!0}),Yb=t=>[,,,Kb(t?.[rf("metadata")]??null)],Qb=["class","method","getter","setter","accessor","field","value","get","set"],sf=t=>t!==void 0&&typeof t!="function"?nf("Function expected"):t,Xb=(t,e,i,r,n)=>({kind:Qb[t],name:e,metadata:r,addInitializer:s=>i._?nf("Already initialized"):n.push(sf(s||null))}),Jb=(t,e)=>Vb(e,rf("metadata"),t[3]),Zb=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},ew=(t,e,i,r,n,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(n=n.prototype,c<5&&(c>3||!u)&&Wb(n,i));Gb(n,i);for(var d=r.length-1;d>=0;d--)l=Xb(c,i,a={},t[3],h),o=(0,r[d])(n,l),a._=1,sf(o)&&(n=o);return Jb(t,n),m&&zo(n,i,m),u?c^4?s:m:n},of,Ko,af;of=[ve(["wiki","getUrl","preferences"]),ii(L.object({"quickDiff.keyshortcut":L.string().default("ctrl-d").description("Key shortcut to open quick diff in quick edit modal")}).description("Quick diff options").extra("category","editor"))];class Un extends(af=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=Hb("#mw-history-compare");if(!e)return;zb(".mw-history-compareselectedversions-button",e).forEach(r=>{r.after(p("button",{className:"cdx-button",onClick:n=>{n.preventDefault();const s=new FormData(e),o=Number(s.get("oldid"))||0,a=Number(s.get("diff"))||0;if(!s.get("title")||!o||!a)return this.logger.warn("Missing title or revision IDs");this.comparePages({fromrev:o,torev:a})},children:"Quick Diff"}))})}async injectQuickEdit({modal:e,wikiPage:i,options:r}){if(i.pageid===0||r.section==="new")return;let n;e.addButton({label:"Diff",side:"left",keyPress:await this.ctx.preferences.get("quickDiff.keyshortcut")||void 0,className:"btn btn-secondary",method:()=>{const s=i.title,o=i.revisions?.[0]?.content||"",a=e.get$content().querySelector('textarea[name="text"]')?.value||"";return o===a?this.ctx.modal.notify("info",{title:"Quick Diff",content:"No changes"}):(this.ctx.emit("quick-diff/quick-edit-modal",{ctx:this.ctx,modal:e,wikiPage:i}),n=this.comparePages({fromtitle:s,fromtext:o,totitle:s,totext:a,topst:!0},n,{backdrop:!1,draggable:!0}),n)}},2),e.on(e.Event.Close,()=>{n?.destroy(),n=void 0})}comparePages(e,i,r){return!i||i.isDestroyed?i=this.ctx.modal.createObject({title:"Loading diff...",content:"",className:"quick-diff",center:!1,...r}).init():i.removeButton("*"),this.ctx.emit("quick-diff/init-options",{ctx:this.ctx,options:e}),i.setContent(p("section",{style:{height:"70vh",display:"flex",justifyContent:"center",alignItems:"center"},children:p(jt,{})})),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(n=>{if(!n.data.compare)throw new Error("No compare data received",{cause:n});const{data:{compare:s}}=n;i.setTitle(s.fromtitle&&s.totitle?`${s.fromtitle}${s.fromrevid?` (${s.fromrevid})`:""} ⇔ ${s.totitle}${s.torevid?` (${s.torevid})`:""}`:"Differences");let o;i.setContent(p("section",{style:{minHeight:"70vh"},children:p(qb,{ref:a=>o=a,data:s,ctx:this.ctx})})),o.addEventListener(jn.update,a=>{a.stopPropagation(),this.comparePages({fromrev:a.detail.fromrev,torev:a.detail.torev},i,r)},{once:!0}),this.ctx.inject(["quickEdit"],a=>{const l=c=>{c.stopPropagation(),a.quickEdit({revision:c.detail.revid})};o.addEventListener(jn.edit,l),i.on(i.Event.Close,()=>{o.removeEventListener(jn.edit,l)})}),s.fromrevid&&s.torevid&&i.addButton({label:"Original Compare Page",side:"right",className:"btn btn-secondary",method:()=>{window.location.href=this.ctx.getUrl("",{oldid:s.fromrevid,diff:s.torevid})}}),this.ctx.emit("quick-diff/loaded",{ctx:this.ctx,modal:i,compare:s})}).catch(n=>{i.setContent(p(vr,{title:"Failed to load diff",type:"error",children:p("pre",{children:n instanceof Error?n.message:String(n)})}))}),i.show()}}Ko=Yb(af),Un=ew(Ko,0,"PluginQuickDiff",of,Un),Zb(Ko,1,Un);const tw=Object.freeze(Object.defineProperty({__proto__:null,get PluginQuickDiff(){return Un}},Symbol.toStringTag,{value:"Module"})),zn=class zn extends je{constructor(e){super(e,{},"quick-redirect"),this.ctx=e}start(){this.ctx.set("quickRedirect",this);const e=window.mw?.config.get("wgPageName")||"",i=window.mw?.config.get("wgIsProbablyEditable");this.ctx.inject(["toolbox"],r=>{this.ctx=r,r.toolbox.addButton({id:"quick-redirect",icon:p("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:[p("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),p("path",{d:"M4 21v-4a3 3 0 0 1 3 -3h5"}),p("path",{d:"M9 17l3 -3l-3 -3"}),p("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),p("path",{d:"M5 11v-6a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-9.5"})]}),tooltip:"Quick Redirect",group:"group1",index:2,onClick:()=>{this.showModal(i?{to:e}:{})}}),this.addDisposeHandler(n=>{n.toolbox.removeButton("quick-redirect")})})}stop(){}async showModal(e){const i=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:"Quick Redirect",content:p(jt,{}),className:"quick-redirect compact-buttons",sizeClass:"smallToMedium",center:!0}).init();let n=null;return r.setContent(p("form",{ref:s=>n=s,style:{display:"flex",flexDirection:"column",gap:"1rem"},onSubmit:s=>{if(s.preventDefault(),n?.checkValidity(),!n?.reportValidity())return;const o=new FormData(n),a={from:o.get("from")?.toString().trim(),to:o.get("to")?.toString().trim(),reason:o.get("reason")||"",overwrite:o.get("overwrite")==="on"};if(!a.from||!a.to){this.ctx.modal.notify("error",{title:"Failed to redirect",content:"From and to are required."});return}this.ctx.emit("quick-redirect/submit",{ctx:this.ctx,payload:a}),r.setLoadingState(!0),this.redirectPage(a).then(l=>{r.close(),this.ctx.modal.notify("success",{title:"Redirect successful",content:"The redirect has been created."})}).catch(l=>{r.setLoadingState(!1),this.ctx.modal.notify("error",{title:"Failed to redirect",content:l instanceof Error?l.message:String(l)})})},children:[p(zu,{inputs:[{label:"From",name:"from",value:e?.from,required:!0},{label:"To",name:"to",value:e?.to,required:!0}]}),p(_r,{label:"Reason",id:"reason",name:"reason",value:e?.reason??i??""}),p("div",{children:p(Ti,{name:"overwrite",id:"overwrite",checked:e?.overwrite,children:"Force create redirect even if the from page already exists"})})]})),r.setButtons([{label:"Create Redirect",className:"is-primary is-ghost",method:()=>{n?.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:r,reason:n="",overwrite:s=!1}=e,o=await this.ctx.wikiPage.newBlankPage({title:i}),a=`#REDIRECT [[:${r}]]`;return o.edit({text:a,summary:n},{createonly:!s})}};zn.inject=["api","wikiPage","modal"],zn.PreferencesSchema=L.object({"quickRedirect.reason":L.string().default("[IPE-NEXT] Quick redirect")}).description("Quick redirect options").extra("category","editor");let Wo=zn;const iw=Object.freeze(Object.defineProperty({__proto__:null,PluginQuickRedirect:Wo},Symbol.toStringTag,{value:"Module"}));var rw=Object.create,Vo=Object.defineProperty,nw=Object.getOwnPropertyDescriptor,lf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),cf=t=>{throw TypeError(t)},sw=(t,e,i)=>e in t?Vo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ow=(t,e)=>Vo(t,"name",{value:e,configurable:!0}),aw=t=>[,,,rw(t?.[lf("metadata")]??null)],lw=["class","method","getter","setter","accessor","field","value","get","set"],uf=t=>t!==void 0&&typeof t!="function"?cf("Function expected"):t,cw=(t,e,i,r,n)=>({kind:lw[t],name:e,metadata:r,addInitializer:s=>i._?cf("Already initialized"):n.push(uf(s||null))}),uw=(t,e)=>sw(e,lf("metadata"),t[3]),fw=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},dw=(t,e,i,r,n,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(n=n.prototype,c<5&&(c>3||!u)&&nw(n,i));ow(n,i);for(var d=r.length-1;d>=0;d--)l=cw(c,i,a={},t[3],h),o=(0,r[d])(n,l),a._=1,uf(o)&&(n=o);return uw(t,n),m&&Vo(n,i,m),u?c^4?s:m:n},ff,Go,df;ff=[ii(L.object({toolboxAlwaysShow:L.boolean().description("Make the toolbox opened by default").default(!1)}).description("Toolbox preferences")),ve(["preferences"])];class Fn extends(df=Pt){constructor(e){super(e,"toolbox",!1),this.ctx=e,this.container=void 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.updateButtonDelays()}stop(){this.container?.remove()}get isPersistent(){return this.container.classList.contains("is-persistent")}setupHoverLogic(){let e=null;this.container.addEventListener("mouseenter",()=>{e&&(clearTimeout(e),e=null),this.isPersistent||this.container.classList.add("is-hovered")}),this.container.addEventListener("mouseleave",()=>{this.isPersistent||(e=window.setTimeout(()=>{this.container.classList.remove("is-hovered")},150))})}calculateButtonDelay(e,i){if(i<=1)return 0;const r=.15,n=e/(i-1),s=r*Math.sqrt(n);return Math.round(s*1e3)/1e3}updateButtonDelays(){this.container.querySelectorAll(".btn-group").forEach(i=>{const r=i.querySelectorAll(".btn-tip-group"),n=r.length;r.forEach((s,o)=>{const a=this.calculateButtonDelay(o,n);s.style.setProperty("--transition-delay",`${a}s`),s.style.setProperty("--max-transition-delay","0.15s")})})}createToolbox(){return p("div",{id:"ipe-edit-toolbox",children:[p("ul",{className:"btn-group group1",style:{display:"flex",flexDirection:"column"}}),p("ul",{className:"btn-group group2",style:{display:"flex",flexDirection:"row"}}),p("button",{className:"ipe-toolbox-btn",id:"toolbox-toggler",onClick:()=>{this.toggle()},children:p("svg",{xmlns:"http://www.w3.org/2000/svg",width:"448",height:"512",viewBox:"0 0 448 512",children:[p("rect",{width:"448",height:"512",fill:"none"}),p("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,"-")}addButton(e){let{id:i,group:r,icon:n,tooltip:s,itemProps:o,buttonProps:a,onClick:l,index:c}=e;i=this.normalizeButtonId(i);const u=this.container.querySelector(`#${i}`);u&&(this.ctx.logger("toolbox").warn(`Button with id ${i} already exists, replacing it.`),u.remove());let f=null;if(typeof r>"u"||r==="auto"){const m=this.container.querySelector(".btn-group.group1"),d=this.container.querySelector(".btn-group.group2"),_=m?.children.length||0,k=d?.children.length||0;f=_<=k?m:d}else f=this.container.querySelector(`.btn-group.${r}`);if(!f)throw new Error(`Button group ${r} not found`);const h=p("li",{class:"btn-tip-group",id:i,onClick:l,...o,children:[p("div",{class:"btn-tip",children:s}),p("button",{id:`${i}-btn`,"data-id":e.id,class:"ipe-toolbox-btn",...a,children:n})]});return h.addEventListener("click",m=>{this.ctx.emit("toolbox/button-clicked",{ctx:this.ctx,button:m.target,id:e.id})}),typeof c=="number"?c<=0?f.prepend(h):c>=f.children.length?f.appendChild(h):f.children[c]?.before(h):f.appendChild(h),this.ctx.emit("toolbox/button-added",{ctx:this.ctx,button:h}),this.updateButtonDelays(),h}removeButton(e){const i=this.normalizeButtonId(e);this.container.querySelector(`#${i}`)?.remove(),this.ctx.emit("toolbox/button-removed",{ctx:this.ctx,id:e}),this.updateButtonDelays()}getContainer(){return this.container}get isOpened(){return this.container.classList.contains("is-persistent")||this.container.classList.contains("is-hovered")}toggle(e){const i=this.isPersistent,r=typeof e=="boolean"?e:!i;this.container.classList.toggle("is-persistent",r),this.container.classList.remove("is-hovered"),this.ctx.preferences.set("toolboxAlwaysShow",r),this.ctx.emit("toolbox/toggle",{ctx:this.ctx,opened:this.isOpened})}}Go=aw(df),Fn=dw(Go,0,"PluginToolbox",ff,Fn),fw(Go,1,Fn);const hw=Object.freeze(Object.defineProperty({__proto__:null,get PluginToolbox(){return Fn}},Symbol.toStringTag,{value:"Module"})),pw={id:"ipe-plugin-store-app"},gw={class:"sotre-header"},yw={class:"store-search-wrapper"},bw=["disabled"],ww=["disabled"],vw={class:"refresh-text"},_w={key:0,class:"store-loading"},xw={key:1,class:"store-plugins"},Sw={class:"plugin-info"},kw={class:"plugin-header"},Ew={class:"name"},$w={key:0,class:"status-badge"},Pw=["href"],Cw={class:"plugin-id"},Iw={key:0,class:"plugin-desc"},Aw={class:"plugin-meta"},Ow={key:0,class:"version"},Rw={key:1,class:"author"},Tw={key:2,class:"license"},Lw=["onClick"],Nw={key:2,class:"plugin-empty"},Mw=Object.freeze(Object.defineProperty({__proto__:null,default:Cu(pn({__name:"PluginStoreApp",setup(t){const e=ou(),i=lt([]),r=lt([]),n=lt(""),s=lt(!1);Pi(async()=>{await o()});const o=async()=>{const k=await e.store.ctx.preferences.get("pluginStore.registries")||[],E=await Promise.allSettled(k.map(async x=>({...await e.store.getRegistryInfo(x),registryUrl:x})));i.value=E.filter(x=>x.status==="fulfilled").map(x=>x.value)},a=(k,E)=>r.value.includes(`${k}:${E}`),l=k=>{try{return new URL(k).hostname}catch{return k}},c=yr(()=>{const k=i.value.flatMap(x=>(x.packages||[]).map(y=>({...y,registry:x.registryUrl,registryHomepage:x.homepage})));if(!n.value.trim())return k;const E=n.value.toLowerCase();return k.filter(x=>x.name?.toLowerCase().includes(E)||x.id?.toLowerCase().includes(E)||x.description?.toLowerCase().includes(E)||x.author?.toLowerCase().includes(E))}),u=async(k,E)=>{e.store.installAndSetPreference(k,E)},f=async(k,E)=>{e.store.uninstallAndRemovePreference(k,E)},h=(k,E)=>{a(k,E)?f(k,E):u(k,E)},m=async()=>{if(!s.value){s.value=!0;try{const k=await e.store.ctx.preferences.get("pluginStore.registries")||[],E=await Promise.allSettled(k.map(async x=>({...await e.store.refreshRegistryCache(x),registryUrl:x})));i.value=E.filter(x=>x.status==="fulfilled").map(x=>x.value),e.modal.notify("success",{content:`${k.length} registries refreshed successfully`})}catch{e.modal.notify("error",{content:"Failed to refresh registries"})}finally{setTimeout(()=>{s.value=!1},3e3)}}},d=async()=>{const k=await e.store.ctx.preferences.get("pluginStore.plugins")||[];r.value=k.map(E=>`${E.registry}:${E.id}`)};function _(k){const E=k.changes["pluginStore.plugins"];E&&Array.isArray(E)&&(r.value=E.map(x=>`${x.registry}:${x.id}`))}return Pi(()=>{d(),e.on("preferences/changed",_)}),Pi(()=>{}),ao(()=>{}),(k,E)=>(_e(),$e("div",pw,[de("div",gw,[de("div",yw,[$m(de("input",{class:"store-search-input","onUpdate:modelValue":E[0]||(E[0]=x=>n.value=x),type:"text",placeholder:"Search plugins...",disabled:i.value.length===0},null,8,bw),[[Zg,n.value]]),E[1]||(E[1]=de("div",{class:"store-search-icon"},"🔍",-1))]),de("button",{class:ri(["store-refresh-btn",{refreshing:s.value}]),onClick:m,disabled:s.value},[de("span",vw,Je(s.value?"Refreshing...":"Refresh"),1)],10,ww)]),i.value.length===0?(_e(),$e("div",_w,[...E[2]||(E[2]=[de("div",{class:"loading-spinner"},null,-1),de("div",{class:"loading-text"},"Loading...",-1)])])):c.value.length>0?(_e(),$e("div",xw,[(_e(!0),$e(ct,null,sc(c.value,x=>(_e(),$e("div",{class:ri(["plugin-item",{installed:a(x.registry,x.id)}]),key:`${x.registry}:${x.id}`},[de("div",Sw,[de("div",kw,[de("div",Ew,Je(x.name),1),a(x.registry,x.id)?(_e(),$e("div",$w,"✓")):zt("",!0)]),de("a",{class:"registry-tag",href:x.registryHomepage,target:"_blank"},Je(l(x.registry)),9,Pw),de("div",Cw,Je(x.id),1),x.description?(_e(),$e("div",Iw,Je(x.description),1)):zt("",!0),de("div",Aw,[x.version?(_e(),$e("span",Ow,"v"+Je(x.version),1)):zt("",!0),x.author?(_e(),$e("span",Rw,"👤 "+Je(x.author),1)):zt("",!0),x.license?(_e(),$e("span",Tw,"📜 "+Je(x.license),1)):zt("",!0)])]),de("button",{class:ri({active:a(x.registry,x.id)}),onClick:y=>h(x.registry,x.id)},Je(a(x.registry,x.id)?"Remove":"Install"),11,Lw)],2))),128))])):(_e(),$e("div",Nw,[...E[3]||(E[3]=[de("div",{class:"plugin-empty-icon"},"📦",-1),de("div",{class:"plugin-empty-text"},"No matching plugins found",-1)])]))]))}}),[["__scopeId","data-v-6fcc9e77"]])},Symbol.toStringTag,{value:"Module"})),Dw=window?.location?.origin,Sr=({type:t,tag:e,href:i,target:r,children:n,...s})=>(e=e||(i?"a":"button"),typeof r>"u"&&i&&i.startsWith("http")&&!i.startsWith(Dw)&&(r="_blank"),Zd(e,{className:`theme-ipe ipe-action-button ipe-modal-btn is-${t||"default"}`,href:e==="a"?i:void 0,target:e==="a"?r:void 0,"data-href":e!=="a"?i:void 0,...s},n));var jw=Object.create,Yo=Object.defineProperty,Uw=Object.getOwnPropertyDescriptor,hf=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),pf=t=>{throw TypeError(t)},Fw=(t,e,i)=>e in t?Yo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Bw=(t,e)=>Yo(t,"name",{value:e,configurable:!0}),qw=t=>[,,,jw(t?.[hf("metadata")]??null)],Hw=["class","method","getter","setter","accessor","field","value","get","set"],mf=t=>t!==void 0&&typeof t!="function"?pf("Function expected"):t,zw=(t,e,i,r,n)=>({kind:Hw[t],name:e,metadata:r,addInitializer:s=>i._?pf("Already initialized"):n.push(mf(s||null))}),Kw=(t,e)=>Fw(e,hf("metadata"),t[3]),Ww=(t,e,i,r)=>{for(var n=0,s=t[e>>1],o=s&&s.length;n<o;n++)s[n].call(i);return r},Vw=(t,e,i,r,n,s)=>{var o,a,l,c=e&7,u=!1,f=0,h=t[f]||(t[f]=[]),m=c&&(n=n.prototype,c<5&&(c>3||!u)&&Uw(n,i));Bw(n,i);for(var d=r.length-1;d>=0;d--)l=zw(c,i,a={},t[3],h),o=(0,r[d])(n,l),a._=1,mf(o)&&(n=o);return Kw(t,n),m&&Yo(n,i,m),u?c^4?s:m:n},gf,Qo,yf;gf=[ve(["preferences","wikiPage","wikiTitle","modal","preferencesUI"])];class Bn extends(yf=je){constructor(e){super(e,{},"pref-sync"),this.ctx=e,e.set("prefSync",this)}start(){const e=this.ctx;e.preferences.defineCategory({name:"pref-sync",label:"Sync",description:"Import and export preferences",index:98,customRenderer:()=>{const i=this.getUserPrefsPageTitle();return p("div",{className:"theme-ipe-prose",children:[p("section",{children:[p("h3",{children:"Backup your preferences via user page"}),i&&p("p",{children:p("a",{href:i?.getURL().toString(),target:"_blank",children:[i?.getPrefixedText()," →"]})}),p("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[p(Sr,{type:"primary",onClick:r=>{r.preventDefault();const n=e.preferencesUI.getCurrentModal(),s=r.target;s.disabled=!0,n?.setLoadingState(!0),this.importFromUserPage().then(o=>{this.notifyImportSuccess(o)}).finally(()=>{s.disabled=!1,n?.setLoadingState(!1)})},children:"Import"}),p(Sr,{type:"primary",onClick:r=>{r.preventDefault();const n=r.target;n.disabled=!0;const s=e.preferencesUI.getCurrentModal();s?.setLoadingState(!0),this.exportToUserPage().then(o=>{e.modal.notify("success",{title:"Preferences Exported",content:p("p",{children:["Your preferences have been exported to"," ",p("a",{href:o.getURL().toString(),target:"_blank",children:o.getPrefixedText()}),"."]})})}).finally(()=>{n.disabled=!1,s?.setLoadingState(!1)})},children:"Export"})]})]}),p("section",{children:[p("h3",{children:"Import and export preferences"}),p("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[p(Sr,{onClick:r=>{r.preventDefault();const n=e.preferencesUI.getCurrentModal();n?.setLoadingState(!0);const s=document.createElement("input");s.type="file",s.accept="application/json";let o=!1;const a=()=>{o||n?.setLoadingState(!1),window.removeEventListener("focus",a)};window.addEventListener("focus",a,{once:!0}),s.addEventListener("change",async l=>{o=!0;try{const c=l.target.files?.[0];if(!c)return;const u=await this.importFromFile(c);this.notifyImportSuccess(u)}catch(c){e.modal.notify("error",{title:"Import failed",content:c instanceof Error?c.message:String(c)})}finally{n?.setLoadingState(!1)}}),s.click()},children:"Import from file"}),p(Sr,{onClick:r=>{r.preventDefault();const n=p("input",{type:"url"}),s=e.preferencesUI.getCurrentModal();e.modal.confirm({title:"Import Preferences from URL",content:p("div",{children:[p("label",{htmlFor:"url-input",children:"Enter the URL of the preferences JSON file:"}),n]})},async o=>{const a=n.value.trim();if(!(!o||!a))try{s?.setLoadingState(!0);const l=await this.importFromUrl(a);this.notifyImportSuccess(l)}catch(l){e.modal.notify("error",{title:"Import failed",content:l instanceof Error?l.message:String(l)})}finally{s?.setLoadingState(!1)}})},children:"Import from URL"}),p(Sr,{onClick:async r=>{r.preventDefault(),await e.preferencesUI.dispatchFormSave();const n=await e.preferences.getExportableRecord(),s=JSON.stringify(n,null,2);e.modal.dialog({title:"Save to file",content:p("div",{children:[p("label",{htmlFor:"data",children:"Your InPageEdit preferences:"}),p("textarea",{name:"data",id:"data",rows:10,value:s,readOnly:!0,style:{width:"100%"}})]}),buttons:[{label:"Copy",method:(o,a)=>{navigator.clipboard.writeText(s),e.modal.notify("success",{content:"Copied to clipboard"}),a.close()}},{label:"Download",method:(o,a)=>{const l=document.createElement("a");l.href=`data:text/json;charset=utf-8,${encodeURIComponent(s)}`,l.download=`ipe-prefs-${new Date().toISOString()}.json`,l.click(),a.close()}}]},()=>{})},children:"Save as file"})]})]})]})}})}stop(){}getUserPrefsPageTitle(){try{const e=this.ctx.wiki?.userInfo?.name;return e?this.ctx.wikiTitle.newTitle(`User:${e}/ipe-prefs.json`,2):null}catch{return null}}async importFromUserPage(){const e=this.getUserPrefsPageTitle();if(!e)return this.logger.debug("Cannot get user page title, skipping load"),{};try{const i=e.getURL({action:"raw",ctype:"application/json"}),r=await this.importFromUrl(i.toString());return this.logger.info("Loaded preferences from user page:",e),r}catch(i){return this.logger.error("Failed to load preferences from user page:",i),{}}}async exportToUserPage(){const e=this.ctx,i=this.getUserPrefsPageTitle();if(!i)throw new Error("Cannot get user page title");await e.preferencesUI.dispatchFormSave();const r=await e.preferences.getExportableRecord(),n=JSON.stringify(r,null,2);try{return await this.ctx.wikiPage.newBlankPage({title:i.toString(),ns:2}).edit({text:n,summary:"Update InPageEdit preferences",watchlist:Xe.nochange}),this.logger.info("Exported preferences to user page:",i),i}catch(s){throw this.logger.error("Failed to export preferences to user page:",s),s}}async importFromUrl(e){const i=await fetch(e);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);const r=await i.blob();return await this.importFromFile(r)}async importFromFile(e){const i=await e.text(),r=JSON.parse(i);return await this.ctx.preferences.setMany(r)}notifyImportSuccess(e){const i=Object.keys(e??{}),r=i.length;return this.ctx.modal.notify("success",{title:"Preferences Imported",content:p("section",{children:[p("p",{children:["Successfully imported ",r||""," ",r!==1?"settings":"setting",":"]}),p("ol",{style:{listStyle:"auto",paddingLeft:"1em"},children:i.map(n=>p("li",{children:n},n))})]})})}}Qo=qw(yf),Bn=Vw(Qo,0,"PluginPrefSync",gf,Bn),Ww(Qo,1,Bn);const Gw=Object.freeze(Object.defineProperty({__proto__:null,get PluginPrefSync(){return Bn}},Symbol.toStringTag,{value:"Module"}));Q.BasePlugin=je,Q.InPageEdit=wi,Q.Inject=ve,Q.Logger=ma,Q.LoggerLevel=ns,Q.Schema=L,Q.Service=Pt,Q.createLogger=ba,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})}));
122
18
  //# sourceMappingURL=index.umd.js.map