19 lines
78 KiB
JavaScript

/*!
* Tiny Export to Word plugin
*
* Copyright (c) 2024 Ephox Corporation DBA Tiny Technologies, Inc.
* Licensed under the Tiny commercial license. See https://www.tiny.cloud/legal/
*
* Version: 8.3.0-112
*/
/*!
* This resource uses the code from the following libraries:
*
* specificity
* Copyright (c) 2022 Bramus Van Damme - https://www.bram.us/
* https://github.com/keeganstreet/specificity
*
*/
!function(){"use strict";const t=Object.getPrototypeOf,e=(t,e,n)=>!!n(t,e.prototype)||t.constructor?.name===e.name,n=t=>n=>(t=>{const n=typeof t;return null===t?"null":"object"===n&&Array.isArray(t)?"array":"object"===n&&e(t,String,((t,e)=>e.isPrototypeOf(t)))?"string":n})(n)===t,r=t=>e=>typeof e===t,o=t=>e=>t===e,s=n("string"),i=n("object"),a=n=>((n,r)=>i(n)&&e(n,r,((e,n)=>t(e)===n)))(n,Object),l=n("array"),c=o(null),u=r("boolean"),h=o(void 0),d=t=>null==t,p=t=>!d(t),f=r("function"),m=r("number"),g=()=>{},y=(t,e)=>(...n)=>t(e.apply(null,n)),k=t=>()=>t,v=t=>t;function S(t,...e){return(...n)=>{const r=e.concat(n);return t.apply(null,r)}}const b=t=>t(),C=k(!1),w=k(!0);class x{tag;value;static singletonNone=new x(!1);constructor(t,e){this.tag=t,this.value=e}static some(t){return new x(!0,t)}static none(){return x.singletonNone}fold(t,e){return this.tag?e(this.value):t()}isSome(){return this.tag}isNone(){return!this.tag}map(t){return this.tag?x.some(t(this.value)):x.none()}bind(t){return this.tag?t(this.value):x.none()}exists(t){return this.tag&&t(this.value)}forall(t){return!this.tag||t(this.value)}filter(t){return!this.tag||t(this.value)?this:x.none()}getOr(t){return this.tag?this.value:t}or(t){return this.tag?this:t}getOrThunk(t){return this.tag?this.value:t()}orThunk(t){return this.tag?this:t()}getOrDie(t){if(this.tag)return this.value;throw new Error(t??"Called getOrDie on None")}static from(t){return p(t)?x.some(t):x.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(t){this.tag&&t(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}const A=Array.prototype.slice,L=Array.prototype.indexOf,E=Array.prototype.push,T=(t,e)=>{return n=t,r=e,L.call(n,r)>-1;var n,r},O=(t,e)=>{for(let n=0,r=t.length;n<r;n++)if(e(t[n],n))return!0;return!1},P=(t,e)=>{const n=t.length,r=new Array(n);for(let o=0;o<n;o++){const n=t[o];r[o]=e(n,o)}return r},_=(t,e)=>{for(let n=0,r=t.length;n<r;n++)e(t[n],n)},I=(t,e)=>{const n=[];for(let r=0,o=t.length;r<o;r++){const o=t[r];e(o,r)&&n.push(o)}return n},R=t=>{const e=[];for(let n=0,r=t.length;n<r;++n){if(!l(t[n]))throw new Error("Arr.flatten item "+n+" was not an array, input: "+t);E.apply(e,t[n])}return e},j=(t,e)=>R(P(t,e)),N=f(Array.from)?Array.from:t=>A.call(t),$=Object.keys,M=Object.hasOwnProperty,D=(t,e)=>{const n=$(t);for(let r=0,o=n.length;r<o;r++){const o=n[r];e(t[o],o)}},B=(t,e)=>U(t,((t,n)=>({k:n,v:e(t,n)}))),U=(t,e)=>{const n={};return D(t,((t,r)=>{const o=e(t,r);n[o.k]=o.v})),n},V=(t,e)=>z(t,e)?x.from(t[e]):x.none(),z=(t,e)=>M.call(t,e),F=t=>{const e=e=>e(t),n=k(t),r=()=>o,o={tag:!0,inner:t,fold:(e,n)=>n(t),isValue:w,isError:C,map:e=>q.value(e(t)),mapError:r,bind:e,exists:e,forall:e,getOr:n,or:r,getOrThunk:n,orThunk:r,getOrDie:n,each:e=>{e(t)},toOptional:()=>x.some(t)};return o},W=t=>{const e=()=>n,n={tag:!1,inner:t,fold:(e,n)=>e(t),isValue:C,isError:w,map:e,mapError:e=>q.error(e(t)),bind:e,exists:C,forall:w,getOr:v,or:v,getOrThunk:b,orThunk:b,getOrDie:(r=String(t),()=>{throw new Error(r)}),each:g,toOptional:x.none};var r;return n},q={value:F,error:W,fromOption:(t,e)=>t.fold((()=>W(e)),F)},H="undefined"!=typeof window?window:Function("return this;")(),G=t=>(...e)=>{if(0===e.length)throw new Error("Can't merge zero objects");const n={};for(let r=0;r<e.length;r++){const o=e[r];for(const e in o)z(o,e)&&(n[e]=t(n[e],o[e]))}return n},J=G(((t,e)=>a(t)&&a(e)?J(t,e):e)),K=(G(((t,e)=>e)),(t,e)=>((t,e)=>{let n=null!=e?e:H;for(let e=0;e<t.length&&null!=n;++e)n=n[t[e]];return n})(t.split("."),e)),Q=(t,e)=>{const{type:n,message:r}=e;t.notificationManager.open({type:n,text:r})},Y=t=>{(t=>{switch(t){case"error":return console.error;case"info":return console.info;case"warn":return console.warn;default:return console.log}})(t.type)(t.message)},X=(t,e)=>{const{protect:n,allowList:r=[],blockList:o=[]}=null!=t?t:{};let s;return s=p(n)?n:r.length>0||o.length>0||e,{protect:s,allowList:r,blockList:o}},Z=t=>{const{protect:e,allowList:n,blockList:r}=null!=t?t:{};return t=>{const o=t.toLowerCase();return n.length>0?!O(n,(t=>t.toLowerCase()===o)):r.length>0?O(r,(t=>t.toLowerCase()===o)):e}},tt=t=>{const e=Z(t);return(t,n)=>{const r=((t,e)=>`${t}:${e}`)(n,t.toLowerCase());return e(r)}},et=(t,e,n,r)=>{const o=Reflect.get(t,"on"),s={protectedEventHandlers:[],cleanupScheduled:!1},i=(t,e)=>{r&&console.log(`[EventsProxy] ${t}`,e||"")},a=e=>{"invalid"===e&&s.protectedEventHandlers.length>0&&(i("Removing event handlers",s.protectedEventHandlers),_(s.protectedEventHandlers,(e=>{t.off(e.name,e.callback)})),s.protectedEventHandlers=[])},l=e.onStatusChange(a);return t.on("remove",l),(r,l,c)=>{i(`Adding event listener: ${r}`,{shouldProtect:n(r)});const u=((t,r)=>{const o=n(t),i=e.getStatus(),a=o&&"invalid"===i?g:r;return o&&s.protectedEventHandlers.push({name:t,callback:a}),a})(r,l);return s.cleanupScheduled||(s.cleanupScheduled=!0,window.setTimeout((()=>{a(e.getStatus()),s.cleanupScheduled=!1}),0)),Reflect.apply(o,t,[r,u,c])}},nt=(t,e,n)=>r=>{const o="invalid"!==e.getStatus()&&p(n)?n(r):g,s=((t,e,n)=>{const r=t=>{"invalid"===t&&n.setEnabled(!1)},o=()=>r(e.getStatus());r(e.getStatus()),t.on("NodeChange",o);const s=e.onStatusChange(r);return()=>{t.off("NodeChange",o),s()}})(t,e,r);return t=>{null==o||o(t),s()}},rt=(t,e,n)=>(...r)=>{var o;return"invalid"===t.getStatus()?n:null!==(o=null==e?void 0:e(...r))&&void 0!==o?o:n},ot=(t,e)=>rt(t,e,Promise.resolve([])),st=(t,e)=>rt(t,e,[]),it=(t,e)=>rt(t,e,!1),at=(t,e,n,r)=>{const o=e=>{const{command:o,value:i}=e,a=x.from(i).filter(s).map((t=>t.toLowerCase())),l=o.toLowerCase()===r.toLowerCase(),c=a.exists((t=>n.has(t))),u=a.exists((e=>e===t.queryCommandValue(r)));l&&c&&!u&&e.preventDefault()},i=e.onStatusChange((e=>{if("invalid"===e){t.on("BeforeExecCommand",o);const e=()=>{const e=t.queryCommandValue(r);n.has(e.toLowerCase())&&t.execCommand(r,!1,e)};t.initialized?e():t.on("init",e)}}));t.on("remove",(()=>{i(),t.off("BeforeExecCommand",o)}))},lt=(t,e,n,r,o,i=!1)=>{const a=new Set,l=new Set,c=(t,e)=>{i&&console.log(`[UiProxy] ${t}`,e||"")};((t,e,n)=>{at(t,e,n,"ToggleView")})(t,n,a),((t,e,n)=>{at(t,e,n,"ToggleSidebar")})(t,n,l);const u=(e,s,i,a)=>{const l=o(e,i);return c(`${a}: ${e}`,{spec:s,context:r,shouldProtect:l}),l?{...s,onSetup:nt(t,n,s.onSetup)}:s};return new Proxy(e,{get:(t,e,i)=>{const h=Reflect.get(t,e,i);if(!s(e))return h;switch(e){case"addButton":case"addGroupToolbarButton":case"addToggleButton":case"addMenuButton":case"addSplitButton":return(...n)=>{const[r,o,...s]=n,i=u(r,o,"button",String(e));return Reflect.apply(h,t,[r,i,...s])};case"addMenuItem":case"addToggleMenuItem":case"addNestedMenuItem":return(...n)=>{const[r,o,...s]=n,i=u(r,o,"menuitem",String(e));return Reflect.apply(h,t,[r,i,...s])};case"addAutocompleter":return(...s)=>{const[i,a,...l]=s,u=o(i,"autocompleter");if(c(`${String(e)}: ${i}`,{spec:a,context:r,shouldProtect:u}),u){const e={...a,fetch:ot(n,a.fetch)};return Reflect.apply(h,t,[i,e,...l])}return Reflect.apply(h,t,[i,a,...l])};case"addSidebar":return(...n)=>{const[s,i,...a]=n,u=o(s,"sidebar");if(c(`${String(e)}: ${s}`,{spec:i,context:r,shouldProtect:u}),u){l.add(s.toLowerCase());const e={...i};return Reflect.apply(h,t,[s,e,...a])}return Reflect.apply(h,t,[s,i,...a])};case"addView":return(...n)=>{const[s,i,...l]=n,u=o(s,"view");if(c(`${String(e)}: ${s}`,{spec:i,context:r,shouldProtect:u}),u){a.add(s.toLowerCase());const e={...i};return Reflect.apply(h,t,[s,e,...l])}return Reflect.apply(h,t,[s,i,...l])};case"addContextMenu":return(...s)=>{const[i,a,...l]=s,u=o(i,"contextmenu");if(c(`${String(e)}: ${i}`,{spec:a,context:r,shouldProtect:u}),u){const e={...a,update:st(n,a.update)};return Reflect.apply(h,t,[i,e,...l])}return Reflect.apply(h,t,[i,a,...l])};case"addContextToolbar":case"addContextForm":return(...s)=>{const[i,a,...l]=s,u=o(i,"contexttoolbar");if(c(`${String(e)}: ${i}`,{spec:a,context:r,shouldProtect:u}),u){const e={...a,predicate:it(n,a.predicate)};return Reflect.apply(h,t,[i,e,...l])}return Reflect.apply(h,t,[i,a,...l])};case"addIcon":case"getAll":case"addContext":return h}}})},ct=new Set(["addCommand","addCommands","addQueryStateHandler","addQueryValueHandler"]),ut=t=>(e,n)=>{t&&console.log(`[EditorProxy] ${e}`,n||"")},ht=(t,e)=>{const{statusProvider:n,uiContext:r,protection:o,debug:s=!1}=e,{events:i,commands:a,ui:l}=o;ut(s)("Creating enhanced editor with options:",{hasStatusProvider:!!n,uiContext:r,debug:s,protection:o});const{editorUiProxy:c,editorCommandsProxy:u,editorEventListenerProxy:h}=((t,e,n,r,o,s,i)=>{const a=s.protect?{...t.ui,registry:lt(t,t.ui.registry,e,n,tt(s),i)}:t.ui,l=r.protect?((t,e,n,r,o)=>{const s={protectedCommands:[],cleanupScheduled:!1},i=(t,e)=>{o&&console.log(`[CommandsProxy] ${t}`,e||"")},a=(t,e)=>{const o=r(t),i=n.getStatus();return o&&s.protectedCommands.push(t),o&&"invalid"===i?g:e},l=e=>{"invalid"===e&&s.protectedCommands.length>0&&(i("Removing commands",s.protectedCommands),_(s.protectedCommands,(e=>{t.editorCommands.removeCommand(e)})),s.protectedCommands=[])},c=()=>{s.cleanupScheduled||(s.cleanupScheduled=!0,window.setTimeout((()=>{l(n.getStatus()),s.cleanupScheduled=!1}),0))},u=n.onStatusChange(l);return t.on("remove",u),new Proxy(e,{get:(t,n,o)=>{if(i(`Accessing property: ${String(n)}`),"addCommand"===n){const s=Reflect.get(t,n,o);return(t,n,...o)=>{i(`Adding command: ${t}`,{shouldProtect:r(t)});const l=a(t,n);return c(),Reflect.apply(s,e,[t,l,...o])}}if("addCommands"===n){const r=Reflect.get(t,n,o);return(t,n="exec")=>{i(`Adding commands (${n})`,{commandCount:Object.keys(t).length,willApplyEnforcement:"exec"===n});const o="exec"!==n?t:B(t,((t,e)=>a(e,t)));return c(),Reflect.apply(r,e,[o,n])}}return Reflect.get(t,n,o)}})})(t,t.editorCommands,e,Z(r),i):t.editorCommands;return{editorUiProxy:a,editorCommandsProxy:l,editorEventListenerProxy:o.protect?et(t,e,Z(o),i):t.on.bind(t)}})(t,n,r||"",a,i,l,s),d=((t,e,n,r)=>(o,s,i)=>{const a=String(s);if("on"===s)return ut(r)("on intercepted"),n;if(ct.has(a))return ut(r)(`${a} intercepted`),e[a].bind(e);if("editorCommands"===s)return ut(r)("editorCommands accessed"),e;if("ui"===s)return ut(r)("ui accessed"),t;const l=Reflect.get(o,s,i);return f(l)?l.bind(o):l})(c,u,h,s);return new Proxy(t,{get:d,set:(t,e,n,r)=>Reflect.set(t,e,n,r),has:(t,e)=>Reflect.has(t,e),ownKeys:t=>Reflect.ownKeys(t),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t,e),defineProperty:(t,e,n)=>Reflect.defineProperty(t,e,n),deleteProperty:(t,e)=>Reflect.deleteProperty(t,e),isExtensible:t=>Reflect.isExtensible(t),preventExtensions:t=>Reflect.preventExtensions(t),getPrototypeOf:t=>Reflect.getPrototypeOf(t),setPrototypeOf:(t,e)=>Reflect.setPrototypeOf(t,e)})},dt=t=>parseInt(t,10),pt=(t,e)=>{const n=t-e;return 0===n?0:n>0?1:-1},ft=(t,e,n)=>({major:t,minor:e,patch:n}),mt=t=>{const e=/([0-9]+)\.([0-9]+)\.([0-9]+)(?:(\-.+)?)/.exec(t);return e?ft(dt(e[1]),dt(e[2]),dt(e[3])):ft(0,0,0)},gt=(t,e)=>!!t&&-1===((t,e)=>{const n=pt(t.major,e.major);if(0!==n)return n;const r=pt(t.minor,e.minor);if(0!==r)return r;const o=pt(t.patch,e.patch);return 0!==o?o:0})((t=>mt((t=>[t.majorVersion,t.minorVersion].join(".").split(".").slice(0,3).join("."))(t)))(t),mt(e)),yt=mt("8.3.0"),kt=`${yt.major}.${yt.minor}.0`,vt=`${yt.major+1}.0.0`,St=(t,e)=>{const{setup:n,protection:r}=e;return(o,s)=>{if(!((t,e)=>gt(t,kt)?(console.error(`The "${e}" plugin requires at least version ${kt} of TinyMCE.`),!1):!!gt(t,vt)||(console.error(`The "${e}" plugin requires at least version ${kt} of TinyMCE but less than ${vt}.`),!1))(tinymce,t)||((t,e)=>!!(t=>{var e;const n=null===(e=t.options.get("license_key"))||void 0===e?void 0:e.toLowerCase(),r=t.options.get("online_license_key");return d(r)&&"gpl"===n})(t)&&(((t,e)=>{const{console:n,editor:r}=e;p(r)&&(t._skinLoaded?Q(t,r):t.on("SkinLoaded",(()=>{Q(t,r)}))),p(n)&&Y(n)})(t,{console:{type:"error",message:[`The "${e}" plugin requires a valid TinyMCE license key.`,"Read more: https://www.tiny.cloud/docs/tinymce/latest/license-key/"].join(" ")}}),!0))(o,t))return{};const i=(t=>{const{protect:e=!0,events:n,commands:r,ui:o,api:s}=null!=t?t:{};return{protect:e,events:X(n,false),commands:X(r,true),ui:X(o,true),api:X(s,true)}})(r),a=((t="pre-validation")=>{const e=(t=>{let e=t;return{get:()=>e,set:t=>{e=t}}})(t),n=new Set;let r=!1;const{enableLogging:o=!1}={},s=(t,...e)=>{o&&console.log(`[StatusProvider] ${t}`,...e)};return{setStatus:t=>{const r=e.get();if(r===t)return s("Status unchanged:",t),!1;e.set(t),s("Status changed:",r,"->",t);const o={currentStatus:t,previousStatus:r},i=Array.from(n);return _(i,(t=>{t(o.currentStatus,o.previousStatus)})),!0},onStatusChange:t=>(n.add(t),s("Callback registered, total listeners:",n.size),()=>{n.delete(t)&&s("Callback unregistered, remaining listeners:",n.size)}),getStatus:e.get,hasListeners:()=>n.size>0,destroy:()=>{r||(s("Destroying StatusProvider, clearing",n.size,"listeners"),n.clear(),r=!0)}}})(),l=((t,e,n)=>{const r=`commercial-license-${e}`;return t.ui.registry.addContext(r,(()=>"invalid"!==n.getStatus()&&!t.mode.isReadOnly())),t.licenseKeyManager.validate({plugin:e}).then((t=>{n.setStatus(t?"valid":"invalid")}),(t=>{console.error(t),console.error(`An unknown error occurred when trying to validate "${e}" plugin.`),n.setStatus("invalid")})),{ui:{context:r}}})(o,t,a),c=i.protect?ht(o,{statusProvider:a,uiContext:l.ui.context,debug:e.debug||!1,protection:i}):o,u=((t,e)=>({pluginCode:t,enforcer:{isInvalid:()=>"invalid"===e.getStatus(),onInvalid:t=>e.onStatusChange(((e,n)=>{"invalid"===e&&t(e,n)}))}}))(t,a);return((t,e,n,r)=>{if(e.protect&&e.api.protect&&p(t)){const s=Z(e.api);return(o=t=>"invalid"===n.getStatus()&&s(t),(t,e)=>B(t,((t,n)=>f(t)?(...r)=>{if(o(n.toLowerCase())){const t=`Method "${p(e)?`${e}.`:""}${n}" is not available due to license key restrictions.`,r=new Error(t);throw console.error(t),r}return t(...r)}:t)))(t,r)}var o;return t})(n(c,s,u),i,a,t)}},bt=t=>{if(null==t)throw new Error("Node cannot be null or undefined");return{dom:t}},Ct=(t,e)=>{const n=(e||document).createElement(t);return bt(n)},wt=bt,xt=(t,e)=>{const n=t.dom;if(1!==n.nodeType)return!1;{const t=n;if(void 0!==t.matches)return t.matches(e);if(void 0!==t.msMatchesSelector)return t.msMatchesSelector(e);if(void 0!==t.webkitMatchesSelector)return t.webkitMatchesSelector(e);if(void 0!==t.mozMatchesSelector)return t.mozMatchesSelector(e);throw new Error("Browser lacks native selectors")}},At=Object.getPrototypeOf,Lt=t=>{const e=K("ownerDocument.defaultView",t);return i(t)&&((t=>((t,e)=>{const n=((t,e)=>K(t,e))(t,e);if(null==n)throw new Error(t+" not available on this browser");return n})("HTMLElement",t))(e).prototype.isPrototypeOf(t)||/^HTML\w*Element$/.test(At(t).constructor.name))},Et=t=>e=>(t=>t.dom.nodeType)(e)===t,Tt=Et(1),Ot=Et(9),Pt=Et(11),_t=t=>wt(t.dom.ownerDocument),It=t=>Ot(t)?t:_t(t),Rt=t=>P(t.dom.childNodes,wt),jt=t=>wt(t.dom.getRootNode()),Nt=t=>{const e=wt((t=>{if(p(t.target)){const e=wt(t.target);if(Tt(e)&&p(e.dom.shadowRoot)&&t.composed&&t.composedPath){const e=t.composedPath();if(e)return(t=>0<t.length?x.some(t[0]):x.none())(e)}}return x.from(t.target)})(t).getOr(t.target)),n=()=>t.stopPropagation(),r=()=>t.preventDefault(),o=y(r,n);return((t,e,n,r,o,s,i)=>({target:t,x:e,y:n,stop:r,prevent:o,kill:s,raw:i}))(e,t.clientX,t.clientY,n,r,o,t)},$t=(t,e,n,r)=>{t.dom.removeEventListener(e,n,r)},Mt=w,Dt=(t,e,n)=>((t,e,n,r)=>((t,e,n,r,o)=>{const s=((t,e)=>n=>{t(n)&&e(Nt(n))})(n,r);return t.dom.addEventListener(e,s,o),{unbind:S($t,t,e,s,o)}})(t,e,n,r,!1))(t,e,Mt,n),Bt=(t,e)=>{t.dom.appendChild(e.dom)},Ut=(t,e,n)=>{((t,e,n)=>{if(!(s(n)||u(n)||m(n)))throw console.error("Invalid call to Attribute.set. Key ",e,":: Value ",n,":: Element ",t),new Error("Attribute value was not simple");t.setAttribute(e,n+"")})(t.dom,e,n)},Vt=t=>{const e=t.dom;null!==e.parentNode&&e.parentNode.removeChild(e)},zt=(t,e)=>{const n=_t(t).dom,r=wt(n.createDocumentFragment()),o=((t,e)=>{const n=(e||document).createElement("div");return n.innerHTML=t,Rt(wt(n))})(e,n);var s;s=r,_(o,(t=>{Bt(s,t)})),(t=>{t.dom.textContent="",_(Rt(t),(t=>{Vt(t)}))})(t),Bt(t,r)},Ft=t=>void 0!==t.style&&f(t.style.getPropertyValue),Wt=t=>{const e=t.dom.body;if(null==e)throw new Error("Body is not available yet");return wt(e)},qt=(t,e,n)=>{if(!s(n))throw console.error("Invalid call to CSS.set. Property ",e,":: Value ",n,":: Element ",t),new Error("CSS value must be a string: "+n);Ft(t)&&t.style.setProperty(e,n)},Ht=(t,e)=>{const n=t.dom;D(e,((t,e)=>{qt(n,e,t)}))},Gt=(t,e)=>(t=>{return(n=t.dom.childNodes,r=t=>(t=>xt(t,e))(wt(t)),((t,e,n)=>{for(let r=0,o=t.length;r<o;r++){const o=t[r];if(e(o,r))return x.some(o);if(n(o,r))break}return x.none()})(n,r,C)).map(wt);var n,r})(t),Jt=(t,e)=>{(t=>void 0!==t.dom.classList)(t)?t.dom.classList.add(e):((t,e)=>{((t,e,n)=>{const r=((t,e)=>{const n=((t,e)=>{const n=t.dom.getAttribute(e);return null===n?void 0:n})(t,e);return void 0===n||""===n?[]:n.split(" ")})(t,e),o=r.concat([n]);Ut(t,e,o.join(" "))})(t,"class",e)})(t,e)};var Kt=Object.create,Qt=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,Xt=Object.getOwnPropertyNames,Zt=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty,ee=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ne=(t,e)=>{for(var n in e)Qt(t,n,{get:e[n],enumerable:!0})},re=ee((t=>{var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");t.encode=function(t){if(0<=t&&t<e.length)return e[t];throw new TypeError("Must be between 0 and 63: "+t)},t.decode=function(t){return 65<=t&&t<=90?t-65:97<=t&&t<=122?t-97+26:48<=t&&t<=57?t-48+52:43==t?62:47==t?63:-1}})),oe=ee((t=>{var e=re();t.encode=function(t){var n,r,o="",s=(r=t)<0?1+(-r<<1):0+(r<<1);do{n=31&s,(s>>>=5)>0&&(n|=32),o+=e.encode(n)}while(s>0);return o},t.decode=function(t,n,r){var o,s,i=t.length,a=0,l=0;do{if(n>=i)throw new Error("Expected more digits in base 64 VLQ value.");if(-1===(s=e.decode(t.charCodeAt(n++))))throw new Error("Invalid base64 digit: "+t.charAt(n-1));o=!!(32&s),a+=(s&=31)<<l,l+=5}while(o);r.value=function(t){var e=t>>1;return 1&~t?e:-e}(a),r.rest=n}})),se=ee((t=>{t.getArg=function(t,e,n){if(e in t)return t[e];if(3===arguments.length)return n;throw new Error('"'+e+'" is a required argument.')};var e=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,n=/^data:.+\,.+$/;function r(t){var n=t.match(e);return n?{scheme:n[1],auth:n[2],host:n[3],port:n[4],path:n[5]}:null}function o(t){var e="";return t.scheme&&(e+=t.scheme+":"),e+="//",t.auth&&(e+=t.auth+"@"),t.host&&(e+=t.host),t.port&&(e+=":"+t.port),t.path&&(e+=t.path),e}t.urlParse=r,t.urlGenerate=o;var s,i,a=(s=function(e){var n=e,s=r(e);if(s){if(!s.path)return e;n=s.path}for(var i=t.isAbsolute(n),a=[],l=0,c=0;;){if(l=c,-1===(c=n.indexOf("/",l))){a.push(n.slice(l));break}for(a.push(n.slice(l,c));c<n.length&&"/"===n[c];)c++}var u,h=0;for(c=a.length-1;c>=0;c--)"."===(u=a[c])?a.splice(c,1):".."===u?h++:h>0&&(""===u?(a.splice(c+1,h),h=0):(a.splice(c,2),h--));return""===(n=a.join("/"))&&(n=i?"/":"."),s?(s.path=n,o(s)):n},i=[],function(t){for(var e=0;e<i.length;e++)if(i[e].input===t){var n=i[0];return i[0]=i[e],i[e]=n,i[0].result}var r=s(t);return i.unshift({input:t,result:r}),i.length>32&&i.pop(),r});function l(t,e){""===t&&(t="."),""===e&&(e=".");var s=r(e),i=r(t);if(i&&(t=i.path||"/"),s&&!s.scheme)return i&&(s.scheme=i.scheme),o(s);if(s||e.match(n))return e;if(i&&!i.host&&!i.path)return i.host=e,o(i);var l="/"===e.charAt(0)?e:a(t.replace(/\/+$/,"")+"/"+e);return i?(i.path=l,o(i)):l}t.normalize=a,t.join=l,t.isAbsolute=function(t){return"/"===t.charAt(0)||e.test(t)},t.relative=function(t,e){""===t&&(t="."),t=t.replace(/\/$/,"");for(var n=0;0!==e.indexOf(t+"/");){var r=t.lastIndexOf("/");if(r<0||(t=t.slice(0,r)).match(/^([^\/]+:\/)?\/*$/))return e;++n}return Array(n+1).join("../")+e.substr(t.length+1)};var c=!("__proto__"in Object.create(null));function u(t){return t}function h(t){if(!t)return!1;var e=t.length;if(e<9||95!==t.charCodeAt(e-1)||95!==t.charCodeAt(e-2)||111!==t.charCodeAt(e-3)||116!==t.charCodeAt(e-4)||111!==t.charCodeAt(e-5)||114!==t.charCodeAt(e-6)||112!==t.charCodeAt(e-7)||95!==t.charCodeAt(e-8)||95!==t.charCodeAt(e-9))return!1;for(var n=e-10;n>=0;n--)if(36!==t.charCodeAt(n))return!1;return!0}function d(t,e){return t===e?0:null===t?1:null===e?-1:t>e?1:-1}t.toSetString=c?u:function(t){return h(t)?"$"+t:t},t.fromSetString=c?u:function(t){return h(t)?t.slice(1):t},t.compareByOriginalPositions=function(t,e,n){var r=d(t.source,e.source);return 0!==r||0!=(r=t.originalLine-e.originalLine)||0!=(r=t.originalColumn-e.originalColumn)||n||0!=(r=t.generatedColumn-e.generatedColumn)||0!=(r=t.generatedLine-e.generatedLine)?r:d(t.name,e.name)},t.compareByOriginalPositionsNoSource=function(t,e,n){var r;return 0!=(r=t.originalLine-e.originalLine)||0!=(r=t.originalColumn-e.originalColumn)||n||0!=(r=t.generatedColumn-e.generatedColumn)||0!=(r=t.generatedLine-e.generatedLine)?r:d(t.name,e.name)},t.compareByGeneratedPositionsDeflated=function(t,e,n){var r=t.generatedLine-e.generatedLine;return 0!==r||0!=(r=t.generatedColumn-e.generatedColumn)||n||0!==(r=d(t.source,e.source))||0!=(r=t.originalLine-e.originalLine)||0!=(r=t.originalColumn-e.originalColumn)?r:d(t.name,e.name)},t.compareByGeneratedPositionsDeflatedNoLine=function(t,e,n){var r=t.generatedColumn-e.generatedColumn;return 0!==r||n||0!==(r=d(t.source,e.source))||0!=(r=t.originalLine-e.originalLine)||0!=(r=t.originalColumn-e.originalColumn)?r:d(t.name,e.name)},t.compareByGeneratedPositionsInflated=function(t,e){var n=t.generatedLine-e.generatedLine;return 0!==n||0!=(n=t.generatedColumn-e.generatedColumn)||0!==(n=d(t.source,e.source))||0!=(n=t.originalLine-e.originalLine)||0!=(n=t.originalColumn-e.originalColumn)?n:d(t.name,e.name)},t.parseSourceMapInput=function(t){return JSON.parse(t.replace(/^\)]}'[^\n]*\n/,""))},t.computeSourceURL=function(t,e,n){if(e=e||"",t&&("/"!==t[t.length-1]&&"/"!==e[0]&&(t+="/"),e=t+e),n){var s=r(n);if(!s)throw new Error("sourceMapURL could not be parsed");if(s.path){var i=s.path.lastIndexOf("/");i>=0&&(s.path=s.path.substring(0,i+1))}e=l(o(s),e)}return a(e)}})),ie=ee((t=>{var e=se(),n=Object.prototype.hasOwnProperty,r=typeof Map<"u";function o(){this._array=[],this._set=r?new Map:Object.create(null)}o.fromArray=function(t,e){for(var n=new o,r=0,s=t.length;r<s;r++)n.add(t[r],e);return n},o.prototype.size=function(){return r?this._set.size:Object.getOwnPropertyNames(this._set).length},o.prototype.add=function(t,o){var s=r?t:e.toSetString(t),i=r?this.has(t):n.call(this._set,s),a=this._array.length;(!i||o)&&this._array.push(t),i||(r?this._set.set(t,a):this._set[s]=a)},o.prototype.has=function(t){if(r)return this._set.has(t);var o=e.toSetString(t);return n.call(this._set,o)},o.prototype.indexOf=function(t){if(r){var o=this._set.get(t);if(o>=0)return o}else{var s=e.toSetString(t);if(n.call(this._set,s))return this._set[s]}throw new Error('"'+t+'" is not in the set.')},o.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)},o.prototype.toArray=function(){return this._array.slice()},t.ArraySet=o})),ae=ee((t=>{var e=se();function n(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}n.prototype.unsortedForEach=function(t,e){this._array.forEach(t,e)},n.prototype.add=function(t){!function(t,n){var r=t.generatedLine,o=n.generatedLine,s=t.generatedColumn,i=n.generatedColumn;return o>r||o==r&&i>=s||e.compareByGeneratedPositionsInflated(t,n)<=0}(this._last,t)?(this._sorted=!1,this._array.push(t)):(this._last=t,this._array.push(t))},n.prototype.toArray=function(){return this._sorted||(this._array.sort(e.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},t.MappingList=n})),le=ee((t=>{var e=oe(),n=se(),r=ie().ArraySet,o=ae().MappingList;function s(t){t||(t={}),this._file=n.getArg(t,"file",null),this._sourceRoot=n.getArg(t,"sourceRoot",null),this._skipValidation=n.getArg(t,"skipValidation",!1),this._sources=new r,this._names=new r,this._mappings=new o,this._sourcesContents=null}s.prototype._version=3,s.fromSourceMap=function(t){var e=t.sourceRoot,r=new s({file:t.file,sourceRoot:e});return t.eachMapping((function(t){var o={generated:{line:t.generatedLine,column:t.generatedColumn}};null!=t.source&&(o.source=t.source,null!=e&&(o.source=n.relative(e,o.source)),o.original={line:t.originalLine,column:t.originalColumn},null!=t.name&&(o.name=t.name)),r.addMapping(o)})),t.sources.forEach((function(o){var s=o;null!==e&&(s=n.relative(e,o)),r._sources.has(s)||r._sources.add(s);var i=t.sourceContentFor(o);null!=i&&r.setSourceContent(o,i)})),r},s.prototype.addMapping=function(t){var e=n.getArg(t,"generated"),r=n.getArg(t,"original",null),o=n.getArg(t,"source",null),s=n.getArg(t,"name",null);this._skipValidation||this._validateMapping(e,r,o,s),null!=o&&(o=String(o),this._sources.has(o)||this._sources.add(o)),null!=s&&(s=String(s),this._names.has(s)||this._names.add(s)),this._mappings.add({generatedLine:e.line,generatedColumn:e.column,originalLine:null!=r&&r.line,originalColumn:null!=r&&r.column,source:o,name:s})},s.prototype.setSourceContent=function(t,e){var r=t;null!=this._sourceRoot&&(r=n.relative(this._sourceRoot,r)),null!=e?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[n.toSetString(r)]=e):this._sourcesContents&&(delete this._sourcesContents[n.toSetString(r)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},s.prototype.applySourceMap=function(t,e,o){var s=e;if(null==e){if(null==t.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');s=t.file}var i=this._sourceRoot;null!=i&&(s=n.relative(i,s));var a=new r,l=new r;this._mappings.unsortedForEach((function(e){if(e.source===s&&null!=e.originalLine){var r=t.originalPositionFor({line:e.originalLine,column:e.originalColumn});null!=r.source&&(e.source=r.source,null!=o&&(e.source=n.join(o,e.source)),null!=i&&(e.source=n.relative(i,e.source)),e.originalLine=r.line,e.originalColumn=r.column,null!=r.name&&(e.name=r.name))}var c=e.source;null!=c&&!a.has(c)&&a.add(c);var u=e.name;null!=u&&!l.has(u)&&l.add(u)}),this),this._sources=a,this._names=l,t.sources.forEach((function(e){var r=t.sourceContentFor(e);null!=r&&(null!=o&&(e=n.join(o,e)),null!=i&&(e=n.relative(i,e)),this.setSourceContent(e,r))}),this)},s.prototype._validateMapping=function(t,e,n,r){if(e&&"number"!=typeof e.line&&"number"!=typeof e.column)throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0)||e||n||r){if(t&&"line"in t&&"column"in t&&e&&"line"in e&&"column"in e&&t.line>0&&t.column>=0&&e.line>0&&e.column>=0&&n)return;throw new Error("Invalid mapping: "+JSON.stringify({generated:t,source:n,original:e,name:r}))}},s.prototype._serializeMappings=function(){for(var t,r,o,s,i=0,a=1,l=0,c=0,u=0,h=0,d="",p=this._mappings.toArray(),f=0,m=p.length;f<m;f++){if(t="",(r=p[f]).generatedLine!==a)for(i=0;r.generatedLine!==a;)t+=";",a++;else if(f>0){if(!n.compareByGeneratedPositionsInflated(r,p[f-1]))continue;t+=","}t+=e.encode(r.generatedColumn-i),i=r.generatedColumn,null!=r.source&&(s=this._sources.indexOf(r.source),t+=e.encode(s-h),h=s,t+=e.encode(r.originalLine-1-c),c=r.originalLine-1,t+=e.encode(r.originalColumn-l),l=r.originalColumn,null!=r.name&&(o=this._names.indexOf(r.name),t+=e.encode(o-u),u=o)),d+=t}return d},s.prototype._generateSourcesContent=function(t,e){return t.map((function(t){if(!this._sourcesContents)return null;null!=e&&(t=n.relative(e,t));var r=n.toSetString(t);return Object.prototype.hasOwnProperty.call(this._sourcesContents,r)?this._sourcesContents[r]:null}),this)},s.prototype.toJSON=function(){var t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(t.file=this._file),null!=this._sourceRoot&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t},s.prototype.toString=function(){return JSON.stringify(this.toJSON())},t.SourceMapGenerator=s}));function ce(t){return t>=48&&t<=57}function ue(t){return ce(t)||t>=65&&t<=70||t>=97&&t<=102}function he(t){return t>=65&&t<=90}function de(t){return function(t){return he(t)||function(t){return t>=97&&t<=122}(t)}(t)||function(t){return t>=128}(t)||95===t}function pe(t){return de(t)||ce(t)||45===t}function fe(t){return t>=0&&t<=8||11===t||t>=14&&t<=31||127===t}function me(t){return 10===t||13===t||12===t}function ge(t){return me(t)||32===t||9===t}function ye(t,e){return!(92!==t||me(e)||0===e)}function ke(t,e,n){return 45===t?de(e)||45===e||ye(e,n):!!de(t)||92===t&&ye(t,e)}function ve(t,e,n){return 43===t||45===t?ce(e)?2:46===e&&ce(n)?3:0:46===t?ce(e)?2:0:ce(t)?1:0}function Se(t){return 65279===t||65534===t?1:0}var be=new Array(128),Ce=130;for(let t=0;t<be.length;t++)be[t]=(ge(t)?Ce:ce(t)&&131)||de(t)&&132||fe(t)&&133||t||128;function we(t){return t<128?be[t]:132}function xe(t,e){return e<t.length?t.charCodeAt(e):0}function Ae(t,e,n){return 13===n&&10===xe(t,e+1)?2:1}function Le(t,e,n){let r=t.charCodeAt(e);return he(r)&&(r|=32),r===n}function Ee(t,e,n,r){if(n-e!==r.length||e<0||n>t.length)return!1;for(let o=e;o<n;o++){let n=r.charCodeAt(o-e),s=t.charCodeAt(o);if(he(s)&&(s|=32),s!==n)return!1}return!0}function Te(t,e){for(;e<t.length&&ge(t.charCodeAt(e));e++);return e}function Oe(t,e){for(;e<t.length&&ce(t.charCodeAt(e));e++);return e}function Pe(t,e){if(ue(xe(t,(e+=2)-1))){for(let n=Math.min(t.length,e+5);e<n&&ue(xe(t,e));e++);let n=xe(t,e);ge(n)&&(e+=Ae(t,e,n))}return e}function _e(t,e){for(;e<t.length;e++){let n=t.charCodeAt(e);if(!pe(n)){if(ye(n,xe(t,e+1))){e=Pe(t,e)-1;continue}break}}return e}function Ie(t,e){let n=t.charCodeAt(e);if((43===n||45===n)&&(n=t.charCodeAt(e+=1)),ce(n)&&(e=Oe(t,e+1),n=t.charCodeAt(e)),46===n&&ce(t.charCodeAt(e+1))&&(e=Oe(t,e+=2)),Le(t,e,101)){let r=0;n=t.charCodeAt(e+1),(45===n||43===n)&&(r=1,n=t.charCodeAt(e+2)),ce(n)&&(e=Oe(t,e+1+r+1))}return e}function Re(t,e){for(;e<t.length;e++){let n=t.charCodeAt(e);if(41===n){e++;break}ye(n,xe(t,e+1))&&(e=Pe(t,e))}return e}function je(t){if(1===t.length&&!ue(t.charCodeAt(0)))return t[0];let e=parseInt(t,16);return(0===e||e>=55296&&e<=57343||e>1114111)&&(e=65533),String.fromCodePoint(e)}var Ne=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token"];function $e(t=null,e){return null===t||t.length<e?new Uint32Array(Math.max(e+1024,16384)):t}function Me(t){let e=t.source,n=e.length,r=e.length>0?Se(e.charCodeAt(0)):0,o=$e(t.lines,n),s=$e(t.columns,n),i=t.startLine,a=t.startColumn;for(let t=r;t<n;t++){let r=e.charCodeAt(t);o[t]=i,s[t]=a++,(10===r||13===r||12===r)&&(13===r&&t+1<n&&10===e.charCodeAt(t+1)&&(t++,o[t]=i,s[t]=a),i++,a=1)}o[n]=i,s[n]=a,t.lines=o,t.columns=s,t.computed=!0}var De=class{constructor(){this.lines=null,this.columns=null,this.computed=!1}setSource(t,e=0,n=1,r=1){this.source=t,this.startOffset=e,this.startLine=n,this.startColumn=r,this.computed=!1}getLocation(t,e){return this.computed||Me(this),{source:e,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,e,n){return this.computed||Me(this),{source:n,start:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]},end:{offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}}}},Be=16777215,Ue=24,Ve=new Map([[2,22],[21,22],[19,20],[23,24]]),ze=class{constructor(t,e){this.setSource(t,e)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(t="",e=()=>{}){let n=(t=String(t||"")).length,r=$e(this.offsetAndType,t.length+1),o=$e(this.balance,t.length+1),s=0,i=0,a=0,l=-1;for(this.offsetAndType=null,this.balance=null,e(t,((t,e,c)=>{switch(t){default:o[s]=n;break;case i:{let t=a&Be;for(a=o[t],i=a>>Ue,o[s]=t,o[t++]=s;t<s;t++)o[t]===n&&(o[t]=s);break}case 21:case 2:case 19:case 23:o[s]=a,i=Ve.get(t),a=i<<Ue|s}r[s++]=t<<Ue|c,-1===l&&(l=e)})),r[s]=0|n,o[s]=n,o[n]=n;0!==a;){let t=a&Be;a=o[t],o[t]=n}this.source=t,this.firstCharOffset=-1===l?0:l,this.tokenCount=s,this.offsetAndType=r,this.balance=o,this.reset(),this.next()}lookupType(t){return(t+=this.tokenIndex)<this.tokenCount?this.offsetAndType[t]>>Ue:0}lookupOffset(t){return(t+=this.tokenIndex)<this.tokenCount?this.offsetAndType[t-1]&Be:this.source.length}lookupValue(t,e){return(t+=this.tokenIndex)<this.tokenCount&&Ee(this.source,this.offsetAndType[t-1]&Be,this.offsetAndType[t]&Be,e)}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&Be:this.offsetAndType[this.tokenCount]&Be:this.firstCharOffset}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBalanceEdge(t){return this.balance[this.tokenIndex]<t}isDelim(t,e){return e?9===this.lookupType(e)&&this.source.charCodeAt(this.lookupOffset(e))===t:9===this.tokenType&&this.source.charCodeAt(this.tokenStart)===t}skip(t){let e=this.tokenIndex+t;e<this.tokenCount?(this.tokenIndex=e,this.tokenStart=this.offsetAndType[e-1]&Be,e=this.offsetAndType[e],this.tokenType=e>>Ue,this.tokenEnd=e&Be):(this.tokenIndex=this.tokenCount,this.next())}next(){let t=this.tokenIndex+1;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=this.tokenEnd,t=this.offsetAndType[t],this.tokenType=t>>Ue,this.tokenEnd=t&Be):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=0,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;13===this.tokenType||25===this.tokenType;)this.next()}skipUntilBalanced(t,e){let n,r,o=t;t:for(;o<this.tokenCount&&(n=this.balance[o],!(n<t));o++)switch(r=o>0?this.offsetAndType[o-1]&Be:this.firstCharOffset,e(this.source.charCodeAt(r))){case 1:break t;case 2:o++;break t;default:this.balance[n]===o&&(o=n)}this.skip(o-this.tokenIndex)}forEachToken(t){for(let e=0,n=this.firstCharOffset;e<this.tokenCount;e++){let r=n,o=this.offsetAndType[e],s=o&Be;n=s,t(o>>Ue,r,s,e)}}dump(){let t=new Array(this.tokenCount);return this.forEachToken(((e,n,r,o)=>{t[o]={idx:o,type:Ne[e],chunk:this.source.substring(n,r),balance:this.balance[o]}})),t}};function Fe(t,e){function n(e){return e<a?t.charCodeAt(e):0}function r(){return c=Ie(t,c),ke(n(c),n(c+1),n(c+2))?(i=12,void(c=_e(t,c))):37===n(c)?(i=11,void c++):void(i=10)}function o(){let e=c;return c=_e(t,c),Ee(t,e,c,"url")&&40===n(c)?(c=Te(t,c+1),34===n(c)||39===n(c)?(i=2,void(c=e+4)):void function(){for(i=7,c=Te(t,c);c<t.length;c++){let e=t.charCodeAt(c);switch(we(e)){case 41:return void c++;case Ce:return c=Te(t,c),41===n(c)||c>=t.length?void(c<t.length&&c++):(c=Re(t,c),void(i=8));case 34:case 39:case 40:case 133:return c=Re(t,c),void(i=8);case 92:if(ye(e,n(c+1))){c=Pe(t,c)-1;break}return c=Re(t,c),void(i=8)}}}()):40===n(c)?(i=2,void c++):void(i=1)}function s(e){for(e||(e=n(c++)),i=5;c<t.length;c++){let r=t.charCodeAt(c);switch(we(r)){case e:return void c++;case Ce:if(me(r))return c+=Ae(t,c,r),void(i=6);break;case 92:if(c===t.length-1)break;let o=n(c+1);me(o)?c+=Ae(t,c+1,o):ye(r,o)&&(c=Pe(t,c)-1)}}}let i,a=(t=String(t||"")).length,l=Se(n(0)),c=l;for(;c<a;){let a=t.charCodeAt(c);switch(we(a)){case Ce:i=13,c=Te(t,c+1);break;case 34:s();break;case 35:pe(n(c+1))||ye(n(c+1),n(c+2))?(i=4,c=_e(t,c+1)):(i=9,c++);break;case 39:s();break;case 40:i=21,c++;break;case 41:i=22,c++;break;case 43:ve(a,n(c+1),n(c+2))?r():(i=9,c++);break;case 44:i=18,c++;break;case 45:ve(a,n(c+1),n(c+2))?r():45===n(c+1)&&62===n(c+2)?(i=15,c+=3):ke(a,n(c+1),n(c+2))?o():(i=9,c++);break;case 46:ve(a,n(c+1),n(c+2))?r():(i=9,c++);break;case 47:42===n(c+1)?(i=25,c=t.indexOf("*/",c+2),c=-1===c?t.length:c+2):(i=9,c++);break;case 58:i=16,c++;break;case 59:i=17,c++;break;case 60:33===n(c+1)&&45===n(c+2)&&45===n(c+3)?(i=14,c+=4):(i=9,c++);break;case 64:ke(n(c+1),n(c+2),n(c+3))?(i=3,c=_e(t,c+1)):(i=9,c++);break;case 91:i=19,c++;break;case 92:ye(a,n(c+1))?o():(i=9,c++);break;case 93:i=20,c++;break;case 123:i=23,c++;break;case 125:i=24,c++;break;case 131:r();break;case 132:o();break;default:i=9,c++}e(i,l,l=c)}}var We,qe=(We=le(),((t,e,n,r)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let n of Xt(e))!te.call(t,n)&&"default"!==n&&Qt(t,n,{get:()=>e[n],enumerable:!(r=Yt(e,n))||r.enumerable});return t})((t=>Qt(t,"__esModule",{value:!0}))(Qt(null!=We?Kt(Zt(We)):{},"default",{value:We,enumerable:!0})),We)),He=new Set(["Atrule","Selector","Declaration"]),Ge={};ne(Ge,{safe:()=>Ze,spec:()=>Xe});var Je=(t,e)=>{if(9===t&&(t=e),"string"==typeof t){let e=t.charCodeAt(0);return e>127?32768:e<<8}return t},Ke=[[1,1],[1,2],[1,7],[1,8],[1,"-"],[1,10],[1,11],[1,12],[1,15],[1,21],[3,1],[3,2],[3,7],[3,8],[3,"-"],[3,10],[3,11],[3,12],[3,15],[4,1],[4,2],[4,7],[4,8],[4,"-"],[4,10],[4,11],[4,12],[4,15],[12,1],[12,2],[12,7],[12,8],[12,"-"],[12,10],[12,11],[12,12],[12,15],["#",1],["#",2],["#",7],["#",8],["#","-"],["#",10],["#",11],["#",12],["#",15],["-",1],["-",2],["-",7],["-",8],["-","-"],["-",10],["-",11],["-",12],["-",15],[10,1],[10,2],[10,7],[10,8],[10,10],[10,11],[10,12],[10,"%"],[10,15],["@",1],["@",2],["@",7],["@",8],["@","-"],["@",15],[".",10],[".",11],[".",12],["+",10],["+",11],["+",12],["/","*"]],Qe=Ke.concat([[1,4],[12,4],[4,4],[3,21],[3,5],[3,16],[11,11],[11,12],[11,2],[11,"-"],[22,1],[22,2],[22,11],[22,12],[22,4],[22,"-"]]);function Ye(t){let e=new Set(t.map((([t,e])=>Je(t)<<16|Je(e))));return function(t,n,r){let o=Je(n,r),s=r.charCodeAt(0);return(45===s&&1!==n&&2!==n&&15!==n||43===s?e.has(t<<16|s<<8):e.has(t<<16|o))&&this.emit(" ",13,!0),o}}var Xe=Ye(Ke),Ze=Ye(Qe);function tn(t,e){if("function"!=typeof e)t.children.forEach(this.node,this);else{let n=null;t.children.forEach((t=>{null!==n&&e.call(this,n),this.node(t),n=t}))}}function en(t){Fe(t,((e,n,r)=>{this.token(e,t.slice(n,r))}))}var nn={};ne(nn,{AnPlusB:()=>pn,Atrule:()=>fn,AtrulePrelude:()=>mn,AttributeSelector:()=>vn,Block:()=>Sn,Brackets:()=>bn,CDC:()=>Cn,CDO:()=>wn,ClassSelector:()=>An,Combinator:()=>En,Comment:()=>Tn,Declaration:()=>On,DeclarationList:()=>Pn,Dimension:()=>_n,Function:()=>In,Hash:()=>Rn,IdSelector:()=>Mn,Identifier:()=>Nn,MediaFeature:()=>Dn,MediaQuery:()=>Bn,MediaQueryList:()=>Un,NestingSelector:()=>zn,Nth:()=>Wn,Number:()=>qn,Operator:()=>Hn,Parentheses:()=>Gn,Percentage:()=>Kn,PseudoClassSelector:()=>Yn,PseudoElementSelector:()=>Zn,Ratio:()=>tr,Raw:()=>rr,Rule:()=>or,Selector:()=>ir,SelectorList:()=>lr,String:()=>pr,StyleSheet:()=>fr,TypeSelector:()=>yr,UnicodeRange:()=>kr,Url:()=>Ar,Value:()=>Lr,WhiteSpace:()=>Er});var rn=43,on=45,sn=110,an=!0;function ln(t,e){let n=this.tokenStart+t,r=this.charCodeAt(n);for((r===rn||r===on)&&(e&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)ce(this.charCodeAt(n))||this.error("Integer is expected",n)}function cn(t){return ln.call(this,0,t)}function un(t,e){if(!this.cmpChar(this.tokenStart+t,e)){let n="";switch(e){case sn:n="N is expected";break;case on:n="HyphenMinus is expected"}this.error(n,this.tokenStart+t)}}function hn(){let t=0,e=0,n=this.tokenType;for(;13===n||25===n;)n=this.lookupType(++t);if(10!==n){if(!this.isDelim(rn,t)&&!this.isDelim(on,t))return null;e=this.isDelim(rn,t)?rn:on;do{n=this.lookupType(++t)}while(13===n||25===n);10!==n&&(this.skip(t),cn.call(this,an))}return t>0&&this.skip(t),0===e&&(n=this.charCodeAt(this.tokenStart),n!==rn&&n!==on&&this.error("Number sign is expected")),cn.call(this,0!==e),e===on?"-"+this.consume(10):this.consume(10)}function dn(){let t=this.tokenStart,e=null,n=null;if(10===this.tokenType)cn.call(this,!1),n=this.consume(10);else if(1===this.tokenType&&this.cmpChar(this.tokenStart,on))switch(e="-1",un.call(this,1,sn),this.tokenEnd-this.tokenStart){case 2:this.next(),n=hn.call(this);break;case 3:un.call(this,2,on),this.next(),this.skipSC(),cn.call(this,an),n="-"+this.consume(10);break;default:un.call(this,2,on),ln.call(this,3,an),this.next(),n=this.substrToCursor(t+2)}else if(1===this.tokenType||this.isDelim(rn)&&1===this.lookupType(1)){let r=0;switch(e="1",this.isDelim(rn)&&(r=1,this.next()),un.call(this,0,sn),this.tokenEnd-this.tokenStart){case 1:this.next(),n=hn.call(this);break;case 2:un.call(this,1,on),this.next(),this.skipSC(),cn.call(this,an),n="-"+this.consume(10);break;default:un.call(this,1,on),ln.call(this,2,an),this.next(),n=this.substrToCursor(t+r+1)}}else if(12===this.tokenType){let r=this.charCodeAt(this.tokenStart),o=r===rn||r===on,s=this.tokenStart+o;for(;s<this.tokenEnd&&ce(this.charCodeAt(s));s++);s===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),un.call(this,s-this.tokenStart,sn),e=this.substring(t,s),s+1===this.tokenEnd?(this.next(),n=hn.call(this)):(un.call(this,s-this.tokenStart+1,on),s+2===this.tokenEnd?(this.next(),this.skipSC(),cn.call(this,an),n="-"+this.consume(10)):(ln.call(this,s-this.tokenStart+2,an),this.next(),n=this.substrToCursor(s+1)))}else this.error();return null!==e&&e.charCodeAt(0)===rn&&(e=e.substr(1)),null!==n&&n.charCodeAt(0)===rn&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(t,this.tokenStart),a:e,b:n}}function pn(t){if(t.a){let e=("+1"===t.a||"1"===t.a?"n":"-1"===t.a&&"-n")||t.a+"n";if(t.b){let n="-"===t.b[0]||"+"===t.b[0]?t.b:"+"+t.b;this.tokenize(e+n)}else this.tokenize(e)}else this.tokenize(t.b)}function fn(t){this.token(3,"@"+t.name),null!==t.prelude&&this.node(t.prelude),t.block?this.node(t.block):this.token(17,";")}function mn(t){this.children(t)}function gn(){this.eof&&this.error("Unexpected end of input");let t=this.tokenStart,e=!1;return this.isDelim(42)?(e=!0,this.next()):this.isDelim(124)||this.eat(1),this.isDelim(124)?61!==this.charCodeAt(this.tokenStart+1)?(this.next(),this.eat(1)):e&&this.error("Identifier is expected",this.tokenEnd):e&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(t,this.tokenStart),name:this.substrToCursor(t)}}function yn(){let t=this.tokenStart,e=this.charCodeAt(t);return 61!==e&&126!==e&&94!==e&&36!==e&&42!==e&&124!==e&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),61!==e&&(this.isDelim(61)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(t)}function kn(){let t,e=this.tokenStart,n=null,r=null,o=null;return this.eat(19),this.skipSC(),t=gn.call(this),this.skipSC(),20!==this.tokenType&&(1!==this.tokenType&&(n=yn.call(this),this.skipSC(),r=5===this.tokenType?this.String():this.Identifier(),this.skipSC()),1===this.tokenType&&(o=this.consume(1),this.skipSC())),this.eat(20),{type:"AttributeSelector",loc:this.getLocation(e,this.tokenStart),name:t,matcher:n,value:r,flags:o}}function vn(t){this.token(9,"["),this.node(t.name),null!==t.matcher&&(this.tokenize(t.matcher),this.node(t.value)),null!==t.flags&&this.token(1,t.flags),this.token(9,"]")}function Sn(t){this.token(23,"{"),this.children(t,(t=>{"Declaration"===t.type&&this.token(17,";")})),this.token(24,"}")}function bn(t){this.token(9,"["),this.children(t),this.token(9,"]")}function Cn(){this.token(15,"--\x3e")}function wn(){this.token(14,"\x3c!--")}function xn(){return this.eatDelim(46),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function An(t){this.token(9,"."),this.token(1,t.name)}function Ln(){let t,e=this.tokenStart;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case 62:case 43:case 126:this.next();break;case 47:this.next(),this.eatIdent("deep"),this.eatDelim(47);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e)}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function En(t){this.tokenize(t.name)}function Tn(t){this.token(25,"/*"+t.value+"*/")}function On(t){this.token(1,t.property),this.token(16,":"),this.node(t.value),t.important&&(this.token(9,"!"),this.token(1,!0===t.important?"important":t.important))}function Pn(t){this.children(t,(t=>{"Declaration"===t.type&&this.token(17,";")}))}function _n(t){this.token(12,t.value+t.unit)}function In(t){this.token(2,t.name+"("),this.children(t),this.token(22,")")}function Rn(t){this.token(4,"#"+t.value)}function jn(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function Nn(t){this.token(1,t.name)}function $n(){let t=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(t,this.tokenStart),name:this.substrToCursor(t+1)}}function Mn(t){this.token(9,"#"+t.name)}function Dn(t){this.token(21,"("),this.token(1,t.name),null!==t.value&&(this.token(16,":"),this.node(t.value)),this.token(22,")")}function Bn(t){this.children(t)}function Un(t){this.children(t,(()=>this.token(18,",")))}function Vn(){let t=this.tokenStart;return this.eatDelim(38),{type:"NestingSelector",loc:this.getLocation(t,this.tokenStart)}}function zn(){this.token(9,"&")}function Fn(){this.skipSC();let t,e=this.tokenStart,n=e,r=null;return t=this.lookupValue(0,"odd")||this.lookupValue(0,"even")?this.Identifier():this.AnPlusB(),n=this.tokenStart,this.skipSC(),this.lookupValue(0,"of")&&(this.next(),r=this.SelectorList(),n=this.tokenStart),{type:"Nth",loc:this.getLocation(e,n),nth:t,selector:r}}function Wn(t){this.node(t.nth),null!==t.selector&&(this.token(1,"of"),this.node(t.selector))}function qn(t){this.token(10,t.value)}function Hn(t){this.tokenize(t.value)}function Gn(t){this.token(21,"("),this.children(t),this.token(22,")")}function Jn(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function Kn(t){this.token(11,t.value+"%")}function Qn(){let t,e,n=this.tokenStart,r=null;return this.eat(16),2===this.tokenType?(t=this.consumeFunctionName(),e=t.toLowerCase(),hasOwnProperty.call(this.pseudo,e)?(this.skipSC(),r=this.pseudo[e].call(this),this.skipSC()):(r=this.createList(),r.push(this.Raw(this.tokenIndex,null,!1))),this.eat(22)):t=this.consume(1),{type:"PseudoClassSelector",loc:this.getLocation(n,this.tokenStart),name:t,children:r}}function Yn(t){this.token(16,":"),null===t.children?this.token(1,t.name):(this.token(2,t.name+"("),this.children(t),this.token(22,")"))}function Xn(){let t,e,n=this.tokenStart,r=null;return this.eat(16),this.eat(16),2===this.tokenType?(t=this.consumeFunctionName(),e=t.toLowerCase(),hasOwnProperty.call(this.pseudo,e)?(this.skipSC(),r=this.pseudo[e].call(this),this.skipSC()):(r=this.createList(),r.push(this.Raw(this.tokenIndex,null,!1))),this.eat(22)):t=this.consume(1),{type:"PseudoElementSelector",loc:this.getLocation(n,this.tokenStart),name:t,children:r}}function Zn(t){this.token(16,":"),this.token(16,":"),null===t.children?this.token(1,t.name):(this.token(2,t.name+"("),this.children(t),this.token(22,")"))}function tr(t){this.token(10,t.left),this.token(9,"/"),this.token(10,t.right)}function er(){return this.tokenIndex>0&&13===this.lookupType(-1)?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function nr(t,e,n){let r,o=this.getTokenStart(t);return this.skipUntilBalanced(t,e||this.consumeUntilBalanceEnd),r=n&&this.tokenStart>o?er.call(this):this.tokenStart,{type:"Raw",loc:this.getLocation(o,r),value:this.substring(o,r)}}function rr(t){this.tokenize(t.value)}function or(t){this.node(t.prelude),this.node(t.block)}function sr(){let t=this.readSequence(this.scope.Selector);return null===this.getFirstListNode(t)&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(t),children:t}}function ir(t){this.children(t)}function ar(){let t=this.createList();for(;!this.eof&&(t.push(this.Selector()),18===this.tokenType);)this.next();return{type:"SelectorList",loc:this.getLocationFromList(t),children:t}}function lr(t){this.children(t,(()=>this.token(18,",")))}var cr=92,ur=34;function hr(t){let e=t.length,n=t.charCodeAt(0),r=n===ur||39===n?1:0,o=1===r&&e>1&&t.charCodeAt(e-1)===n?e-2:e-1,s="";for(let n=r;n<=o;n++){let r=t.charCodeAt(n);if(r===cr){if(n===o){n!==e-1&&(s=t.substr(n+1));break}if(r=t.charCodeAt(++n),ye(cr,r)){let e=n-1,r=Pe(t,e);n=r-1,s+=je(t.substring(e+1,r))}else 13===r&&10===t.charCodeAt(n+1)&&n++}else s+=t[n]}return s}function dr(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:hr(this.consume(5))}}function pr(t){this.token(5,function(t){let e=ur,n="",r=!1;for(let o=0;o<t.length;o++){let s=t.charCodeAt(o);0!==s?s<=31||127===s?(n+="\\"+s.toString(16),r=!0):s===e||s===cr?(n+="\\"+t.charAt(o),r=!1):(r&&(ue(s)||ge(s))&&(n+=" "),n+=t.charAt(o),r=!1):n+="\ufffd"}return'"'+n+'"'}(t.value))}function fr(t){this.children(t)}function mr(){1!==this.tokenType&&!1===this.isDelim(42)&&this.error("Identifier or asterisk is expected"),this.next()}function gr(){let t=this.tokenStart;return this.isDelim(124)?(this.next(),mr.call(this)):(mr.call(this),this.isDelim(124)&&(this.next(),mr.call(this))),{type:"TypeSelector",loc:this.getLocation(t,this.tokenStart),name:this.substrToCursor(t)}}function yr(t){this.tokenize(t.name)}function kr(t){this.tokenize(t.value)}var vr=32,Sr=92,br=34,Cr=39,wr=40,xr=41;function Ar(t){this.token(7,function(t){let e="",n=!1;for(let r=0;r<t.length;r++){let o=t.charCodeAt(r);0!==o?o<=31||127===o?(e+="\\"+o.toString(16),n=!0):o===vr||o===Sr||o===br||o===Cr||o===wr||o===xr?(e+="\\"+t.charAt(r),n=!1):(n&&ue(o)&&(e+=" "),e+=t.charAt(r),n=!1):e+="\ufffd"}return"url("+e+")"}(t.value))}function Lr(t){this.children(t)}function Er(t){this.token(13,t.value)}var Tr=function(t){let e=new Map;for(let n in t.node){let r=t.node[n];"function"==typeof(r.generate||r)&&e.set(n,r.generate||r)}return function(t,n){let r="",o=0,s={node(t){if(!e.has(t.type))throw new Error("Unknown node type: "+t.type);e.get(t.type).call(i,t)},tokenBefore:Ze,token(t,e){o=this.tokenBefore(o,t,e),this.emit(e,t,!1),9===t&&92===e.charCodeAt(0)&&this.emit("\n",13,!0)},emit(t){r+=t},result:()=>r};n&&("function"==typeof n.decorator&&(s=n.decorator(s)),n.sourceMap&&(s=function(t){let e=new qe.SourceMapGenerator,n={line:1,column:0},r={line:0,column:0},o={line:1,column:0},s={generated:o},i=1,a=0,l=!1,c=t.node;t.node=function(t){if(t.loc&&t.loc.start&&He.has(t.type)){let c=t.loc.start.line,u=t.loc.start.column-1;(r.line!==c||r.column!==u)&&(r.line=c,r.column=u,n.line=i,n.column=a,l&&(l=!1,(n.line!==o.line||n.column!==o.column)&&e.addMapping(s)),l=!0,e.addMapping({source:t.loc.source,original:r,generated:n}))}c.call(this,t),l&&He.has(t.type)&&(o.line=i,o.column=a)};let u=t.emit;t.emit=function(t,e,n){for(let e=0;e<t.length;e++)10===t.charCodeAt(e)?(i++,a=0):a++;u(t,e,n)};let h=t.result;return t.result=function(){return l&&e.addMapping(s),{css:h(),map:e}},t}(s)),n.mode in Ge&&(s.tokenBefore=Ge[n.mode]));let i={node:t=>s.node(t),children:tn,token:(t,e)=>s.token(t,e),tokenize:en};return s.node(t),s.result()}}({node:nn}),Or=null,Pr=class{static createItem(t){return{prev:null,next:null,data:t}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(t){return Pr.createItem(t)}allocateCursor(t,e){let n;return null!==Or?(n=Or,Or=Or.cursor,n.prev=t,n.next=e,n.cursor=this.cursor):n={prev:t,next:e,cursor:this.cursor},this.cursor=n,n}releaseCursor(){let{cursor:t}=this;this.cursor=t.cursor,t.prev=null,t.next=null,t.cursor=Or,Or=t}updateCursors(t,e,n,r){let{cursor:o}=this;for(;null!==o;)o.prev===t&&(o.prev=e),o.next===n&&(o.next=r),o=o.cursor}*[Symbol.iterator](){for(let t=this.head;null!==t;t=t.next)yield t.data}get size(){let t=0;for(let e=this.head;null!==e;e=e.next)t++;return t}get isEmpty(){return null===this.head}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(t){let e=null;this.head=null;for(let n of t){let t=Pr.createItem(n);null!==e?e.next=t:this.head=t,t.prev=e,e=t}return this.tail=e,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(t,e=this){let n=this.allocateCursor(null,this.head);for(;null!==n.next;){let r=n.next;n.next=r.next,t.call(e,r.data,r,this)}this.releaseCursor()}forEachRight(t,e=this){let n=this.allocateCursor(this.tail,null);for(;null!==n.prev;){let r=n.prev;n.prev=r.prev,t.call(e,r.data,r,this)}this.releaseCursor()}reduce(t,e,n=this){let r,o=this.allocateCursor(null,this.head),s=e;for(;null!==o.next;)r=o.next,o.next=r.next,s=t.call(n,s,r.data,r,this);return this.releaseCursor(),s}reduceRight(t,e,n=this){let r,o=this.allocateCursor(this.tail,null),s=e;for(;null!==o.prev;)r=o.prev,o.prev=r.prev,s=t.call(n,s,r.data,r,this);return this.releaseCursor(),s}some(t,e=this){for(let n=this.head;null!==n;n=n.next)if(t.call(e,n.data,n,this))return!0;return!1}map(t,e=this){let n=new Pr;for(let r=this.head;null!==r;r=r.next)n.appendData(t.call(e,r.data,r,this));return n}filter(t,e=this){let n=new Pr;for(let r=this.head;null!==r;r=r.next)t.call(e,r.data,r,this)&&n.appendData(r.data);return n}nextUntil(t,e,n=this){if(null===t)return;let r=this.allocateCursor(null,t);for(;null!==r.next;){let t=r.next;if(r.next=t.next,e.call(n,t.data,t,this))break}this.releaseCursor()}prevUntil(t,e,n=this){if(null===t)return;let r=this.allocateCursor(t,null);for(;null!==r.prev;){let t=r.prev;if(r.prev=t.prev,e.call(n,t.data,t,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){let t=new Pr;for(let e of this)t.appendData(e);return t}prepend(t){return this.updateCursors(null,t,this.head,t),null!==this.head?(this.head.prev=t,t.next=this.head):this.tail=t,this.head=t,this}prependData(t){return this.prepend(Pr.createItem(t))}append(t){return this.insert(t)}appendData(t){return this.insert(Pr.createItem(t))}insert(t,e=null){if(null!==e)if(this.updateCursors(e.prev,t,e,t),null===e.prev){if(this.head!==e)throw new Error("before doesn't belong to list");this.head=t,e.prev=t,t.next=e,this.updateCursors(null,t)}else e.prev.next=t,t.prev=e.prev,e.prev=t,t.next=e;else this.updateCursors(this.tail,t,null,t),null!==this.tail?(this.tail.next=t,t.prev=this.tail):this.head=t,this.tail=t;return this}insertData(t,e){return this.insert(Pr.createItem(t),e)}remove(t){if(this.updateCursors(t,t.prev,t,t.next),null!==t.prev)t.prev.next=t.next;else{if(this.head!==t)throw new Error("item doesn't belong to list");this.head=t.next}if(null!==t.next)t.next.prev=t.prev;else{if(this.tail!==t)throw new Error("item doesn't belong to list");this.tail=t.prev}return t.prev=null,t.next=null,t}push(t){this.insert(Pr.createItem(t))}pop(){return null!==this.tail?this.remove(this.tail):null}unshift(t){this.prepend(Pr.createItem(t))}shift(){return null!==this.head?this.remove(this.head):null}prependList(t){return this.insertList(t,this.head)}appendList(t){return this.insertList(t)}insertList(t,e){return null===t.head||(null!=e?(this.updateCursors(e.prev,t.tail,e,t.head),null!==e.prev?(e.prev.next=t.head,t.head.prev=e.prev):this.head=t.head,e.prev=t.tail,t.tail.next=e):(this.updateCursors(this.tail,t.tail,null,t.head),null!==this.tail?(this.tail.next=t.head,t.head.prev=this.tail):this.head=t.head,this.tail=t.tail),t.head=null,t.tail=null),this}replace(t,e){"head"in e?this.insertList(e,t):this.insert(e,t),this.remove(t)}};function _r({source:t,line:e,column:n},r){function o(t,e){return s.slice(t,e).map(((e,n)=>String(t+n+1).padStart(l)+" |"+e)).join("\n")}let s=t.split(/\r\n?|\n|\f/),i=Math.max(1,e-r)-1,a=Math.min(e+r,s.length+1),l=Math.max(4,String(a).length)+1,c=0;(n+=3*(s[e-1].substr(0,n-1).match(/\t/g)||[]).length)>100&&(c=n-60+3,n=58);for(let t=i;t<=a;t++)t>=0&&t<s.length&&(s[t]=s[t].replace(/\t/g," "),s[t]=(c>0&&s[t].length>c?"\u2026":"")+s[t].substr(c,98)+(s[t].length>c+100-1?"\u2026":""));return[o(i,e),new Array(n+l+2).join("-")+"^",o(e,a)].filter(Boolean).join("\n")}function Ir(t,e,n,r,o){return Object.assign(function(t,e){let n=Object.create(SyntaxError.prototype),r=new Error;return Object.assign(n,{name:t,message:e,get stack(){return(r.stack||"").replace(/^(.+\n){1,3}/,`${t}: ${e}\n`)}})}("SyntaxError",t),{source:e,offset:n,line:r,column:o,sourceFragment:t=>_r({source:e,line:r,column:o},isNaN(t)?0:t),get formattedMessage(){return`Parse error: ${t}\n`+_r({source:e,line:r,column:o},2)}})}function Rr(t){let e=this.createList(),n=!1,r={recognizer:t};for(;!this.eof;){switch(this.tokenType){case 25:this.next();continue;case 13:n=!0,this.next();continue}let o=t.getNode.call(this,r);if(void 0===o)break;n&&(t.onWhiteSpace&&t.onWhiteSpace.call(this,o,e,r),n=!1),e.push(o)}return n&&t.onWhiteSpace&&t.onWhiteSpace.call(this,null,e,r),e}var jr=()=>{};function Nr(t){return function(){return this[t]()}}function $r(t){let e=Object.create(null);for(let n in t){let r=t[n],o=r.parse||r;o&&(e[n]=o)}return e}var Mr={parse(){return this.createSingleNodeList(this.SelectorList())}},Dr={parse(){return this.createSingleNodeList(this.Selector())}},Br={parse(){return this.createSingleNodeList(this.Identifier())}},Ur={parse(){return this.createSingleNodeList(this.Nth())}},Vr={dir:Br,has:Mr,lang:Br,matches:Mr,is:Mr,"-moz-any":Mr,"-webkit-any":Mr,where:Mr,not:Mr,"nth-child":Ur,"nth-last-child":Ur,"nth-last-of-type":Ur,"nth-of-type":Ur,slotted:Dr,host:Dr,"host-context":Dr},zr={};ne(zr,{AnPlusB:()=>dn,AttributeSelector:()=>kn,ClassSelector:()=>xn,Combinator:()=>Ln,IdSelector:()=>$n,Identifier:()=>jn,NestingSelector:()=>Vn,Nth:()=>Fn,Percentage:()=>Jn,PseudoClassSelector:()=>Qn,PseudoElementSelector:()=>Xn,Raw:()=>nr,Selector:()=>sr,SelectorList:()=>ar,String:()=>dr,TypeSelector:()=>gr});var Fr=function(t){let e="",n="<unknown>",r=!1,o=jr,s=!1,i=new De,a=Object.assign(new ze,function(t){let e={context:Object.create(null),scope:Object.assign(Object.create(null),t.scope),atrule:$r(t.atrule),pseudo:$r(t.pseudo),node:$r(t.node)};for(let n in t.parseContext)switch(typeof t.parseContext[n]){case"function":e.context[n]=t.parseContext[n];break;case"string":e.context[n]=Nr(t.parseContext[n])}return{config:e,...e,...e.node}}(t||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:Rr,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket:t=>123===t?1:0,consumeUntilLeftCurlyBracketOrSemicolon:t=>123===t||59===t?1:0,consumeUntilExclamationMarkOrSemicolon:t=>33===t||59===t?1:0,consumeUntilSemicolonIncluded:t=>59===t?2:0,createList:()=>new Pr,createSingleNodeList:t=>(new Pr).appendData(t),getFirstListNode:t=>t&&t.first,getLastListNode:t=>t&&t.last,parseWithFallback(t,e){let n=this.tokenIndex;try{return t.call(this)}catch(t){if(s)throw t;let r=e.call(this,n);return s=!0,o(t,r),s=!1,r}},lookupNonWSType(t){let e;do{if(e=this.lookupType(t++),13!==e)return e}while(0!==e);return 0},charCodeAt:t=>t>=0&&t<e.length?e.charCodeAt(t):0,substring:(t,n)=>e.substring(t,n),substrToCursor(t){return this.source.substring(t,this.tokenStart)},cmpChar:(t,n)=>Le(e,t,n),cmpStr:(t,n,r)=>Ee(e,t,n,r),consume(t){let e=this.tokenStart;return this.eat(t),this.substrToCursor(e)},consumeFunctionName(){let t=e.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),t},consumeNumber(t){let n=e.substring(this.tokenStart,Ie(e,this.tokenStart));return this.eat(t),n},eat(t){if(this.tokenType!==t){let e=Ne[t].slice(0,-6).replace(/-/g," ").replace(/^./,(t=>t.toUpperCase())),n=`${/[[\](){}]/.test(e)?`"${e}"`:e} is expected`,r=this.tokenStart;switch(t){case 1:2===this.tokenType||7===this.tokenType?(r=this.tokenEnd-1,n="Identifier is expected but function found"):n="Identifier is expected";break;case 4:this.isDelim(35)&&(this.next(),r++,n="Name is expected");break;case 11:10===this.tokenType&&(r=this.tokenEnd,n="Percent sign is expected")}this.error(n,r)}this.next()},eatIdent(t){(1!==this.tokenType||!1===this.lookupValue(0,t))&&this.error(`Identifier "${t}" is expected`),this.next()},eatDelim(t){this.isDelim(t)||this.error(`Delim "${String.fromCharCode(t)}" is expected`),this.next()},getLocation:(t,e)=>r?i.getLocationRange(t,e,n):null,getLocationFromList(t){if(r){let e=this.getFirstListNode(t),r=this.getLastListNode(t);return i.getLocationRange(null!==e?e.loc.start.offset-i.startOffset:this.tokenStart,null!==r?r.loc.end.offset-i.startOffset:this.tokenStart,n)}return null},error(t,n){let r=typeof n<"u"&&n<e.length?i.getLocation(n):this.eof?i.getLocation(function(t,e){for(;e>=0&&ge(t.charCodeAt(e));e--);return e+1}(e,e.length-1)):i.getLocation(this.tokenStart);throw new Ir(t||"Unexpected input",e,r.offset,r.line,r.column)}});return Object.assign((function(t,l){e=t,l=l||{},a.setSource(e,Fe),i.setSource(e,l.offset,l.line,l.column),n=l.filename||"<unknown>",r=Boolean(l.positions),o="function"==typeof l.onParseError?l.onParseError:jr,s=!1,a.parseAtrulePrelude=!("parseAtrulePrelude"in l)||Boolean(l.parseAtrulePrelude),a.parseRulePrelude=!("parseRulePrelude"in l)||Boolean(l.parseRulePrelude),a.parseValue=!("parseValue"in l)||Boolean(l.parseValue),a.parseCustomProperty="parseCustomProperty"in l&&Boolean(l.parseCustomProperty);let{context:c="default",onComment:u}=l;if(!(c in a.context))throw new Error("Unknown context `"+c+"`");"function"==typeof u&&a.forEachToken(((t,n,r)=>{if(25===t){let t=a.getLocation(n,r),o=Ee(e,r-2,r,"*/")?e.slice(n+2,r-2):e.slice(n+2,r);u(o,t)}}));let h=a.context[c].call(a,l);return a.eof||a.error(),h}),{SyntaxError:Ir,config:a.config})}({parseContext:{default:"SelectorList",selectorList:"SelectorList",selector:"Selector"},scope:{Selector:{onWhiteSpace:function(t,e){null!==e.last&&"Combinator"!==e.last.type&&null!==t&&"Combinator"!==t.type&&e.push({type:"Combinator",loc:null,name:" "})},getNode:function(){switch(this.tokenType){case 19:return this.AttributeSelector();case 4:return this.IdSelector();case 16:return 16===this.lookupType(1)?this.PseudoElementSelector():this.PseudoClassSelector();case 1:return this.TypeSelector();case 10:case 11:return this.Percentage();case 12:46===this.charCodeAt(this.tokenStart)&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:switch(this.charCodeAt(this.tokenStart)){case 43:case 62:case 126:case 47:return this.Combinator();case 46:return this.ClassSelector();case 42:case 124:return this.TypeSelector();case 35:return this.IdSelector();case 38:return this.NestingSelector()}}}}},atrule:{},pseudo:Vr,node:zr}),Wr=(t,e)=>t.a===e.a?t.b===e.b?t.c-e.c:t.b-e.b:t.a-e.a,qr=(t,e)=>0===Wr(t,e),Hr=(t,e)=>Wr(t,e)>0,Gr=(t,e)=>Wr(t,e)<0,Jr=(t,e="ASC")=>{let n=t.sort(Wr);return"DESC"===e?n.reverse():n},Kr=(...t)=>Jr(t,"ASC"),Qr=(...t)=>Jr(t,"DESC"),Yr=(...t)=>Qr(...t)[0],Xr=t=>{let e={a:0,b:0,c:0};return t.children.forEach((t=>{switch(t.type){case"IdSelector":e.a+=1;break;case"AttributeSelector":case"ClassSelector":e.b+=1;break;case"PseudoClassSelector":switch(t.name.toLowerCase()){case"where":break;case"is":case"matches":case"-webkit-any":case"-moz-any":case"any":case"not":case"has":if(t.children){let n=Yr(...Zr(t.children.first));e.a+=n.a,e.b+=n.b,e.c+=n.c}break;case"nth-child":case"nth-last-child":if(e.b+=1,t.children.first.selector){let n=Yr(...Zr(t.children.first.selector));e.a+=n.a,e.b+=n.b,e.c+=n.c}break;case"host-context":case"host":if(e.b+=1,t.children){let n={type:"Selector",children:[]},r=!1;t.children.first.children.forEach((t=>!r&&("Combinator"===t.type?(r=!0,!1):void n.children.push(t))));let o=Zr(n)[0];e.a+=o.a,e.b+=o.b,e.c+=o.c}break;case"after":case"before":case"first-letter":case"first-line":e.c+=1;break;default:e.b+=1}break;case"PseudoElementSelector":switch(t.name){case"slotted":if(e.c+=1,t.children){let n={type:"Selector",children:[]},r=!1;t.children.first.children.forEach((t=>!r&&("Combinator"===t.type?(r=!0,!1):void n.children.push(t))));let o=Zr(n)[0];e.a+=o.a,e.b+=o.b,e.c+=o.c}break;case"view-transition-group":case"view-transition-image-pair":case"view-transition-old":case"view-transition-new":if(t.children&&"*"===t.children.first.value)break;e.c+=1;break;default:e.c+=1}break;case"TypeSelector":let n=t.name;n.includes("|")&&(n=n.split("|")[1]),"*"!==n&&(e.c+=1)}})),new to(e,t)},Zr=t=>{if(!t)return[];let e=(t=>{if("string"==typeof t||t instanceof String)try{return Fr(t,{context:"selectorList"})}catch(e){throw new TypeError(`Could not convert passed in source '${t}' to SelectorList: ${e.message}`)}if(t instanceof Object){if(t.type&&["Selector","SelectorList"].includes(t.type))return t;if(t.type&&"Raw"===t.type)try{return Fr(t.value,{context:"selectorList"})}catch(t){throw new TypeError(`Could not convert passed in source to SelectorList: ${t.message}`)}throw new TypeError("Passed in source is an Object but no AST / AST of the type Selector or SelectorList")}throw new TypeError("Passed in source is not a String nor an Object. I don't know what to do with it.")})(t);if("Selector"===e.type)return[Xr(t)];if("SelectorList"===e.type){let t=[];return e.children.forEach((e=>{let n=Xr(e);t.push(n)})),t}},to=class{constructor(t,e=null){this.value=t,this.selector=e}get a(){return this.value.a}set a(t){throw new Error("Manipulating the port of the specificity directly is not allowed. Instead, directly set a new value")}get b(){return this.value.b}set b(t){throw new Error("Manipulating the port of the specificity directly is not allowed. Instead, directly set a new value")}get c(){return this.value.c}set c(t){throw new Error("Manipulating the port of the specificity directly is not allowed. Instead, directly set a new value")}selectorString(){return"string"==typeof this.selector||this.selector instanceof String?this.selector:this.selector instanceof Object&&"Selector"===this.selector.type?Tr(this.selector):""}toObject(){return this.value}toArray(){return[this.value.a,this.value.b,this.value.c]}toString(){return`(${this.value.a},${this.value.b},${this.value.c})`}toJSON(){return{selector:this.selectorString(),asObject:this.toObject(),asArray:this.toArray(),asString:this.toString()}}isEqualTo(t){return qr(this,t)}isGreaterThan(t){return Hr(this,t)}isLessThan(t){return Gr(this,t)}static calculate(t){return Zr(t)}static compare(t,e){return Wr(t,e)}static equals(t,e){return qr(t,e)}static lessThan(t,e){return Gr(t,e)}static greaterThan(t,e){return Hr(t,e)}static min(...t){return((...t)=>Kr(...t)[0])(...t)}static max(...t){return Yr(...t)}static sortAsc(...t){return Kr(...t)}static sortDesc(...t){return Qr(...t)}};const eo=t=>j(t,(t=>"fulfilled"===t.status?t.value:[t])),no=t=>{const e=new Map,n=t=>{const n=e.get(t);if(p(n))return n;{const n=to.calculate(t)[0];return e.set(t,n),n}};return(t=>{const e=A.call(t,0);return e.sort(((t,e)=>{const r=n(t.selector),o=n(e.selector);return to.compare(r,o)})),e})(t)},ro=t=>{const e=(t=>j(t,(t=>(t=>-1!==t.selector.indexOf(","))(t)?(t=>{const e=t.selector.split(/,(?![^(]*\))/g);return P(e,(e=>{const n=e.trim();return{...t,selector:n}}))})(t):[t])))(t);return no(e)},oo=t=>{const e={};return _(t,(n=>{const r=t.getPropertyValue(n);s(r)&&(e[n]=r)})),e},so=t=>({selector:t.selectorText,styles:oo(t.style)}),io=(t,e)=>e(t).then((async t=>{const n=j(t,(t=>{if(t.type===window.CSSRule.IMPORT_RULE&&p(t.styleSheet))return[io(t.styleSheet,e)];if(t.type===window.CSSRule.STYLE_RULE){const e={status:"fulfilled",value:[so(t)]};return[Promise.resolve([e])]}return[]})),r=await Promise.allSettled(n);return eo(r)}),(t=>Promise.resolve([{status:"rejected",reason:t}]))),ao=(t,e)=>{var n,r;return((t,e)=>{const n={};var r;return((t,e,n,r)=>{D(t,((t,o)=>{(e(t,o)?n:r)(t,o)}))})(t,e,(r=n,(t,e)=>{r[e]=t}),g),n})((n=(t,e)=>({...t,...e.styles}),r={},_(e,((t,e)=>{r=n(r,t)})),r),((e,n)=>!T(t.dom.style,n)))},lo=(t,e)=>{const n=(t=>Ct("style",It(t).dom))(t);Ut(n,"media","max-width: 1px"),zt(n,e);const r=(t=>(t=>Pt(t)&&p(t.dom.host))(t)?t:(t=>{const e=t.dom.head;if(null==e)throw new Error("Head is not available yet");return wt(e)})(It(t)))(t);Bt(r,n);const o=x.from(n.dom.sheet).fold((()=>[]),(t=>N(t.cssRules)));return Vt(n),o},co=t=>j(t,(t=>"fulfilled"===t.status?t.value:[])),uo=ro,ho=t=>e=>e.options.get(t),po=ho("body_class"),fo=ho("body_id"),mo=ho("skin"),go=new Set(["margin","margin-left","margin-right","margin-top","margin-bottom","padding","padding-left","padding-right","padding-top","padding-bottom","border","border-width","border-style","border-color","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","float","position","left","right","top","bottom","z-index","display","transform","width","max-width","min-width","height","max-height","min-height","overflow","overflow-x","overflow-y","text-overflow","vertical-align","transition","transition-delay","transition-duration","transition-property","transition-timing-function","outline","outline-color","outline-style","outline-width"]),yo=t=>{const e=jt(t),n=((t,e,n)=>I(((t,e)=>{const n=f(e)?e:C;let r=t.dom;const o=[];for(;null!==r.parentNode&&void 0!==r.parentNode;){const t=r.parentNode,e=wt(t);if(o.push(e),!0===n(e))break;r=t}return o})(t,n),e))(t,(t=>xt(t,"*")),(t=>{return n=e,t.dom===n.dom;var n}));return[t].concat(n)},ko=(t,e)=>{const n=(t=>{const e=A.call(t,0);return e.reverse(),e})(yo(t)),r={},o=uo(e);return _(n,(t=>{const e=I(o,(e=>xt(t,e.selector))),n=((t,e)=>{const n={},r=P(e,(t=>t.styles)),o=(t=>{const e={},n=t.dom;if(Ft(n))for(let t=0;t<n.style.length;t++){const r=n.style.item(t);e[r]=n.style[r]}return e})(t);return _(r.concat([o]),(t=>{D(t,((t,e)=>{var r;"background-color"!==e&&(r=e,go.has(r))||(n[e]=t)}))})),n})(t,e);D(n,((t,e)=>{r[e]=t}))})),r},vo=(t,e)=>{const n=Rt(t);_(n,(t=>{var n;Tt(n=t)&&Lt(n.dom)&&D(e,((e,n)=>{((t,e)=>{const n=((t,e)=>Ft(t)?t.style.getPropertyValue(e):"")(t.dom,e);return x.from(n).filter((t=>t.length>0))})(t,n).isNone()&&((t,e,n)=>{const r=t.dom;qt(r,e,n)})(t,n,e)}))}))},So=t=>{const e=N(t);return 0===e.length||O(e,(t=>"screen"===t||"all"===t))},bo=t=>!(t=>"CSSImportRule"===t.constructor.name)(t)||So(t.media),Co=(t,e,n)=>{const r=jt(t);return(async(t,e)=>{const n=(t=>{const e=t.dom.styleSheets;return Array.prototype.slice.call(e)})(t),r=P(n,(t=>io(t,e))),o=await Promise.allSettled(r);return eo(o)})(r,(t=>((t,e,n)=>(!!c(t.href)||!e(t.href)&&(h(n)||n(t.href)))&&(c(t.media)||So(t.media)))(t,e,n)?((t,e)=>(t=>{try{return Promise.resolve(N(t.cssRules))}catch(t){return Promise.reject(t)}})(e).catch((n=>(async(t,e)=>c(e.href)?Promise.resolve([]):fetch(e.href).then((t=>t.ok?t.text():Promise.reject())).then((e=>lo(t,e))).catch((t=>[])))(t,e))))(r,t).then((t=>I(t,bo))):Promise.resolve([]))).then(co)},wo=async(t,e,n,r,o)=>{const i=t.getContent(),a=(t=>{const e=t.editorManager.suffix,n=mo(t),r=(t=>{const e=mo(t),n=t.options.get("skin_url");return!1===e?n:n?t.documentBaseURI.toAbsolute(n):t.editorManager.baseURL+"/skins/ui/"+e})(t);return!1!==n&&s(r)?[r+`/skin${e}.css`,r+`/skin.shadowdom${e}.css`]:[]})(t),l=wt(t.getBody()),c=await Co(l,(t=>T(a,t)),e),u=(t=>{const e="mce-sandbox";return{play:(n,r)=>new Promise(((o,s)=>{var i;const a=Ct("div"),l=Ct("iframe");Jt(a,e),Ht(a,{visibility:"hidden"}),Bt(a,l),Bt(t,a);const c=t=>(...e)=>{Vt(a),t(...e)},u=null===(i=l.dom.contentWindow)||void 0===i?void 0:i.document;if(h(u))return void c(s)(new Error("sandbox iframe did not init correctly"));const d=Dt(l,"load",(()=>{d.unbind();const t=wt(u),e=Wt(t);r(t,e).then(c(o),c(s))}));u.open(),u.write(n),u.close()})),playInline:(n,r)=>new Promise(((o,s)=>{const i=Ct("div");Jt(i,e),Ht(i,{position:"fixed",overflow:"hidden",zIndex:"1000",left:"0",right:"0",bottom:"0",top:"0",opacity:"0"});const a=Ct("div");Ht(a,{position:"absolute",left:"0",right:"0",top:"0",height:"auto",margin:"auto"}),zt(a,n),Bt(i,a),Bt(t,i);const l=t=>(...e)=>{Vt(i),t(...e)};setTimeout((()=>{const e=_t(t);r(e,a).then(l(o),l(s))}),50)}))}})(Wt(wt(document))),d=((t,e,n,r)=>'<!DOCTYPE html><html><head><base href="'+(0,t.dom.encode)(t.documentBaseURI.getURI())+'"></head>'+((t,e,n,r)=>{const o=t.dom.encode,s=t.getBody(),i=s.dir,a=i?' dir="'+o(i)+'"':"",l=t.inline?s.nodeName.toLowerCase():"body";return`<${l} ${t.inline?`class="mce-content-body"${a}`:`id="${o(n)}" class="mce-content-body ${o(r)}"${a}`}>`+e+`</${l}>`})(t,e,n,r)+"</html>")(t,i,r,o);return u.play(d,((t,e)=>{const r=Gt(e,".mce-content-body").getOr(e),o=((t,e,n=w)=>I(e,(t=>!(t=>((t,e,n=0,r)=>{const o=t.indexOf(e,n);return-1!==o&&(!!h(r)||o+e.length<=r)})(t.selector,"::"))(t)&&n(t.selector))))(0,c,n);((t,e)=>{((t,e)=>{const n=document.createTreeWalker(t.dom,NodeFilter.SHOW_ELEMENT);for(;p(n.nextNode());){const t=wt(n.currentNode),r=I(e,(e=>xt(t,e.selector)));if(r.length>0){const e=ao(t,r);Ht(t,e)}}})(e,ro(t))})(o,r);const s=ko(l,o);return vo(r,s),Promise.resolve({html:(i=r,i.dom.innerHTML)});var i}))};var xo;!function(t){t[t.Error=0]="Error",t[t.Value=1]="Value"}(xo||(xo={}));const Ao=(t,e,n)=>t.stype===xo.Error?e(t.serror):n(t.svalue),Lo=t=>({stype:xo.Value,svalue:t}),Eo=t=>({stype:xo.Error,serror:t}),To=Ao,Oo=t=>i(t)&&$(t).length>100?" removed due to size":JSON.stringify(t,null,2),Po=(t,e)=>Eo([{path:t,getErrorInfo:e}]),_o=t=>({extract:(e,n)=>{return r=t(n),o=t=>((t,e)=>Po(t,k(e)))(e,t),r.stype===xo.Error?o(r.serror):r;var r,o},toString:k("val")}),Io=(t,e)=>_o((n=>{const r=typeof n;return t(n)?Lo(n):Eo(`Expected type: ${e} but got: ${r}`)})),Ro=Io(s,"string"),jo=Io(u,"boolean"),No=(t,e,n)=>{switch(t.tag){case"field":return e(t.key,t.newKey,t.presence,t.prop);case"custom":return n(t.newKey,t.instantiator)}},$o=t=>{const e=(t=>{const e=[],n=[];return _(t,(t=>{Ao(t,(t=>n.push(t)),(t=>e.push(t)))})),{values:e,errors:n}})(t);return e.errors.length>0?(n=e.errors,y(Eo,R)(n)):Lo(e.values);var n},Mo=(t,e,n,r)=>r(V(t,e).getOrThunk((()=>n(t)))),Do=(t,e,n,r,o)=>{const s=t=>o.extract(e.concat([r]),t),i=t=>t.fold((()=>Lo(x.none())),(t=>{const n=o.extract(e.concat([r]),t);return s=n,i=x.some,s.stype===xo.Value?{stype:xo.Value,svalue:i(s.svalue)}:s;var s,i}));switch(t.tag){case"required":return((t,e,n,r)=>V(e,n).fold((()=>((t,e,n)=>Po(t,(()=>'Could not find valid *required* value for "'+e+'" in '+Oo(n))))(t,n,e)),r))(e,n,r,s);case"defaultedThunk":return Mo(n,r,t.process,s);case"option":return((t,e,n)=>n(V(t,e)))(n,r,i);case"defaultedOptionThunk":return((t,e,n,r)=>r(V(t,e).map((e=>!0===e?n(t):e))))(n,r,t.process,i);case"mergeWithThunk":return Mo(n,r,k({}),(e=>{const r=J(t.process(n),e);return s(r)}))}},Bo=t=>({extract:(e,n)=>((t,e,n)=>{const r={},o=[];for(const s of n)No(s,((n,s,i,a)=>{const l=Do(i,t,e,n,a);To(l,(t=>{o.push(...t)}),(t=>{r[s]=t}))}),((t,n)=>{r[t]=n(e)}));return o.length>0?Eo(o):Lo(r)})(e,n,t),toString:()=>{const e=P(t,(t=>No(t,((t,e,n,r)=>t+" -> "+r.toString()),((t,e)=>"state("+t+")"))));return"obj{\n"+e.join("\n")+"}"}}),Uo=t=>_o((e=>t(e).fold(Eo,Lo))),Vo=(t,e,n)=>{return r=((t,e,n)=>((t,e)=>t.stype===xo.Error?{stype:xo.Error,serror:e(t.serror)}:t)(e.extract([t],n),(t=>({input:n,errors:t}))))(t,e,n),Ao(r,q.error,q.value);var r},zo=(t,e,n,r)=>({tag:"field",key:t,newKey:e,presence:n,prop:r}),Fo=t=>((t,e)=>zo(t,t,{tag:"required",process:{}},e))(t,Ro),Wo=(t,e)=>zo(t,t,{tag:"option",process:{}},e),qo=t=>Wo(t,Ro),Ho=Bo([Fo("html"),qo("css")]),Go=Bo([Wo("default",Ho),Wo("even",Ho),Wo("odd",Ho),Wo("first",Ho)]),Jo=Bo([qo("top"),qo("bottom"),qo("right"),qo("left")]),Ko=Bo([(Qo=["portrait","landscape"],Wo("orientation",(t=>Uo((e=>T(t,e)?q.value(e):q.error(`Unsupported value: "${e}", choose one of "${t.join(", ")}".`))))(Qo))),Wo("margin",Jo),Wo("size",(t=>{const e=v;return{extract:(n,r)=>{const o=[];for(const s of t){const t=s.extract(n,r);if(t.stype===xo.Value)return{stype:xo.Value,svalue:e(t.svalue)};o.push(t)}return $o(o)},toString:()=>"oneOf("+P(t,(t=>t.toString())).join(", ")+")"}})([Bo([Fo("width"),Fo("height")]),Uo((t=>{const e=["Letter","Legal","Tabloid","Statement","Executive","A3","A4","A5","A6","B4","B5","JB4","JB5"],n=t.toLowerCase();return O(e,(t=>t.toLowerCase()===n))?q.value(!0):q.error("The size should be one of these values: "+e.join(", "))}))]))]);var Qo;const Yo=Bo([Fo("source"),qo("width"),qo("height"),Wo("washout",jo)]),Xo={document:{size:"letter"}},Zo=Bo([Wo("headers",Go),Wo("footers",Go),Wo("document",Ko),Wo("watermark",Yo),Wo("extra_http_headers",Bo([])),qo("base_url")]),ts=t=>x.from(t.options.get("exportword_service_url")).map((t=>(t=>{const e=new URL(t);return e.pathname="/v2/convert/html-docx",e.search="",e.hash="",e.toString()})(t))).getOrDie("The Export to Word plugin requires the exportword_service_url to be configured"),es=t=>x.from(t.options.get("exportword_converter_options")).getOr(Xo),ns=async t=>(t=>x.from(t.options.get("exportword_token_provider")))(t).fold((()=>Promise.resolve(x.none())),(async t=>{const e=t();if(!(i(n=e)&&f(n.then)&&f(n.catch)))throw new Error("The token provider needs to return a promise");var n;const r=await e;if(!i(r)||!s(r.token))throw new Error("Token provider should return a promise with an object that has a token string property");return x.some(r.token)})),rs=(t,e)=>{const n=document.createElement("a");n.href=window.URL.createObjectURL(t),n.download=e,n.click(),n.remove()},os=(t,e)=>t.execCommand(e);((t,e)=>{const{i18n:n=!0}=e;n&&tinymce.PluginManager.requireLangPack(t,"ar,bg-BG,ca,cs,da,de,el,es,eu,fa,fi,fr-FR,he-IL,hi,hr,hu-HU,id,it,ja,kk,ko-KR,ms,nb-NO,nl,pl,pt-BR,pt-PT,ro,ru,sk,sl-SI,sv-SE,th-TH,tr,uk,vi,zh-CN,zh-TW"),tinymce.PluginManager.add(t,St(t,e))})("exportword",{setup:t=>{(t=>{t.options.register("exportword_service_url",{processor:t=>{if(!s(t))return console.error("The Export to Word plugin requires the exportword_service_url to be configured"),!1;try{return new URL(t),!0}catch(t){return console.error("The value provided in exportword_service_url is not a valid URL"),!1}}}),t.options.register("exportword_converter_options",{processor:t=>Vo("exportword_converter_options",Zo,t).fold((t=>{return console.error("Errors: \n"+(t=>{const e=t.length>10?t.slice(0,10).concat([{path:[],getErrorInfo:k("... (only showing first ten failures)")}]):t;return P(e,(t=>"Failed path: ("+t.path.join(" > ")+")\n"+t.getErrorInfo()))})((e=t).errors).join("\n")+"\n\nInput object: "+Oo(e.input)),!1;var e}),(t=>!0))}),t.options.register("exportword_converter_style",{processor:"string",default:""}),t.options.register("exportword_token_provider",{processor:"function"})})(t),(t=>{t.addCommand("ExportWord",(()=>{(async(t,e)=>{var n,r;const o=(t=>{var e;return null!==(e=t.options.get("directionality"))&&void 0!==e?e:""})(t),s=(t=>t.options.get("exportword_converter_style"))(t),i=e.converterUrl,{html:a}=await(t=>({getContent:()=>wo(t,void 0,void 0,fo(t),po(t))}))(t).getContent(),l={html:`<html>\n <head>\n <meta charset="utf-8">\n </head>\n <body>\n <div class="tinymce-content" dir="${o}">\n ${a}\n </div>\n <body>\n </html>`,css:s,config:{...e.converterOptions,base_url:null!==(r=null===(n=e.converterOptions)||void 0===n?void 0:n.base_url)&&void 0!==r?r:t.documentBaseURI.getURI()}},c={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/docx",...(await ns(t)).fold((()=>({})),(t=>({Authorization:t}))),"x-cs-editor":`tinymce${t.editorManager.majorVersion}`},body:JSON.stringify(l)};t.setProgressState(!0),window.fetch(i,c).then((async t=>{if(200!==t.status)throw await t.json();return t.blob()})).then((n=>{const r="function"==typeof e.fileName?e.fileName():e.fileName;rs(n,r),(t=>{t.dispatch("ExportToWord")})(t)})).finally((()=>t.setProgressState(!1))).catch((e=>{t.notificationManager.open({text:"Operation failed",type:"error"}),console.error(e)}))})(t,{fileName:"document.docx",converterUrl:ts(t),converterOptions:es(t)})}))})(t),(t=>{t.ui.registry.addButton("exportword",{tooltip:"Export to Word",icon:"export-word",onAction:()=>{os(t,"ExportWord")},context:"any"})})(t),(t=>{t.ui.registry.addMenuItem("exportword",{text:"Export to Word...",icon:"export-word",onAction:()=>os(t,"ExportWord"),context:"any"})})(t)}})}();