10 lines
86 KiB
JavaScript

/*!
* Tiny Suggested Edits plugin
*
* Copyright (c) 2025 Ephox Corporation DBA Tiny Technologies, Inc.
* Licensed under the Tiny commercial license. See https://www.tiny.cloud/legal/
*
* Version: 8.3.0-112
*/
!function(){"use strict";var t=function(t){if(null===t)return"null";if(void 0===t)return"undefined";var e=typeof t;return"object"===e&&(Array.prototype.isPrototypeOf(t)||t.constructor&&"Array"===t.constructor.name)?"array":"object"===e&&(String.prototype.isPrototypeOf(t)||t.constructor&&"String"===t.constructor.name)?"string":e},e=function(t){return{eq:t}},n=e((function(t,e){return t===e})),r=n,o=function(t){return e((function(e,n){if(e.length!==n.length)return!1;for(var r=e.length,o=0;o<r;o++)if(!t.eq(e[o],n[o]))return!1;return!0}))},s=function(t){return e((function(n,s){var i=Object.keys(n),a=Object.keys(s);if(!function(t,n){return function(t,n){return e((function(e,r){return t.eq(n(e),n(r))}))}(o(t),(function(t){return function(t,e){return Array.prototype.slice.call(t).sort(e)}(t,n)}))}(r).eq(i,a))return!1;for(var l=i.length,c=0;c<l;c++){var d=i[c];if(!t.eq(n[d],s[d]))return!1}return!0}))},i=e((function(e,n){if(e===n)return!0;var r=t(e);return r===t(n)&&(function(t){return-1!==["undefined","boolean","number","string","function","xml","null"].indexOf(t)}(r)?e===n:"array"===r?o(i).eq(e,n):"object"===r&&s(i).eq(e,n))}));const a=Object.getPrototypeOf,l=(t,e,n)=>!!n(t,e.prototype)||t.constructor?.name===e.name,c=t=>e=>(t=>{const e=typeof t;return null===t?"null":"object"===e&&Array.isArray(t)?"array":"object"===e&&l(t,String,((t,e)=>e.isPrototypeOf(t)))?"string":e})(e)===t,d=t=>e=>typeof e===t,u=c("string"),f=c("object"),h=t=>((t,e)=>f(t)&&l(t,e,((t,e)=>a(t)===e)))(t,Object),g=c("array"),p=d("boolean"),m=t=>undefined===t;const v=t=>null==t,y=t=>!v(t),w=d("function"),b=d("number"),_=()=>{},C=t=>()=>t,x=t=>t,S=(t,e)=>t===e,D=t=>t(),A=C(!1),M=C(!0);class k{tag;value;static singletonNone=new k(!1);constructor(t,e){this.tag=t,this.value=e}static some(t){return new k(!0,t)}static none(){return k.singletonNone}fold(t,e){return this.tag?e(this.value):t()}isSome(){return this.tag}isNone(){return!this.tag}map(t){return this.tag?k.some(t(this.value)):k.none()}bind(t){return this.tag?t(this.value):k.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:k.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 y(t)?k.some(t):k.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 N=Array.prototype.slice,O=Array.prototype.indexOf,E=Array.prototype.push,R=(t,e)=>((t,e)=>O.call(t,e))(t,e)>-1,P=(t,e)=>{for(let n=0,r=t.length;n<r;n++)if(e(t[n],n))return!0;return!1},I=(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=(t,e)=>{for(let n=0,r=t.length;n<r;n++)e(t[n],n)},j=(t,e)=>{const n=[],r=[];for(let o=0,s=t.length;o<s;o++){const s=t[o];(e(s,o)?n:r).push(s)}return{pass:n,fail:r}},L=(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},F=(t,e,n)=>(((t,e)=>{for(let n=t.length-1;n>=0;n--)e(t[n],n)})(t,((t,r)=>{n=e(n,t,r)})),n),$=(t,e,n)=>(T(t,((t,r)=>{n=e(n,t,r)})),n),U=(t,e)=>((t,e,n)=>{for(let r=0,o=t.length;r<o;r++){const o=t[r];if(e(o,r))return k.some(o);if(n(o,r))break}return k.none()})(t,e,A),z=t=>{const e=[];for(let n=0,r=t.length;n<r;++n){if(!g(t[n]))throw new Error("Arr.flatten item "+n+" was not an array, input: "+t);E.apply(e,t[n])}return e},B=(t,e)=>{for(let n=0,r=t.length;n<r;++n)if(!0!==e(t[n],n))return!1;return!0},q=(t,e,n=i)=>o(n).eq(t,e),V=w(Array.from)?Array.from:t=>N.call(t),H=(t,e)=>{const n=[],r=w(e)?t=>P(n,(n=>e(n,t))):t=>R(n,t);for(let e=0,o=t.length;e<o;e++){const o=t[e];r(o)||n.push(o)}return n},K=Object.keys,W=Object.hasOwnProperty,G=(t,e)=>{const n=K(t);for(let r=0,o=n.length;r<o;r++){const o=n[r];e(t[o],o)}},Q=(t,e)=>J(t,((t,n)=>({k:n,v:e(t,n)}))),J=(t,e)=>{const n={};return G(t,((t,r)=>{const o=e(t,r);n[o.k]=o.v})),n},X=(t,e)=>{const n={};var r;return((t,e,n,r)=>{G(t,((t,o)=>{(e(t,o)?n:r)(t,o)}))})(t,e,(r=n,(t,e)=>{r[e]=t}),_),n},Z=(t,e)=>{const n=[];return G(t,((t,r)=>{n.push(e(t,r))})),n},Y=(t,e)=>tt(t,e)?k.from(t[e]):k.none(),tt=(t,e)=>W.call(t,e),et=t=>{for(const e in t)if(W.call(t,e))return!1;return!0},nt=t=>{let e=t;return{get:()=>e,set:t=>{e=t}}},rt=t=>{const e=e=>e(t),n=C(t),r=()=>o,o={tag:!0,inner:t,fold:(e,n)=>n(t),isValue:M,isError:A,map:e=>st.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:()=>k.some(t)};return o},ot=t=>{const e=()=>n,n={tag:!1,inner:t,fold:(e,n)=>e(t),isValue:A,isError:M,map:e,mapError:e=>st.error(e(t)),bind:e,exists:A,forall:M,getOr:x,or:x,getOrThunk:D,orThunk:D,getOrDie:(r=String(t),()=>{throw new Error(r)}),each:_,toOptional:k.none};var r;return n},st={value:rt,error:ot,fromOption:(t,e)=>t.fold((()=>ot(e)),rt)},it=(at=(t,e)=>h(t)&&h(e)?it(t,e):e,(...t)=>{if(0===t.length)throw new Error("Can't merge zero objects");const e={};for(let n=0;n<t.length;n++){const r=t[n];for(const t in r)tt(r,t)&&(e[t]=at(e[t],r[t]))}return e});var at;const lt=t=>{const e=[],n=t=>{e.push(t)};for(let e=0;e<t.length;e++)t[e].each(n);return e},ct=t=>{let e,n=!1;return(...r)=>(n||(n=!0,e=t.apply(null,r)),e)},dt=(t,e)=>{const{type:n,message:r}=e;t.notificationManager.open({type:n,text:r})},ut=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)},ft=(t,e)=>{const{protect:n,allowList:r=[],blockList:o=[]}=null!=t?t:{};let s;return s=y(n)?n:r.length>0||o.length>0||e,{protect:s,allowList:r,blockList:o}},ht=t=>{const{protect:e,allowList:n,blockList:r}=null!=t?t:{};return t=>{const o=t.toLowerCase();return n.length>0?!P(n,(t=>t.toLowerCase()===o)):r.length>0?P(r,(t=>t.toLowerCase()===o)):e}},gt=t=>{const e=ht(t);return(t,n)=>{const r=((t,e)=>`${t}:${e}`)(n,t.toLowerCase());return e(r)}},pt=(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),T(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 d=((t,r)=>{const o=n(t),i=e.getStatus(),a=o&&"invalid"===i?_: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,d,c])}},mt=(t,e,n)=>r=>{const o="invalid"!==e.getStatus()&&y(n)?n(r):_,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()}},vt=(t,e,n)=>(...r)=>{var o;return"invalid"===t.getStatus()?n:null!==(o=null==e?void 0:e(...r))&&void 0!==o?o:n},yt=(t,e)=>vt(t,e,Promise.resolve([])),wt=(t,e)=>vt(t,e,[]),bt=(t,e)=>vt(t,e,!1),_t=(t,e,n,r)=>{const o=e=>{const{command:o,value:s}=e,i=k.from(s).filter(u).map((t=>t.toLowerCase())),a=o.toLowerCase()===r.toLowerCase(),l=i.exists((t=>n.has(t))),c=i.exists((e=>e===t.queryCommandValue(r)));a&&l&&!c&&e.preventDefault()},s=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",(()=>{s(),t.off("BeforeExecCommand",o)}))},Ct=(t,e,n,r,o,s=!1)=>{const i=new Set,a=new Set,l=(t,e)=>{s&&console.log(`[UiProxy] ${t}`,e||"")};((t,e,n)=>{_t(t,e,n,"ToggleView")})(t,n,i),((t,e,n)=>{_t(t,e,n,"ToggleSidebar")})(t,n,a);const c=(e,s,i,a)=>{const c=o(e,i);return l(`${a}: ${e}`,{spec:s,context:r,shouldProtect:c}),c?{...s,onSetup:mt(t,n,s.onSetup)}:s};return new Proxy(e,{get:(t,e,s)=>{const d=Reflect.get(t,e,s);if(!u(e))return d;switch(e){case"addButton":case"addGroupToolbarButton":case"addToggleButton":case"addMenuButton":case"addSplitButton":return(...n)=>{const[r,o,...s]=n,i=c(r,o,"button",String(e));return Reflect.apply(d,t,[r,i,...s])};case"addMenuItem":case"addToggleMenuItem":case"addNestedMenuItem":return(...n)=>{const[r,o,...s]=n,i=c(r,o,"menuitem",String(e));return Reflect.apply(d,t,[r,i,...s])};case"addAutocompleter":return(...s)=>{const[i,a,...c]=s,u=o(i,"autocompleter");if(l(`${String(e)}: ${i}`,{spec:a,context:r,shouldProtect:u}),u){const e={...a,fetch:yt(n,a.fetch)};return Reflect.apply(d,t,[i,e,...c])}return Reflect.apply(d,t,[i,a,...c])};case"addSidebar":return(...n)=>{const[s,i,...c]=n,u=o(s,"sidebar");if(l(`${String(e)}: ${s}`,{spec:i,context:r,shouldProtect:u}),u){a.add(s.toLowerCase());const e={...i};return Reflect.apply(d,t,[s,e,...c])}return Reflect.apply(d,t,[s,i,...c])};case"addView":return(...n)=>{const[s,a,...c]=n,u=o(s,"view");if(l(`${String(e)}: ${s}`,{spec:a,context:r,shouldProtect:u}),u){i.add(s.toLowerCase());const e={...a};return Reflect.apply(d,t,[s,e,...c])}return Reflect.apply(d,t,[s,a,...c])};case"addContextMenu":return(...s)=>{const[i,a,...c]=s,u=o(i,"contextmenu");if(l(`${String(e)}: ${i}`,{spec:a,context:r,shouldProtect:u}),u){const e={...a,update:wt(n,a.update)};return Reflect.apply(d,t,[i,e,...c])}return Reflect.apply(d,t,[i,a,...c])};case"addContextToolbar":case"addContextForm":return(...s)=>{const[i,a,...c]=s,u=o(i,"contexttoolbar");if(l(`${String(e)}: ${i}`,{spec:a,context:r,shouldProtect:u}),u){const e={...a,predicate:bt(n,a.predicate)};return Reflect.apply(d,t,[i,e,...c])}return Reflect.apply(d,t,[i,a,...c])};case"addIcon":case"getAll":case"addContext":return d}}})},xt=new Set(["addCommand","addCommands","addQueryStateHandler","addQueryValueHandler"]),St=t=>(e,n)=>{t&&console.log(`[EditorProxy] ${e}`,n||"")},Dt=(t,e)=>{const{statusProvider:n,uiContext:r,protection:o,debug:s=!1}=e,{events:i,commands:a,ui:l}=o;St(s)("Creating enhanced editor with options:",{hasStatusProvider:!!n,uiContext:r,debug:s,protection:o});const{editorUiProxy:c,editorCommandsProxy:d,editorEventListenerProxy:u}=((t,e,n,r,o,s,i)=>{const a=s.protect?{...t.ui,registry:Ct(t,t.ui.registry,e,n,gt(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?_:e},l=e=>{"invalid"===e&&s.protectedCommands.length>0&&(i("Removing commands",s.protectedCommands),T(s.protectedCommands,(e=>{t.editorCommands.removeCommand(e)})),s.protectedCommands=[])},c=()=>{s.cleanupScheduled||(s.cleanupScheduled=!0,window.setTimeout((()=>{l(n.getStatus()),s.cleanupScheduled=!1}),0))},d=n.onStatusChange(l);return t.on("remove",d),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:Q(t,((t,e)=>a(e,t)));return c(),Reflect.apply(r,e,[o,n])}}return Reflect.get(t,n,o)}})})(t,t.editorCommands,e,ht(r),i):t.editorCommands;return{editorUiProxy:a,editorCommandsProxy:l,editorEventListenerProxy:o.protect?pt(t,e,ht(o),i):t.on.bind(t)}})(t,n,r||"",a,i,l,s),f=((t,e,n,r)=>(o,s,i)=>{const a=String(s);if("on"===s)return St(r)("on intercepted"),n;if(xt.has(a))return St(r)(`${a} intercepted`),e[a].bind(e);if("editorCommands"===s)return St(r)("editorCommands accessed"),e;if("ui"===s)return St(r)("ui accessed"),t;const l=Reflect.get(o,s,i);return w(l)?l.bind(o):l})(c,d,u,s);return new Proxy(t,{get:f,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)})},At=t=>parseInt(t,10),Mt=(t,e)=>{const n=t-e;return 0===n?0:n>0?1:-1},kt=(t,e,n)=>({major:t,minor:e,patch:n}),Nt=t=>{const e=/([0-9]+)\.([0-9]+)\.([0-9]+)(?:(\-.+)?)/.exec(t);return e?kt(At(e[1]),At(e[2]),At(e[3])):kt(0,0,0)},Ot=(t,e)=>!!t&&-1===((t,e)=>{const n=Mt(t.major,e.major);if(0!==n)return n;const r=Mt(t.minor,e.minor);if(0!==r)return r;const o=Mt(t.patch,e.patch);return 0!==o?o:0})((t=>Nt((t=>[t.majorVersion,t.minorVersion].join(".").split(".").slice(0,3).join("."))(t)))(t),Nt(e)),Et=Nt("8.3.0"),Rt=`${Et.major}.${Et.minor}.0`,Pt=`${Et.major+1}.0.0`,It=(t,e)=>{const{setup:n,protection:r}=e;return(o,s)=>{if(!((t,e)=>Ot(t,Rt)?(console.error(`The "${e}" plugin requires at least version ${Rt} of TinyMCE.`),!1):!!Ot(t,Pt)||(console.error(`The "${e}" plugin requires at least version ${Rt} of TinyMCE but less than ${Pt}.`),!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 v(r)&&"gpl"===n})(t)&&(((t,e)=>{const{console:n,editor:r}=e;y(r)&&(t._skinLoaded?dt(t,r):t.on("SkinLoaded",(()=>{dt(t,r)}))),y(n)&&ut(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:ft(n,false),commands:ft(r,true),ui:ft(o,true),api:ft(s,true)}})(r),a=((t="pre-validation")=>{const e=nt(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 T(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?Dt(o,{statusProvider:a,uiContext:l.ui.context,debug:e.debug||!1,protection:i}):o,d=((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&&y(t)){const s=ht(e.api);return(o=t=>"invalid"===n.getStatus()&&s(t),(t,e)=>Q(t,((t,n)=>w(t)?(...r)=>{if(o(n.toLowerCase())){const t=`Method "${y(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,d),i,a,t)}};var Tt;!function(t){t[t.Error=0]="Error",t[t.Value=1]="Value"}(Tt||(Tt={}));const jt=(t,e,n)=>t.stype===Tt.Error?e(t.serror):n(t.svalue),Lt=t=>({stype:Tt.Value,svalue:t}),Ft=t=>({stype:Tt.Error,serror:t}),$t=jt,Ut=(t,e)=>Ft([{path:t,getErrorInfo:e}]),zt=t=>({extract:(e,n)=>{return r=t(n),o=t=>((t,e)=>Ut(t,C(e)))(e,t),r.stype===Tt.Error?o(r.serror):r;var r,o},toString:C("val")}),Bt=zt(Lt),qt=C(Bt),Vt=(Ht=b,zt((t=>{const e=typeof t;return Ht(t)?Lt(t):Ft(`Expected type: number but got: ${e}`)})));var Ht;const Kt=(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)}},Wt=(t,e,n,r)=>r(Y(t,e).getOrThunk((()=>n(t)))),Gt=(t,e,n,r,o)=>{const s=t=>o.extract(e.concat([r]),t),i=t=>t.fold((()=>Lt(k.none())),(t=>{const n=o.extract(e.concat([r]),t);return s=n,i=k.some,s.stype===Tt.Value?{stype:Tt.Value,svalue:i(s.svalue)}:s;var s,i}));switch(t.tag){case"required":return((t,e,n,r)=>Y(e,n).fold((()=>((t,e,n)=>Ut(t,(()=>{return'Could not find valid *required* value for "'+e+'" in '+(f(t=n)&&K(t).length>100?" removed due to size":JSON.stringify(t,null,2));var t})))(t,n,e)),r))(e,n,r,s);case"defaultedThunk":return Wt(n,r,t.process,s);case"option":return((t,e,n)=>n(Y(t,e)))(n,r,i);case"defaultedOptionThunk":return((t,e,n,r)=>r(Y(t,e).map((e=>!0===e?n(t):e))))(n,r,t.process,i);case"mergeWithThunk":return Wt(n,r,C({}),(e=>{const r=it(t.process(n),e);return s(r)}))}},Qt=(t,e,n)=>{return r=((t,e,n)=>((t,e)=>t.stype===Tt.Error?{stype:Tt.Error,serror:e(t.serror)}:t)(e.extract([t],n),(t=>({input:n,errors:t}))))(t,e,n),jt(r,st.error,st.value);var r},Jt=(t,e,n,r)=>({tag:"field",key:t,newKey:e,presence:n,prop:r}),Xt=t=>Jt(t,t,{tag:"required",process:{}},qt()),Zt=t=>{if(null==t)throw new Error("Node cannot be null or undefined");return{dom:t}},Yt=(t,e)=>{const n=(e||document).createElement(t);return Zt(n)},te=(t,e)=>{const n=(e||document).createTextNode(t);return Zt(n)},ee=Zt,ne=t=>I(t.dom.childNodes,ee),re=(t,e)=>{t.dom.appendChild(e.dom)},oe=(t,e)=>{const n=document.createElement("div");return n.innerHTML=t,ne(ee(n))},se=t=>{const e=Yt("div"),n=ee(t.dom.cloneNode(!0));return re(e,n),(t=>t.dom.innerHTML)(e)},ie=(t,e)=>{const n=document.createDocumentFragment();return T(t,(t=>{n.appendChild(t.dom)})),ee(n)},ae=t=>t.hasOwnProperty("text"),le=t=>t.hasOwnProperty("comment"),ce=t=>t.hasOwnProperty("children")||t.hasOwnProperty("type")&&!le(t),de=t=>"type"in t&&"string"==typeof t.type&&ge.has(t.type),ue=t=>3===t.nodeType,fe=t=>1===t.nodeType,he=t=>{switch(t.nodeType){case 3:return"text";case 8:return"comment";default:return t.nodeName.toLowerCase()}},ge=new Set(["area","base","col","embed","br","img","hr","input","meta","link","param","source","track","wbr","iframe"]),pe=t=>1===t.nodeType&&ge.has(t.nodeName.toLowerCase()),me=()=>1e3*Math.floor((new Date).getTime()/1e3);var ve=Symbol.for("immer-nothing"),ye=Symbol.for("immer-draftable"),we=Symbol.for("immer-state");function be(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var _e=Object.getPrototypeOf;function Ce(t){return!!t&&!!t[we]}function xe(t){return!!t&&(De(t)||Array.isArray(t)||!!t[ye]||!!t.constructor?.[ye]||Oe(t)||Ee(t))}var Se=Object.prototype.constructor.toString();function De(t){if(!t||"object"!=typeof t)return!1;const e=_e(t);if(null===e)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Se}function Ae(t,e){0===Me(t)?Reflect.ownKeys(t).forEach((n=>{e(n,t[n],t)})):t.forEach(((n,r)=>e(r,n,t)))}function Me(t){const e=t[we];return e?e.type_:Array.isArray(t)?1:Oe(t)?2:Ee(t)?3:0}function ke(t,e){return 2===Me(t)?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Ne(t,e,n){const r=Me(t);2===r?t.set(e,n):3===r?t.add(n):t[e]=n}function Oe(t){return t instanceof Map}function Ee(t){return t instanceof Set}function Re(t){return t.copy_||t.base_}function Pe(t,e){if(Oe(t))return new Map(t);if(Ee(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=De(t);if(!0===e||"class_only"===e&&!n){const e=Object.getOwnPropertyDescriptors(t);delete e[we];let n=Reflect.ownKeys(e);for(let r=0;r<n.length;r++){const o=n[r],s=e[o];!1===s.writable&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(e[o]={configurable:!0,writable:!0,enumerable:s.enumerable,value:t[o]})}return Object.create(_e(t),e)}{const e=_e(t);if(null!==e&&n)return{...t};const r=Object.create(e);return Object.assign(r,t)}}function Ie(t,e=!1){return je(t)||Ce(t)||!xe(t)||(Me(t)>1&&(t.set=t.add=t.clear=t.delete=Te),Object.freeze(t),e&&Object.entries(t).forEach((([t,e])=>Ie(e,!0)))),t}function Te(){be(2)}function je(t){return Object.isFrozen(t)}var Le,Fe={};function $e(t){const e=Fe[t];return e||be(0),e}function Ue(){return Le}function ze(t,e){e&&($e("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Be(t){qe(t),t.drafts_.forEach(He),t.drafts_=null}function qe(t){t===Le&&(Le=t.parent_)}function Ve(t){return Le={drafts_:[],parent_:Le,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function He(t){const e=t[we];0===e.type_||1===e.type_?e.revoke_():e.revoked_=!0}function Ke(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return void 0!==t&&t!==n?(n[we].modified_&&(Be(e),be(4)),xe(t)&&(t=We(e,t),e.parent_||Qe(e,t)),e.patches_&&$e("Patches").generateReplacementPatches_(n[we].base_,t,e.patches_,e.inversePatches_)):t=We(e,n,[]),Be(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==ve?t:void 0}function We(t,e,n){if(je(e))return e;const r=e[we];if(!r)return Ae(e,((o,s)=>Ge(t,r,e,o,s,n))),e;if(r.scope_!==t)return e;if(!r.modified_)return Qe(t,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const e=r.copy_;let o=e,s=!1;3===r.type_&&(o=new Set(e),e.clear(),s=!0),Ae(o,((o,i)=>Ge(t,r,e,o,i,n,s))),Qe(t,e,!1),n&&t.patches_&&$e("Patches").generatePatches_(r,n,t.patches_,t.inversePatches_)}return r.copy_}function Ge(t,e,n,r,o,s,i){if(Ce(o)){const i=We(t,o,s&&e&&3!==e.type_&&!ke(e.assigned_,r)?s.concat(r):void 0);if(Ne(n,r,i),!Ce(i))return;t.canAutoFreeze_=!1}else i&&n.add(o);if(xe(o)&&!je(o)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;We(t,o),e&&e.scope_.parent_||"symbol"==typeof r||!Object.prototype.propertyIsEnumerable.call(n,r)||Qe(t,o)}}function Qe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&Ie(e,n)}var Je={get(t,e){if(e===we)return t;const n=Re(t);if(!ke(n,e))return function(t,e,n){const r=Ye(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}(t,n,e);const r=n[e];return t.finalized_||!xe(r)?r:r===Ze(t.base_,e)?(en(t),t.copy_[e]=nn(r,t)):r},has:(t,e)=>e in Re(t),ownKeys:t=>Reflect.ownKeys(Re(t)),set(t,e,n){const r=Ye(Re(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const r=Ze(Re(t),e),i=r?.[we];if(i&&i.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(((o=n)===(s=r)?0!==o||1/o==1/s:o!=o&&s!=s)&&(void 0!==n||ke(t.base_,e)))return!0;en(t),tn(t)}var o,s;return t.copy_[e]===n&&(void 0!==n||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_[e]=!0),!0},deleteProperty:(t,e)=>(void 0!==Ze(t.base_,e)||e in t.base_?(t.assigned_[e]=!1,en(t),tn(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0),getOwnPropertyDescriptor(t,e){const n=Re(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r?{writable:!0,configurable:1!==t.type_||"length"!==e,enumerable:r.enumerable,value:n[e]}:r},defineProperty(){be(11)},getPrototypeOf:t=>_e(t.base_),setPrototypeOf(){be(12)}},Xe={};function Ze(t,e){const n=t[we];return(n?Re(n):t)[e]}function Ye(t,e){if(!(e in t))return;let n=_e(t);for(;n;){const t=Object.getOwnPropertyDescriptor(n,e);if(t)return t;n=_e(n)}}function tn(t){t.modified_||(t.modified_=!0,t.parent_&&tn(t.parent_))}function en(t){t.copy_||(t.copy_=Pe(t.base_,t.scope_.immer_.useStrictShallowCopy_))}function nn(t,e){const n=Oe(t)?$e("MapSet").proxyMap_(t,e):Ee(t)?$e("MapSet").proxySet_(t,e):function(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:Ue(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,s=Je;n&&(o=[r],s=Xe);const{revoke:i,proxy:a}=Proxy.revocable(o,s);return r.draft_=a,r.revoke_=i,a}(t,e);return(e?e.scope_:Ue()).drafts_.push(n),n}function rn(t){if(!xe(t)||je(t))return t;const e=t[we];let n;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=Pe(t,e.scope_.immer_.useStrictShallowCopy_)}else n=Pe(t,!0);return Ae(n,((t,e)=>{Ne(n,t,rn(e))})),e&&(e.finalized_=!1),n}Ae(Je,((t,e)=>{Xe[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}})),Xe.deleteProperty=function(t,e){return Xe.set.call(this,t,e,void 0)},Xe.set=function(t,e,n){return Je.set.call(this,t[0],e,n,t[0])};var on=new class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,e,n)=>{if("function"==typeof t&&"function"!=typeof e){const n=e;e=t;const r=this;return function(t=n,...o){return r.produce(t,(t=>e.call(this,t,...o)))}}let r;if("function"!=typeof e&&be(6),void 0!==n&&"function"!=typeof n&&be(7),xe(t)){const o=Ve(this),s=nn(t,void 0);let i=!0;try{r=e(s),i=!1}finally{i?Be(o):qe(o)}return ze(o,n),Ke(r,o)}if(!t||"object"!=typeof t){if(r=e(t),void 0===r&&(r=t),r===ve&&(r=void 0),this.autoFreeze_&&Ie(r,!0),n){const e=[],o=[];$e("Patches").generateReplacementPatches_(t,r,e,o),n(e,o)}return r}be(1)},this.produceWithPatches=(t,e)=>{if("function"==typeof t)return(e,...n)=>this.produceWithPatches(e,(e=>t(e,...n)));let n,r;return[this.produce(t,e,((t,e)=>{n=t,r=e})),n,r]},"boolean"==typeof t?.autoFreeze&&this.setAutoFreeze(t.autoFreeze),"boolean"==typeof t?.useStrictShallowCopy&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}createDraft(t){xe(t)||be(8),Ce(t)&&(t=function(t){return Ce(t)||be(10),rn(t)}(t));const e=Ve(this),n=nn(t,void 0);return n[we].isManual_=!0,qe(e),n}finishDraft(t,e){const n=t&&t[we];n&&n.isManual_||be(9);const{scope_:r}=n;return ze(r,e),Ke(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const r=e[n];if(0===r.path.length&&"replace"===r.op){t=r.value;break}}n>-1&&(e=e.slice(n+1));const r=$e("Patches").applyPatches_;return Ce(t)?r(t,e):this.produce(t,(t=>r(t,e)))}},sn=on.produce;on.produceWithPatches.bind(on),on.setAutoFreeze.bind(on),on.setUseStrictShallowCopy.bind(on),on.applyPatches.bind(on),on.createDraft.bind(on),on.finishDraft.bind(on);const an=_,ln=(t,e,n)=>null!=t&&null!=e&&n.eq(t,e)||t===e,cn=(t,e,n,r)=>n.eq(null!=t?t:r,null!=e?e:r),dn=(t,e)=>cn(t,e,pn,[]),un=(t,e)=>cn(t,e,mn,{}),fn=e(((t,e)=>t.type===e.type&&t.uid===e.uid)),hn=e(((t,e)=>t.type===e.type&&un(t.attrs,e.attrs))),gn=e(((t,e)=>"string"==typeof t||"string"==typeof e?t===e:ln(t,e,hn))),pn=o(gn),mn=s(n),vn=e(((t,e)=>ae(e)&&ae(t)?e.text===t.text&&void 0===e.oldFormat&&dn(e.format,t.format):!(!ce(e)||!ce(t))&&hn.eq(t,e)&&void 0===e.oldAttrs&&ln(e.children,t.children,o(vn)))),yn=(t,e)=>ln(t.opData,e.opData,fn)&&dn(t.format,e.format),wn=t=>{const e=({opData:t,resolution:e})=>"accept"===e&&("insert"===t.type||"modify"===t.type)||"reject"===e&&"remove"===t.type,n=r=>{const o=k.from(r.opData).bind(t);if(de(r))return o.fold((()=>k.some(r)),(t=>{const{opData:n,resolution:o}=t;if(e(t)){const{oldAttrs:t,oldFormat:e,opData:n,...o}=r;return k.some(o)}if("reject"===o&&"modify"===n.type){const{opData:t,oldAttrs:e,oldFormat:n,attrs:o,format:s,...i}=r,a=void 0===e||et(e)?void 0===e&&void 0!==o?{attrs:o}:{}:{attrs:e},l=void 0!==n&&n.length>0?{format:n}:void 0===n&&void 0!==s?{format:s}:{};return k.some({...i,...l,...a})}return k.none()}));if(ce(r)){const t=t=>{if(t.children){const e=(t=>F(t,((t,e)=>e.fold((()=>t),(e=>{if(0===t.length)return[e];const[n,...r]=t;return((t,e)=>{var n,r;return ae(t)&&ae(e)&&yn(t,e)&&(null===(n=t.opData)||void 0===n?void 0:n.id)===(null===(r=e.opData)||void 0===r?void 0:r.id)?[{...t,text:t.text+e.text}]:[t,e]})(e,n).concat(r)}))),[]))(I(t.children,n));return{...t,children:e}}return t};return o.fold((()=>k.some(t(r))),(n=>{const{opData:o,resolution:s}=n;if(e(n)){const{oldAttrs:e,opData:n,...s}=r,i="modify"===o.type?t(s):s;return k.some(i)}if("reject"===s&&"modify"===o.type){const{attrs:e,opData:n,oldAttrs:o,...s}=r,i=o&&!et(o)?{attrs:o}:{};return k.some({...t(s),...i})}return k.none()}))}return ae(r)?o.fold(C(k.some(r)),(t=>{const{opData:n,resolution:o}=t;if(e(t)){const{oldFormat:t,opData:e,...n}=r;return k.some(n)}if("reject"===o&&"modify"===n.type){const t=r.oldFormat&&r.oldFormat.length>0?{format:r.oldFormat}:{};return k.some({text:r.text,...t})}return k.none()})):o.fold((()=>k.some(r)),(t=>{if(e(t)){const{opData:t,...e}=r;return k.some(e)}return k.none()}))};return n},bn=(t,e)=>wn(e)(t),_n=t=>k.some({opData:t,resolution:"accept"}),Cn=t=>k.some({opData:t,resolution:"reject"}),xn=(t,e)=>{var n,r;return(null===(n=t.opData)||void 0===n?void 0:n.uid)===(null===(r=e.opData)||void 0===r?void 0:r.uid)&&vn.eq(t,e)},Sn=(t,e)=>{const n=t=>{var e;return"object"==typeof t&&"span"===t.type&&null!==t.attrs&&"tinycomments"===(null===(e=t.attrs)||void 0===e?void 0:e["data-mce-annotation"])},r=(t,e)=>n(t)?e:t,o=null!=e?e:[],s=null!=t?t:[],i=U(o,n),a=U(s,n);return i.fold((()=>({format:o,oldFormat:L(s,(t=>!n(t)))})),(t=>a.isNone()?{format:o,oldFormat:[...s,t]}:{format:I(o,(e=>r(e,t))),oldFormat:I(s,(e=>r(e,t)))}))},Dn=(t,e)=>{const n=wn(e);return{...t,contents:lt(I(t.contents,n))}},An=_n,Mn=t=>Yt(t),kn=t=>{if(u(t))return Mn(t);{const e=Mn(t.type);return k.from(t.attrs).each((t=>((t,e)=>{const n=t.dom;G(e,((t,e)=>{((t,e,n)=>{if(!(u(n)||p(n)||b(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+"")})(n,e,t)}))})(e,t))),e}},Nn=t=>"type"in t?kn(t):(t=>te(t.text))(t),On=(t,e)=>{for(let n=0;n<t.length;n++)if(!gn.eq(t[n],e[n]))return n;return t.length},En=(t,e)=>F(e,((t,e)=>{const n=kn(e);return re(n,t),n}),t),Rn=t=>{let e=t.dom;for(;e.parentNode;)e=e.parentNode;return ee(e)},Pn=(t,e)=>{an("creating state for",se(t),e,se(Rn(t)));const n=[...e],r=En(t,n),o=[t,n];return an("new tree",se(Rn(r))),an("new state",se(r)),o},In=(t,e)=>{for(let r=0;r<t;r++){const t=(n=e,k.from(n.dom.parentNode).map(ee));an("moving from",se(e),"to",t.map(se).getOrUndefined()),e=t.getOrDie("Major flaw encountered in the suggested edits model. Content will likely be lost.")}var n;return e},Tn=t=>{var e,n;const r=[];if(0===t.length)return r;const o=t[0];let s=Pn(Nn(o),null!==(e=o.format)&&void 0!==e?e:[]);for(let e=1;e<t.length;e++){const o=t[e],i=null!==(n=o.format)&&void 0!==n?n:[],a=Nn(o),[l,c]=s,d=On(c,i);if(an("matched to",d,c.length),d<1){an("complete closed nesting with",se(Rn(l))),r.push(Rn(l)),s=Pn(a,i);continue}const u=In(c.length-d+1,l),f=i.slice(d),h=En(a,f);an("appending to",se(l),"new child",se(h)),re(u,h);const g=c.slice(0,d).concat(f);an("updated state",a,se(Rn(a))),s=[a,g]}const[i]=s,a=Rn(i);return an("final push",se(a)),r.push(a),an(r.map(se)),r},jn=t=>{if(ce(t)){const e=kn(t),n=t.children;if(void 0!==n&&n.length>0){const t=[],r=[];T(n,(e=>{ae(e)||de(e)?r.push(e):(r.length>0&&(t.push(...Tn(r)),r.length=0),t.push(jn(e)))})),r.length>0&&t.push(...Tn(r)),re(e,ie(t))}return e}if(le(t))return(t=>ee(document.createComment(t.comment)))(t);throw ae(t)?new Error("Passing a text node to this method should not be possible"):new Error(`Unknown node type: ${JSON.stringify(t)}`)},Ln=(t,e)=>{const n=k.from(e).getOrThunk((()=>{const e={};return T(t.attributes,(t=>{e[t.name]=t.value})),e}));return et(n)?{}:{attrs:n}},Fn=(t,e)=>{const n=k.from(e).getOrThunk((()=>t?I(t,(t=>{const e=t.nodeName.toLowerCase();return fe(t)&&t.attributes.length>0?{type:e,...Ln(t)}:e})):[]));return 0===n.length?{}:{format:n}},$n=(t,e,n)=>{const r=t=>({id:e.nextOpId,type:t,uid:e.uid,timestamp:e.timestamp});return k.from(n).orThunk((()=>k.from(t).map(r))).map((t=>({opData:t}))).getOr({})},Un=(t,e,n)=>k.from(n).getOrThunk((()=>I(t.childNodes,(t=>Hn(t,e))))),zn=(t,e,n)=>{const r=$n(e.status.get(t),e,null==n?void 0:n.opData),o=Fn(e.formattingMap.get(t),null==n?void 0:n.format),s=(null==n?void 0:n.oldFormat)?{oldFormat:n.oldFormat}:{};return{text:t.nodeValue||"",...r,...o,...s}},Bn=(t,e,n)=>({type:t.nodeName.toLowerCase(),...$n(e.status.get(t),e,null==n?void 0:n.opData),...Ln(t,null==n?void 0:n.attrs),...(null==n?void 0:n.oldAttrs)?{oldAttrs:n.oldAttrs}:{}}),qn=(t,e,n)=>{const r=(null==n?void 0:n.children)?{children:n.children}:((t,e)=>{const n=Un(t,e);return 0===n.length?{}:{children:n}})(t,e);return{...Bn(t,e,n),...r}},Vn=(t,e,n)=>{const r=Fn(e.formattingMap.get(t),null==n?void 0:n.format);return{...Bn(t,e,n),...(null==n?void 0:n.oldFormat)?{oldFormat:n.oldFormat}:{},...r}},Hn=(t,e)=>{switch(!0){case ue(t):return zn(t,e);case pe(t):return Vn(t,e);case fe(t):return qn(t,e);case le(t):default:const n=e.status.get(t),r=n?$n(n,e):{};return{type:"comment",comment:t.data,...r}}},Kn=(t,e)=>{const n=t.getAttribute(e);return null===n?void 0:n},Wn=(t,e)=>k.from(Kn(t,e)),Gn=(t,e)=>document.createElement(t),Qn=(t,e)=>(e||document).createTextNode(t),Jn=t=>t.nodeName.toLowerCase(),Xn=t=>e=>e.nodeType===t,Zn=t=>8===t.nodeType||"#comment"===Jn(t),Yn=Xn(1),tr=Xn(3),er=Xn(9),nr=Xn(11),rr=t=>k.from(t.parentNode),or=t=>rr(t),sr=(t,e)=>{const n=w(e)?e:A;let r=t;const o=[];for(;null!==r.parentNode&&void 0!==r.parentNode;){const t=r.parentNode,e=t;if(o.push(e),!0===n(e))break;r=t}return o},ir=t=>k.from(t.previousSibling),ar=t=>k.from(t.nextSibling),lr=t=>V(t.childNodes),cr=t=>!t.hasChildNodes(),dr=(t,e)=>{const n=(e||document).createDocumentFragment();return T(t,(t=>{n.appendChild(t)})),n},ur=(t,e)=>t.cloneNode(e),fr=t=>ur(t,!1),hr=t=>ur(t,!0),gr=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32},pr=-1;(gr.Diff=function(t,e){this[0]=t,this[1]=e}).prototype.length=2,gr.Diff.prototype.toString=function(){return this[0]+","+this[1]},gr.Diff.prototype[Symbol.iterator]=function*(){yield this[0],yield this[1]},gr.prototype.diff_main=function(t,e,n,r){void 0===r&&(r=this.Diff_Timeout<=0?Number.MAX_VALUE:(new Date).getTime()+1e3*this.Diff_Timeout);var o=r;if(null==t||null==e)throw new Error("Null input. (diff_main)");if(t==e)return t?[new gr.Diff(0,t)]:[];void 0===n&&(n=!0);var s=n,i=this.diff_commonPrefix(t,e),a=t.substring(0,i);t=t.substring(i),e=e.substring(i),i=this.diff_commonSuffix(t,e);var l=t.substring(t.length-i);t=t.substring(0,t.length-i),e=e.substring(0,e.length-i);var c=this.diff_compute_(t,e,s,o);return a&&c.unshift(new gr.Diff(0,a)),l&&c.push(new gr.Diff(0,l)),this.diff_cleanupMerge(c),c},gr.prototype.diff_compute_=function(t,e,n,r){var o;if(!t)return[new gr.Diff(1,e)];if(!e)return[new gr.Diff(pr,t)];var s=t.length>e.length?t:e,i=t.length>e.length?e:t,a=s.indexOf(i);if(-1!=a)return o=[new gr.Diff(1,s.substring(0,a)),new gr.Diff(0,i),new gr.Diff(1,s.substring(a+i.length))],t.length>e.length&&(o[0][0]=o[2][0]=pr),o;if(1==i.length)return[new gr.Diff(pr,t),new gr.Diff(1,e)];var l=this.diff_halfMatch_(t,e);if(l){var c=l[0],d=l[1],u=l[2],f=l[3],h=l[4],g=this.diff_main(c,u,n,r),p=this.diff_main(d,f,n,r);return g.concat([new gr.Diff(0,h)],p)}return n&&t.length>100&&e.length>100?this.diff_lineMode_(t,e,r):this.diff_bisect_(t,e,r)},gr.prototype.diff_lineMode_=function(t,e,n){var r=this.diff_linesToChars_(t,e);t=r.chars1,e=r.chars2;var o=r.lineArray,s=this.diff_main(t,e,!1,n);this.diff_charsToLines_(s,o),this.diff_cleanupSemantic(s),s.push(new gr.Diff(0,""));for(var i=0,a=0,l=0,c="",d="";i<s.length;){switch(s[i][0]){case 1:l++,d+=s[i][1];break;case pr:a++,c+=s[i][1];break;case 0:if(a>=1&&l>=1){s.splice(i-a-l,a+l),i=i-a-l;for(var u=this.diff_main(c,d,!1,n),f=u.length-1;f>=0;f--)s.splice(i,0,u[f]);i+=u.length}l=0,a=0,c="",d=""}i++}return s.pop(),s},gr.prototype.diff_bisect_=function(t,e,n){for(var r=t.length,o=e.length,s=Math.ceil((r+o)/2),i=s,a=2*s,l=new Array(a),c=new Array(a),d=0;d<a;d++)l[d]=-1,c[d]=-1;l[i+1]=0,c[i+1]=0;for(var u=r-o,f=u%2!=0,h=0,g=0,p=0,m=0,v=0;v<s&&!((new Date).getTime()>n);v++){for(var y=-v+h;y<=v-g;y+=2){for(var w=i+y,b=(D=y==-v||y!=v&&l[w-1]<l[w+1]?l[w+1]:l[w-1]+1)-y;D<r&&b<o&&t.charAt(D)==e.charAt(b);)D++,b++;if(l[w]=D,D>r)g+=2;else if(b>o)h+=2;else if(f&&(x=i+u-y)>=0&&x<a&&-1!=c[x]&&D>=(C=r-c[x]))return this.diff_bisectSplit_(t,e,D,b,n)}for(var _=-v+p;_<=v-m;_+=2){for(var C,x=i+_,S=(C=_==-v||_!=v&&c[x-1]<c[x+1]?c[x+1]:c[x-1]+1)-_;C<r&&S<o&&t.charAt(r-C-1)==e.charAt(o-S-1);)C++,S++;if(c[x]=C,C>r)m+=2;else if(S>o)p+=2;else if(!f){var D;if((w=i+u-_)>=0&&w<a&&-1!=l[w])if(b=i+(D=l[w])-w,D>=(C=r-C))return this.diff_bisectSplit_(t,e,D,b,n)}}}return[new gr.Diff(pr,t),new gr.Diff(1,e)]},gr.prototype.diff_bisectSplit_=function(t,e,n,r,o){var s=t.substring(0,n),i=e.substring(0,r),a=t.substring(n),l=e.substring(r),c=this.diff_main(s,i,!1,o),d=this.diff_main(a,l,!1,o);return c.concat(d)},gr.prototype.diff_linesToChars_=function(t,e){var n=[],r={};function o(t){for(var e="",o=0,i=-1,a=n.length;i<t.length-1;){-1==(i=t.indexOf("\n",o))&&(i=t.length-1);var l=t.substring(o,i+1);(r.hasOwnProperty?r.hasOwnProperty(l):void 0!==r[l])?e+=String.fromCharCode(r[l]):(a==s&&(l=t.substring(o),i=t.length),e+=String.fromCharCode(a),r[l]=a,n[a++]=l),o=i+1}return e}n[0]="";var s=4e4,i=o(t);return s=65535,{chars1:i,chars2:o(e),lineArray:n}},gr.prototype.diff_charsToLines_=function(t,e){for(var n=0;n<t.length;n++){for(var r=t[n][1],o=[],s=0;s<r.length;s++)o[s]=e[r.charCodeAt(s)];t[n][1]=o.join("")}},gr.prototype.diff_commonPrefix=function(t,e){if(!t||!e||t.charAt(0)!=e.charAt(0))return 0;for(var n=0,r=Math.min(t.length,e.length),o=r,s=0;n<o;)t.substring(s,o)==e.substring(s,o)?s=n=o:r=o,o=Math.floor((r-n)/2+n);return o},gr.prototype.diff_commonSuffix=function(t,e){if(!t||!e||t.charAt(t.length-1)!=e.charAt(e.length-1))return 0;for(var n=0,r=Math.min(t.length,e.length),o=r,s=0;n<o;)t.substring(t.length-o,t.length-s)==e.substring(e.length-o,e.length-s)?s=n=o:r=o,o=Math.floor((r-n)/2+n);return o},gr.prototype.diff_commonOverlap_=function(t,e){var n=t.length,r=e.length;if(0==n||0==r)return 0;n>r?t=t.substring(n-r):n<r&&(e=e.substring(0,n));var o=Math.min(n,r);if(t==e)return o;for(var s=0,i=1;;){var a=t.substring(o-i),l=e.indexOf(a);if(-1==l)return s;i+=l,0!=l&&t.substring(o-i)!=e.substring(0,i)||(s=i,i++)}},gr.prototype.diff_halfMatch_=function(t,e){if(this.Diff_Timeout<=0)return null;var n=t.length>e.length?t:e,r=t.length>e.length?e:t;if(n.length<4||2*r.length<n.length)return null;var o=this;function s(t,e,n){for(var r,s,i,a,l=t.substring(n,n+Math.floor(t.length/4)),c=-1,d="";-1!=(c=e.indexOf(l,c+1));){var u=o.diff_commonPrefix(t.substring(n),e.substring(c)),f=o.diff_commonSuffix(t.substring(0,n),e.substring(0,c));d.length<f+u&&(d=e.substring(c-f,c)+e.substring(c,c+u),r=t.substring(0,n-f),s=t.substring(n+u),i=e.substring(0,c-f),a=e.substring(c+u))}return 2*d.length>=t.length?[r,s,i,a,d]:null}var i,a,l,c,d,u=s(n,r,Math.ceil(n.length/4)),f=s(n,r,Math.ceil(n.length/2));return u||f?(i=f?u&&u[4].length>f[4].length?u:f:u,t.length>e.length?(a=i[0],l=i[1],c=i[2],d=i[3]):(c=i[0],d=i[1],a=i[2],l=i[3]),[a,l,c,d,i[4]]):null},gr.prototype.diff_cleanupSemantic=function(t){for(var e=!1,n=[],r=0,o=null,s=0,i=0,a=0,l=0,c=0;s<t.length;)0==t[s][0]?(n[r++]=s,i=l,a=c,l=0,c=0,o=t[s][1]):(1==t[s][0]?l+=t[s][1].length:c+=t[s][1].length,o&&o.length<=Math.max(i,a)&&o.length<=Math.max(l,c)&&(t.splice(n[r-1],0,new gr.Diff(pr,o)),t[n[r-1]+1][0]=1,r--,s=--r>0?n[r-1]:-1,i=0,a=0,l=0,c=0,o=null,e=!0)),s++;for(e&&this.diff_cleanupMerge(t),this.diff_cleanupSemanticLossless(t),s=1;s<t.length;){if(t[s-1][0]==pr&&1==t[s][0]){var d=t[s-1][1],u=t[s][1],f=this.diff_commonOverlap_(d,u),h=this.diff_commonOverlap_(u,d);f>=h?(f>=d.length/2||f>=u.length/2)&&(t.splice(s,0,new gr.Diff(0,u.substring(0,f))),t[s-1][1]=d.substring(0,d.length-f),t[s+1][1]=u.substring(f),s++):(h>=d.length/2||h>=u.length/2)&&(t.splice(s,0,new gr.Diff(0,d.substring(0,h))),t[s-1][0]=1,t[s-1][1]=u.substring(0,u.length-h),t[s+1][0]=pr,t[s+1][1]=d.substring(h),s++),s++}s++}},gr.prototype.diff_cleanupSemanticLossless=function(t){function e(t,e){if(!t||!e)return 6;var n=t.charAt(t.length-1),r=e.charAt(0),o=n.match(gr.nonAlphaNumericRegex_),s=r.match(gr.nonAlphaNumericRegex_),i=o&&n.match(gr.whitespaceRegex_),a=s&&r.match(gr.whitespaceRegex_),l=i&&n.match(gr.linebreakRegex_),c=a&&r.match(gr.linebreakRegex_),d=l&&t.match(gr.blanklineEndRegex_),u=c&&e.match(gr.blanklineStartRegex_);return d||u?5:l||c?4:o&&!i&&a?3:i||a?2:o||s?1:0}for(var n=1;n<t.length-1;){if(0==t[n-1][0]&&0==t[n+1][0]){var r=t[n-1][1],o=t[n][1],s=t[n+1][1],i=this.diff_commonSuffix(r,o);if(i){var a=o.substring(o.length-i);r=r.substring(0,r.length-i),o=a+o.substring(0,o.length-i),s=a+s}for(var l=r,c=o,d=s,u=e(r,o)+e(o,s);o.charAt(0)===s.charAt(0);){r+=o.charAt(0),o=o.substring(1)+s.charAt(0),s=s.substring(1);var f=e(r,o)+e(o,s);f>=u&&(u=f,l=r,c=o,d=s)}t[n-1][1]!=l&&(l?t[n-1][1]=l:(t.splice(n-1,1),n--),t[n][1]=c,d?t[n+1][1]=d:(t.splice(n+1,1),n--))}n++}},gr.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,gr.whitespaceRegex_=/\s/,gr.linebreakRegex_=/[\r\n]/,gr.blanklineEndRegex_=/\n\r?\n$/,gr.blanklineStartRegex_=/^\r?\n\r?\n/,gr.prototype.diff_cleanupEfficiency=function(t){for(var e=!1,n=[],r=0,o=null,s=0,i=!1,a=!1,l=!1,c=!1;s<t.length;)0==t[s][0]?(t[s][1].length<this.Diff_EditCost&&(l||c)?(n[r++]=s,i=l,a=c,o=t[s][1]):(r=0,o=null),l=c=!1):(t[s][0]==pr?c=!0:l=!0,o&&(i&&a&&l&&c||o.length<this.Diff_EditCost/2&&i+a+l+c==3)&&(t.splice(n[r-1],0,new gr.Diff(pr,o)),t[n[r-1]+1][0]=1,r--,o=null,i&&a?(l=c=!0,r=0):(s=--r>0?n[r-1]:-1,l=c=!1),e=!0)),s++;e&&this.diff_cleanupMerge(t)},gr.prototype.diff_cleanupMerge=function(t){t.push(new gr.Diff(0,""));for(var e,n=0,r=0,o=0,s="",i="";n<t.length;)switch(t[n][0]){case 1:o++,i+=t[n][1],n++;break;case pr:r++,s+=t[n][1],n++;break;case 0:r+o>1?(0!==r&&0!==o&&(0!==(e=this.diff_commonPrefix(i,s))&&(n-r-o>0&&0==t[n-r-o-1][0]?t[n-r-o-1][1]+=i.substring(0,e):(t.splice(0,0,new gr.Diff(0,i.substring(0,e))),n++),i=i.substring(e),s=s.substring(e)),0!==(e=this.diff_commonSuffix(i,s))&&(t[n][1]=i.substring(i.length-e)+t[n][1],i=i.substring(0,i.length-e),s=s.substring(0,s.length-e))),n-=r+o,t.splice(n,r+o),s.length&&(t.splice(n,0,new gr.Diff(pr,s)),n++),i.length&&(t.splice(n,0,new gr.Diff(1,i)),n++),n++):0!==n&&0==t[n-1][0]?(t[n-1][1]+=t[n][1],t.splice(n,1)):n++,o=0,r=0,s="",i=""}""===t[t.length-1][1]&&t.pop();var a=!1;for(n=1;n<t.length-1;)0==t[n-1][0]&&0==t[n+1][0]&&(t[n][1].substring(t[n][1].length-t[n-1][1].length)==t[n-1][1]?(t[n][1]=t[n-1][1]+t[n][1].substring(0,t[n][1].length-t[n-1][1].length),t[n+1][1]=t[n-1][1]+t[n+1][1],t.splice(n-1,1),a=!0):t[n][1].substring(0,t[n+1][1].length)==t[n+1][1]&&(t[n-1][1]+=t[n+1][1],t[n][1]=t[n][1].substring(t[n+1][1].length)+t[n+1][1],t.splice(n+1,1),a=!0)),n++;a&&this.diff_cleanupMerge(t)},gr.prototype.diff_cleanupSplitSurrogates=function(t){for(var e,n=0;n<t.length;n++){var r=t[n],o=r[1][0],s=r[1][r[1].length-1];0!==r[1].length?(s&&this.isHighSurrogate(s)&&(e=s,r[1]=r[1].slice(0,-1)),e&&o&&this.isHighSurrogate(e)&&this.isLowSurrogate(o)&&(r[1]=e+r[1]),0!==r[1].length||t.splice(n--,1)):t.splice(n--,1)}return t},gr.prototype.isHighSurrogate=function(t){var e=t.charCodeAt(0);return e>=55296&&e<=56319},gr.prototype.isLowSurrogate=function(t){var e=t.charCodeAt(0);return e>=56320&&e<=57343},gr.prototype.digit16=function(t){switch(t){case"0":return 0;case"1":return 1;case"2":return 2;case"3":return 3;case"4":return 4;case"5":return 5;case"6":return 6;case"7":return 7;case"8":return 8;case"9":return 9;case"A":case"a":return 10;case"B":case"b":return 11;case"C":case"c":return 12;case"D":case"d":return 13;case"E":case"e":return 14;case"F":case"f":return 15;default:throw new Error("Invalid hex-code")}},gr.prototype.decodeURI=function(t){try{return decodeURI(t)}catch(l){for(var e=0,n="";e<t.length;)if("%"===t[e]){var r=(this.digit16(t[e+1])<<4)+this.digit16(t[e+2]);if(128&r){if("%"!==t[e+3])throw new URIError("URI malformed");var o=(this.digit16(t[e+4])<<4)+this.digit16(t[e+5]);if(128!=(192&o))throw new URIError("URI malformed");if(o&=63,192!=(224&r)){if("%"!==t[e+6])throw new URIError("URI malformed");var s=(this.digit16(t[e+7])<<4)+this.digit16(t[e+8]);if(128!=(192&s))throw new URIError("URI malformed");if(s&=63,224!=(240&r)){if("%"!==t[e+9])throw new URIError("URI malformed");var i=(this.digit16(t[e+10])<<4)+this.digit16(t[e+11]);if(128!=(192&i))throw new URIError("URI malformed");if(i&=63,240==(248&r)){var a=(7&r)<<18|o<<12|s<<6|i;if(a>=65536&&a<=1114111){n+=String.fromCharCode((65535&a)>>>10&1023|55296),n+=String.fromCharCode(56320|1023&a),e+=12;continue}}throw new URIError("URI malformed")}n+=String.fromCharCode((15&r)<<12|o<<6|s),e+=9}else n+=String.fromCharCode((31&r)<<6|o),e+=6}else n+=String.fromCharCode(r),e+=3}else n+=t[e++];return n}},gr.prototype.diff_xIndex=function(t,e){var n,r=0,o=0,s=0,i=0;for(n=0;n<t.length&&(1!==t[n][0]&&(r+=t[n][1].length),t[n][0]!==pr&&(o+=t[n][1].length),!(r>e));n++)s=r,i=o;return t.length!=n&&t[n][0]===pr?i:i+(e-s)},gr.prototype.diff_prettyHtml=function(t){t=this.diff_cleanupSplitSurrogates(t);for(var e=[],n=/&/g,r=/</g,o=/>/g,s=/\n/g,i=0;i<t.length;i++){var a=t[i][0],l=t[i][1].replace(n,"&amp;").replace(r,"&lt;").replace(o,"&gt;").replace(s,"&para;<br>");switch(a){case 1:e[i]='<ins style="background:#e6ffe6;">'+l+"</ins>";break;case pr:e[i]='<del style="background:#ffe6e6;">'+l+"</del>";break;case 0:e[i]="<span>"+l+"</span>"}}return e.join("")},gr.prototype.diff_text1=function(t){for(var e=[],n=0;n<t.length;n++)1!==t[n][0]&&(e[n]=t[n][1]);return e.join("")},gr.prototype.diff_text2=function(t){for(var e=[],n=0;n<t.length;n++)t[n][0]!==pr&&(e[n]=t[n][1]);return e.join("")},gr.prototype.diff_levenshtein=function(t){for(var e=0,n=0,r=0,o=0;o<t.length;o++){var s=t[o][0],i=t[o][1];switch(s){case 1:n+=i.length;break;case pr:r+=i.length;break;case 0:e+=Math.max(n,r),n=0,r=0}}return e+Math.max(n,r)},gr.prototype.diff_toDelta=function(t){t=this.diff_cleanupSplitSurrogates(t);for(var e=[],n=0;n<t.length;n++)switch(t[n][0]){case 1:e[n]="+"+encodeURI(t[n][1]);break;case pr:e[n]="-"+t[n][1].length;break;case 0:e[n]="="+t[n][1].length}return e.join("\t").replace(/%20/g," ")},gr.prototype.diff_fromDelta=function(t,e){for(var n=[],r=0,o=0,s=e.split(/\t/g),i=0;i<s.length;i++){var a=s[i].substring(1);switch(s[i].charAt(0)){case"+":try{n[r++]=new gr.Diff(1,this.decodeURI(a))}catch(t){throw new Error("Illegal escape in diff_fromDelta: "+a)}break;case"-":case"=":var l=parseInt(a,10);if(isNaN(l)||l<0)throw new Error("Invalid number in diff_fromDelta: "+a);var c=t.substring(o,o+=l);"="==s[i].charAt(0)?n[r++]=new gr.Diff(0,c):n[r++]=new gr.Diff(pr,c);break;default:if(s[i])throw new Error("Invalid diff operation in diff_fromDelta: "+s[i])}}if(o!=t.length)throw new Error("Delta length ("+o+") does not equal source text length ("+t.length+").");return n},gr.prototype.match_main=function(t,e,n){if(null==t||null==e||null==n)throw new Error("Null input. (match_main)");return n=Math.max(0,Math.min(n,t.length)),t==e?0:t.length?t.substring(n,n+e.length)==e?n:this.match_bitap_(t,e,n):-1},gr.prototype.match_bitap_=function(t,e,n){if(e.length>this.Match_MaxBits)throw new Error("Pattern too long for this browser.");var r=this.match_alphabet_(e),o=this;function s(t,r){var s=t/e.length,i=Math.abs(n-r);return o.Match_Distance?s+i/o.Match_Distance:i?1:s}var i=this.Match_Threshold,a=t.indexOf(e,n);-1!=a&&(i=Math.min(s(0,a),i),-1!=(a=t.lastIndexOf(e,n+e.length))&&(i=Math.min(s(0,a),i)));var l,c,d=1<<e.length-1;a=-1;for(var u,f=e.length+t.length,h=0;h<e.length;h++){for(l=0,c=f;l<c;)s(h,n+c)<=i?l=c:f=c,c=Math.floor((f-l)/2+l);f=c;var g=Math.max(1,n-c+1),p=Math.min(n+c,t.length)+e.length,m=Array(p+2);m[p+1]=(1<<h)-1;for(var v=p;v>=g;v--){var y=r[t.charAt(v-1)];if(m[v]=0===h?(m[v+1]<<1|1)&y:(m[v+1]<<1|1)&y|(u[v+1]|u[v])<<1|1|u[v+1],m[v]&d){var w=s(h,v-1);if(w<=i){if(i=w,!((a=v-1)>n))break;g=Math.max(1,2*n-a)}}}if(s(h+1,n)>i)break;u=m}return a},gr.prototype.match_alphabet_=function(t){for(var e={},n=0;n<t.length;n++)e[t.charAt(n)]=0;for(n=0;n<t.length;n++)e[t.charAt(n)]|=1<<t.length-n-1;return e},gr.prototype.patch_addContext_=function(t,e){if(0!=e.length){if(null===t.start2)throw Error("patch not initialized");for(var n=e.substring(t.start2,t.start2+t.length1),r=0;e.indexOf(n)!=e.lastIndexOf(n)&&n.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)r+=this.Patch_Margin,n=e.substring(t.start2-r,t.start2+t.length1+r);r+=this.Patch_Margin,t.start2-r>0&&gr.prototype.isLowSurrogate(e[t.start2-r])&&r++;var o=e.substring(t.start2-r,t.start2);o&&t.diffs.unshift(new gr.Diff(0,o)),t.start2+t.length1+r<e.length&&gr.prototype.isHighSurrogate(e[t.start2+t.length1+r])&&r++;var s=e.substring(t.start2+t.length1,t.start2+t.length1+r);s&&t.diffs.push(new gr.Diff(0,s)),t.start1-=o.length,t.start2-=o.length,t.length1+=o.length+s.length,t.length2+=o.length+s.length}},gr.prototype.patch_make=function(t,e,n){var r,o;if("string"==typeof t&&"string"==typeof e&&void 0===n)r=t,(o=this.diff_main(r,e,!0)).length>2&&(this.diff_cleanupSemantic(o),this.diff_cleanupEfficiency(o));else if(t&&"object"==typeof t&&void 0===e&&void 0===n)o=t,r=this.diff_text1(o);else if("string"==typeof t&&e&&"object"==typeof e&&void 0===n)r=t,o=e;else{if("string"!=typeof t||"string"!=typeof e||!n||"object"!=typeof n)throw new Error("Unknown call format to patch_make.");r=t,o=n}if(0===o.length)return[];o=this.diff_cleanupSplitSurrogates(o);for(var s=[],i=new gr.patch_obj,a=0,l=0,c=0,d=r,u=r,f=0;f<o.length;f++){var h=o[f][0],g=o[f][1];switch(a||0===h||(i.start1=l,i.start2=c),h){case 1:i.diffs[a++]=o[f],i.length2+=g.length,u=u.substring(0,c)+g+u.substring(c);break;case pr:i.length1+=g.length,i.diffs[a++]=o[f],u=u.substring(0,c)+u.substring(c+g.length);break;case 0:g.length<=2*this.Patch_Margin&&a&&o.length!=f+1?(i.diffs[a++]=o[f],i.length1+=g.length,i.length2+=g.length):g.length>=2*this.Patch_Margin&&a&&(this.patch_addContext_(i,d),s.push(i),i=new gr.patch_obj,a=0,d=u,l=c)}1!==h&&(l+=g.length),h!==pr&&(c+=g.length)}return a&&(this.patch_addContext_(i,d),s.push(i)),s},gr.prototype.patch_deepCopy=function(t){for(var e=[],n=0;n<t.length;n++){var r=t[n],o=new gr.patch_obj;o.diffs=[];for(var s=0;s<r.diffs.length;s++)o.diffs[s]=new gr.Diff(r.diffs[s][0],r.diffs[s][1]);o.start1=r.start1,o.start2=r.start2,o.length1=r.length1,o.length2=r.length2,e[n]=o}return e},gr.prototype.patch_apply=function(t,e){if(0==t.length)return[e,[]];t=this.patch_deepCopy(t);var n=this.patch_addPadding(t);e=n+e+n,this.patch_splitMax(t);for(var r=0,o=[],s=0;s<t.length;s++){var i,a,l=t[s].start2+r,c=this.diff_text1(t[s].diffs),d=-1;if(c.length>this.Match_MaxBits?-1!=(i=this.match_main(e,c.substring(0,this.Match_MaxBits),l))&&(-1==(d=this.match_main(e,c.substring(c.length-this.Match_MaxBits),l+c.length-this.Match_MaxBits))||i>=d)&&(i=-1):i=this.match_main(e,c,l),-1==i)o[s]=!1,r-=t[s].length2-t[s].length1;else if(o[s]=!0,r=i-l,c==(a=-1==d?e.substring(i,i+c.length):e.substring(i,d+this.Match_MaxBits)))e=e.substring(0,i)+this.diff_text2(t[s].diffs)+e.substring(i+c.length);else{var u=this.diff_main(c,a,!1);if(c.length>this.Match_MaxBits&&this.diff_levenshtein(u)/c.length>this.Patch_DeleteThreshold)o[s]=!1;else{this.diff_cleanupSemanticLossless(u);for(var f,h=0,g=0;g<t[s].diffs.length;g++){var p=t[s].diffs[g];0!==p[0]&&(f=this.diff_xIndex(u,h)),1===p[0]?e=e.substring(0,i+f)+p[1]+e.substring(i+f):p[0]===pr&&(e=e.substring(0,i+f)+e.substring(i+this.diff_xIndex(u,h+p[1].length))),p[0]!==pr&&(h+=p[1].length)}}}}return[e=e.substring(n.length,e.length-n.length),o]},gr.prototype.patch_addPadding=function(t){for(var e=this.Patch_Margin,n="",r=1;r<=e;r++)n+=String.fromCharCode(r);for(r=0;r<t.length;r++)t[r].start1+=e,t[r].start2+=e;var o=t[0],s=o.diffs;if(0==s.length||0!=s[0][0])s.unshift(new gr.Diff(0,n)),o.start1-=e,o.start2-=e,o.length1+=e,o.length2+=e;else if(e>s[0][1].length){var i=e-s[0][1].length;s[0][1]=n.substring(s[0][1].length)+s[0][1],o.start1-=i,o.start2-=i,o.length1+=i,o.length2+=i}return 0==(s=(o=t[t.length-1]).diffs).length||0!=s[s.length-1][0]?(s.push(new gr.Diff(0,n)),o.length1+=e,o.length2+=e):e>s[s.length-1][1].length&&(i=e-s[s.length-1][1].length,s[s.length-1][1]+=n.substring(0,i),o.length1+=i,o.length2+=i),n},gr.prototype.patch_splitMax=function(t){for(var e=this.Match_MaxBits,n=0;n<t.length;n++)if(!(t[n].length1<=e)){var r=t[n];t.splice(n--,1);for(var o=r.start1,s=r.start2,i="";0!==r.diffs.length;){var a=new gr.patch_obj,l=!0;for(a.start1=o-i.length,a.start2=s-i.length,""!==i&&(a.length1=a.length2=i.length,a.diffs.push(new gr.Diff(0,i)));0!==r.diffs.length&&a.length1<e-this.Patch_Margin;){var c=r.diffs[0][0],d=r.diffs[0][1];1===c?(a.length2+=d.length,s+=d.length,a.diffs.push(r.diffs.shift()),l=!1):c===pr&&1==a.diffs.length&&0==a.diffs[0][0]&&d.length>2*e?(a.length1+=d.length,o+=d.length,l=!1,a.diffs.push(new gr.Diff(c,d)),r.diffs.shift()):(d=d.substring(0,e-a.length1-this.Patch_Margin),a.length1+=d.length,o+=d.length,0===c?(a.length2+=d.length,s+=d.length):l=!1,a.diffs.push(new gr.Diff(c,d)),d==r.diffs[0][1]?r.diffs.shift():r.diffs[0][1]=r.diffs[0][1].substring(d.length))}i=(i=this.diff_text2(a.diffs)).substring(i.length-this.Patch_Margin);var u=this.diff_text1(r.diffs).substring(0,this.Patch_Margin);""!==u&&(a.length1+=u.length,a.length2+=u.length,0!==a.diffs.length&&0===a.diffs[a.diffs.length-1][0]?a.diffs[a.diffs.length-1][1]+=u:a.diffs.push(new gr.Diff(0,u))),l||t.splice(++n,0,a)}}},gr.prototype.patch_toText=function(t){for(var e=[],n=0;n<t.length;n++)e[n]=t[n];return e.join("")},gr.prototype.patch_fromText=function(t){var e=[];if(!t)return e;for(var n=t.split("\n"),r=0,o=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;r<n.length;){var s=n[r].match(o);if(!s)throw new Error("Invalid patch string: "+n[r]);var i=new gr.patch_obj;for(e.push(i),i.start1=parseInt(s[1],10),""===s[2]?(i.start1--,i.length1=1):"0"==s[2]?i.length1=0:(i.start1--,i.length1=parseInt(s[2],10)),i.start2=parseInt(s[3],10),""===s[4]?(i.start2--,i.length2=1):"0"==s[4]?i.length2=0:(i.start2--,i.length2=parseInt(s[4],10)),r++;r<n.length;){var a=n[r].charAt(0);try{var l=decodeURI(n[r].substring(1))}catch(t){throw new Error("Illegal escape in patch_fromText: "+l)}if("-"==a)i.diffs.push(new gr.Diff(pr,l));else if("+"==a)i.diffs.push(new gr.Diff(1,l));else if(" "==a)i.diffs.push(new gr.Diff(0,l));else{if("@"==a)break;if(""!==a)throw new Error('Invalid patch mode "'+a+'" in: '+l)}r++}}return e},(gr.patch_obj=function(){this.diffs=[],this.start1=null,this.start2=null,this.length1=0,this.length2=0}).prototype.toString=function(){var t,e=["@@ -"+(0===this.length1?this.start1+",0":1==this.length1?this.start1+1:this.start1+1+","+this.length1)+" +"+(0===this.length2?this.start2+",0":1==this.length2?this.start2+1:this.start2+1+","+this.length2)+" @@\n"];gr.prototype.diff_cleanupSplitSurrogates(this.diffs);for(var n=0;n<this.diffs.length;n++){switch(this.diffs[n][0]){case 1:t="+";break;case pr:t="-";break;case 0:t=" "}e[n+1]=t+encodeURI(this.diffs[n][1])+"\n"}return e.join("").replace(/%20/g," ")};const mr=(t,e)=>{const n=Jn(t);return n===Jn(e)&&R(["img","iframe","audio","video","embed","source"],n)&&((t,e,n=S)=>{return(r=t,o=e,s=n,r.isSome()&&o.isSome()?k.some(s(r.getOrDie(),o.getOrDie())):k.none()).getOr(t.isNone()&&e.isNone());var r,o,s})(Wn(t,"src"),Wn(e,"src"))},vr=(t,e)=>{const n=new Set(e);return L(t.trim().split(/\s+/),(t=>!n.has(t)&&t.length>0))},yr=(t,e,n,r)=>{var o;const s=null===(o=r[t.toLowerCase()])||void 0===o?void 0:o[e];return!v(s)&&(!0===s.ignore||(s.predicate?s.predicate(n):!!s.ignoreTokens&&0===vr(n,s.ignoreTokens).length))},wr=(t,e)=>{if(!Yn(t))return!1;const n=Array.from(t.attributes);return 0!==n.length&&B(n,(({name:n,value:r})=>yr(t.tagName,n,r,e)))},br=(t,e,n)=>{const r=t.tagName.toLowerCase(),o=n[r];return!!v(o)||B(K(o),(r=>_r(r,t,e,n)))},_r=(t,e,n,r)=>{var o,s;const i=null!==(o=e.getAttribute(t))&&void 0!==o?o:"",a=null!==(s=n.getAttribute(t))&&void 0!==s?s:"",l=(r[e.tagName.toLowerCase()]||{})[t];if(m(l))return i===a;if(null==l?void 0:l.predicate){const t=l.predicate(i),e=l.predicate(a);return!t&&!e||i===a}if(null==l?void 0:l.ignoreTokens){const t=vr(i,l.ignoreTokens),e=vr(a,l.ignoreTokens);return t.length===e.length&&q(t,e)}return i===a},Cr=(t,e,r=!1,o={})=>{if(t===e)return!0;if(t.nodeType!==e.nodeType||Jn(t)!==Jn(e))return!1;if(tr(t)||Zn(t)){if(t.data!==e.data)return!1}else if(Yn(t)){const r=t=>(t=>{const e=N.call(t,0);return e.sort(void 0),e})(t.getAttributeNames?t.getAttributeNames():Object.keys($(t.attributes,((t,e)=>(t[e.name]=e.value,t)),{}))),s=t=>L(r(t),(e=>{var n;return!yr(t.tagName,e,null!==(n=t.getAttribute(e))&&void 0!==n?n:"",o)})),i=s(t),a=s(e);if(!q(i,a,n))return!1;for(let n=0,r=i.length;n<r;++n)if(!_r(i[n],t,e,o))return!1}if(r){const n=lr(t),r=lr(e);return q(n,r,{eq:(t,e)=>Cr(t,e,!0,o)})}return!0},xr=(t,e=k.none())=>e.fold((()=>sr(t)),(e=>t===e?[]:sr(t,(t=>t===e)))),Sr=(t="visual-dom-diff: An error occurred when trying to calculate the diff between content")=>{throw new Error(t)},Dr=(t,e)=>U(e,(e=>Yn(t)&&t.matches(e))),Ar=t=>String.fromCharCode(57344+Math.abs((t=>{let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return e})(t))%6400),Mr=t=>{for(let e=0;e<t.length-2;){const n=t[e],r=t[e+1],o=t[e+2];if(0!==n[0]||0===r[0]||0!==o[0]){e++;continue}const s=n[1],i=r[1],a=o[1],l=s[s.length-1];l!==i[i.length-1]||l<"\ue000"||l>="\uf900"||l===Ar("col")||l===Ar("colgroup")?e++:(n[1]=s.substring(0,s.length-1),r[1]=l+i.substring(0,i.length-1),o[1]=l+a,0===n[1].length&&t.splice(e,1))}},kr=(t,e,n)=>{const r=(t=>{const e=new gr;return e.Diff_EditCost=null!=t?t:8,e.Diff_Timeout=10,e})(n),o=r.diff_main(t,e),s=[],i=[];Mr(o);for(let t=0,e=o.length;t<e;++t){const e=o[t];if(0===e[0]){const t=e[1],n=t.length,o=k.from(/^[^\uE000-\uF8FF]*/.exec(t)).map((t=>t[0].length)).getOr(0);if(o<n){const e=k.from(/[^\uE000-\uF8FF]*$/.exec(t)).map((t=>t[0].length)).getOr(0);o>0&&i.push(new gr.Diff(0,t.substring(0,o))),r.diff_cleanupSemantic(i),r.diff_cleanupEfficiency(i),Nr(s,i),i.length=0,s.push(new gr.Diff(0,t.substring(o,n-e))),e>0&&i.push(new gr.Diff(0,t.substring(n-e)))}else i.push(e)}else i.push(e)}return r.diff_cleanupSemantic(i),r.diff_cleanupEfficiency(i),Nr(s,i),i.length=0,r.diff_cleanupMerge(s),Mr(s),s},Nr=(t,e)=>{Array.prototype.push.apply(t,e)},Or=(t,e)=>{let n;const r=t=>{const e=Jn(t);return"th"===e||"td"===e},o=t=>{const o=t.nodeName.toLowerCase(),s=lr(t);return("tbody"!==o||0!==s.length)&&B(s,((t,o)=>((t,o)=>{const s=Jn(t),i=lr(t);if("tr"!==s||0===i.length)return!1;const a=t=>$(t,((t,e)=>{if(!Yn(e))return{columns:t.columns+1,rowspan:t.rowspan+1};const n=Wn(e,"colspan").map((t=>parseInt(t,10))).getOr(1);return{columns:t.columns+n,rowspan:t.rowspan+Wn(e,"rowspan").map((t=>parseInt(t,10)-1)).getOr(0)*n}}),{columns:0,rowspan:0});if(e)if(m(n))n=a(i);else{const t=a(i);if(n.rowspan>0){const e=t.columns+n.rowspan-n.columns<0,r=o&&n.rowspan+t.columns>n.columns;if(e||r)return!1;{const e=n.columns-t.columns;n={columns:n.columns,rowspan:n.rowspan-e+t.rowspan}}}else{if(n.columns!==t.columns)return!1;n=t}}return B(i,r)})(t,s.length-1===o)))};return(t=>{const e=lr(t),n=e.length;let r=0;if(r<n&&"caption"===Jn(e[r])&&r++,r<n&&"colgroup"===e[r].nodeName.toLowerCase()){if(!(t=>{if(!Yn(t))return!1;const e=t=>Wn(t,"span").map((t=>parseInt(t,10))).getOr(1),n=lr(t),r=e(t);return(0===n.length||B(n,(t=>!(!Yn(t)||"col"!==t.nodeName.toLowerCase())&&1===e(t))))&&1===r})(e[r]))return!1;r++}if(r<n&&"thead"===e[r].nodeName.toLowerCase()){if(!o(e[r]))return!1;r++}if(!(r<n&&"tbody"===Jn(e[r])))return!1;if(!o(e[r]))return!1;if(r++,r<n&&"tfoot"===Jn(e[r])){if(!o(e[r]))return!1;r++}return r===n})(t)},Er=(t,e,n)=>k.from(t.get(e)).exists((t=>t===n)),Rr=(t,e)=>U(Array.from(t.entries()),(([t])=>t===e)).map((([,t])=>t)),Pr=new Set(["img","iframe","object","svg","br","hr","wbr","area","base","basefont","embed","frame","link","meta","param","source","track"]),Ir=new Set(["bdo","bdi","q","cite","code","data","time","var","dfn","abbr","strong","em","big","small","mark","sub","sup","samp","kbd","b","i","s","u","span","a"]);class Tr{constructor(t,e){this.descend=!0,this.nextNode=t,this.rootNode=t,this.config=e,this.skipSelf(this.nextNode)&&this.next()}toArray(){const t=[];let e=this.next();for(;!e.done;){const{value:n}=e;t.push(n),e=this.next()}return t}forEach(t){let e=0,n=this.next();for(;!n.done;)t(n.value,e),n=this.next(),e++}reduce(t,e){let n=e,r=this.next();for(;!r.done;)n=t(n,r.value),r=this.next();return n}some(t){let e=this.next();for(;!e.done;){if(t(e.value))return!0;e=this.next()}return!1}next(){const t=this.nextNode;if(!t)return{done:!0,value:this.rootNode};let e;do{e=this.nextImpl()}while(e.skip&&!e.done);return e.done?{done:!0,value:this.rootNode}:{done:!1,value:t}}nextImpl(){const t=this.nextNode;if(!t)return{done:!0,skip:!1};if(this.descend&&t.firstChild&&!this.skipChildren(t))this.nextNode=(e=t,(t=>{const e=t.childNodes;return k.from(e[0])})(e)).getOrNull();else if(t===this.rootNode)this.nextNode=null;else{if(!ar(t).isSome())return this.nextNode=rr(t).getOrNull(),this.descend=!1,{done:!1,skip:!0};this.nextNode=ar(t).getOrNull(),this.descend=!0}var e;return{done:!1,skip:this.skipSelf(this.nextNode)}}skipSelf(t){return!!(t&&this.config&&this.config.skipSelf)&&this.config.skipSelf(t)}skipChildren(t){return!(!this.config||!this.config.skipChildren)&&this.config.skipChildren(t)}}const jr=t=>{const e=t.toLowerCase();return"th"===e?"td":e},Lr=(t,e)=>{const n={},r=e.normaliseNbsp?t=>t.replace("\xa0"," "):x;return new Tr(t,e).reduce(((t,o)=>{const s=Dr(o,e.atomicSelectors);return s.fold((()=>{switch(!0){case tr(o):return t+r(o.data);case Yn(o):const n=Ar(jr(o.nodeName.toLowerCase()));return t+n;case Zn(o):const s=o.nodeName.toLowerCase()+(e.trackComment(o)?o.data:""),i=Ar(jr(s));return t+i;default:return t}}),(e=>{n[e]=(n[e]||0)+1;const r=o.nodeName+s+n[e];return t+Ar(r)}))}),"")},Fr=t=>tr(t)?t.length:1,$r=t=>"tr"===t.nodeName.toLowerCase(),Ur={skipChildren:$r,skipSelf:t=>!$r(t)},zr=t=>"colgroup"===t.nodeName.toLowerCase(),Br={skipChildren:zr,skipSelf:t=>!zr(t)},qr=(t,e,n)=>{const r=er(o=e)?o:o.ownerDocument;var o;const{diffText:s,skipSelf:i,skipChildren:a}=n,l=t=>!i(t),c=(t,e)=>L(xr(t,k.from(e)),l).length,d=t=>Yn(t)&&i(t),u=(t,e)=>(t=>{const e=N.call(t,0);return e.reverse(),e})(L(xr(t,k.from(e)),d)),f=t=>Yn(t)&&Dr(t,n.atomicSelectors).isSome(),h=s(Lr(t,n),Lr(e,n));let g=0;const p=new Tr(t,n),m=new Tr(e,n);let v,w,b,_,C,x=0,S=0,D=0;b=h[g++],({done:v,value:_}=p.next()),({done:w,value:C}=m.next());const A=dr([],r);let M=A,O=0,E=A,R=0,I=k.none(),F=k.none();const z=new Map,q=new Map,H=new Array,K=new Map,W=new Map,G=new Set,Q=new Set,J=t=>tr(t)||Yn(t)&&cr(t),X=(t,e)=>{const r=u(_,t),o=u(C,e),{pass:s,fail:i}=j(r,(t=>!wr(t,n.ignoreAttributes))),{pass:a,fail:l}=j(o,(t=>!wr(t,n.ignoreAttributes))),c=i.length!==l.length||P(i,((t,e)=>{const r=l[e];return Yn(t)&&Yn(r)&&!br(t,r,n.ignoreAttributes)}));return{nonIgnoredChanged:s.length!==a.length||P(s,((t,e)=>!Cr(t,a[e],!1,n.ignoreAttributes))),ignoredChanged:c,formatsToStore:o}},Z={table:t=>H.push({newTable:C,oldTable:_,outputTable:t}),tr:t=>K.set(t,{newRow:C,oldRow:_}),colgroup:t=>W.set(t,{newRow:C,oldRow:_})},Y=()=>{const e=c(_,t);for(;O>e;)rr(M).fold((()=>{Sr()}),(t=>{I.each((t=>{M===t&&(I=k.none())})),M=t,O--}));O!==e&&Sr()},tt=()=>{const t=c(C,e);for(;R>t;)rr(E).fold((()=>{Sr()}),(t=>{F.each((t=>{E===t&&(F=k.none())})),E=t,R--}));R!==t&&Sr()},et=r=>{if((M!==E||F.isSome()||I.isSome())&&Sr(),tr(r)){const{nonIgnoredChanged:n,formatsToStore:o,ignoredChanged:s}=X(t,e);o.length>0&&q.set(r,o),n?z.set(r,"modify"):s&&G.add(r)}else if(!Yn(r)||f(_)||f(C))Zn(r)&&(n.trackComment(r)||G.add(r));else{const{nonIgnoredChanged:o,formatsToStore:s,ignoredChanged:i}=X(t,e);s.length>0&&cr(C)&&q.set(r,s);const a=!Cr(_,C,!1,n.ignoreAttributes)||cr(C)&&o,l=Yn(_)&&Yn(C)&&!br(_,C,n.ignoreAttributes);a||o?z.set(r,"modify"):(i||l)&&G.add(r);const c=_.nodeName.toLowerCase();Z[c]&&Z[c](r)}E.appendChild(r),M=r,E=r,O++,R++},nt=e=>{I.isNone()&&(I=k.from(e),z.set(e,"remove"));const n=u(_,t);n.length>0&&J(e)&&q.set(e,n),M.appendChild(e),M=e,O++},rt=t=>{F.isNone()&&(F=k.from(t),z.set(t,"insert"));const n=u(C,e);n.length>0&&J(t)&&q.set(t,n),E.appendChild(t),E=t,R++},ot=t=>{const e=b[1].length;x+=t,x===e?(b=h[g++],x=0):x>e&&Sr()},st=t=>{const e=Fr(_);S+=t,S===e?(({done:v,value:_}=p.next()),S=0):S>e&&Sr()},it=t=>{const e=Fr(C);D+=t,D===e?(({done:w,value:C}=m.next()),D=0):D>e&&Sr()};for(;b;){let t,e;switch(b[0]){case pr:v&&Sr(),Y(),t=Math.min(b[1].length-x,Fr(_)-S),e=b[1].substring(x,x+t),nt(tr(_)?Qn(e,r):f(_)?hr(_):fr(_)),ot(t),st(t);break;case 1:w&&Sr(),tt(),t=Math.min(b[1].length-x,Fr(C)-D),e=b[1].substring(x,x+t),rt(tr(C)?Qn(e,r):f(C)?hr(C):fr(C)),ot(t),it(t);break;default:(v||w)&&Sr(),Y(),tt(),t=Math.min(b[1].length-x,Fr(_)-S,Fr(C)-D),e=b[1].substring(x,x+t);const o=()=>M===E,s=()=>tr(_)&&tr(C),i=()=>jr(_.nodeName)===jr(C.nodeName),l=()=>!a(_)&&!a(C);if(f(_)&&f(C)){const t=hr(C);et(t),Q.add(t)}else o()&&(s()||i()&&l()||Cr(_,C,!1,n.ignoreAttributes)||mr(_,C))?et(tr(C)?Qn(e,r):fr(C)):(nt(tr(_)?Qn(e,r):fr(_)),rt(tr(C)?Qn(e,r):fr(C)));ot(t),st(t),it(t)}}z.forEach(((t,e)=>{var r,o;if(e.nodeType!==Node.COMMENT_NODE||n.trackComment(e)){if("remove"===t){const t=e;let n=ir(t).getOrNull();for(;y(n)&&Er(z,n,"insert");)null===(o=n.parentNode)||void 0===o||o.insertBefore(t,n),n=ir(t).getOrNull()}}else"remove"===t&&(null===(r=e.parentNode)||void 0===r||r.removeChild(e)),G.add(e),z.delete(e)})),H.forEach((t=>{var e,r,o;const{newTable:s,oldTable:i,outputTable:a}=t,l=t=>{return(e=t,1!==(n=e).nodeType&&9!==n.nodeType&&11!==n.nodeType||0===n.childElementCount?[]:V(e.querySelectorAll("td[colspan],th[colspan],td[rowspan],th[rowspan]"))).length>0;var e,n};if(!Or(i,!0)||!Or(s,!0)||!Or(a,!1)||(l(s)||l(i))&&(c=K,!B(Array.from(c.values()),(({oldRow:t,newRow:e})=>((t,e)=>{const n=lr(t),r=lr(e);for(let t=0;t<Math.min(n.length,r.length);t++){const e=n[t],o=r[t];if(Yn(e)&&Yn(o)){const t=Kn(e,"colspan")||"1",n=Kn(o,"colspan")||"1",r=Kn(e,"rowspan")||"1",s=Kn(o,"rowspan")||"1";if(t!==n||r!==s)return!1}}return!0})(t,e))))){new Tr(a).forEach((t=>{z.delete(t),q.delete(t)}));const t=hr(i),n=hr(s);return null===(e=a.parentNode)||void 0===e||e.insertBefore(t,a),null===(r=a.parentNode)||void 0===r||r.insertBefore(n,a),null===(o=a.parentNode)||void 0===o||o.removeChild(a),z.set(t,"remove"),void z.set(n,"insert")}var c;const d=()=>{const t={rowsChanges:[],colGroupChanges:[]},e=(t,e,r)=>{const o=Rr(e,t);return o.each((t=>{const{oldRow:e,newRow:o}=t,s=qr(e,o,n),i=lr(e),a=lr(o),l=i.length,c=a.length,d=Math.max(l,c),u=Math.min(l,c),f=s.rootOutputNode.firstElementChild,h=f?lr(f):[];if(h.length===d)T(h,(t=>{Er(s.combinedMap,t,"insert")?r.push(1):Er(s.combinedMap,t,"remove")?r.push(pr):r.push(0)}));else{let t=0,e=0;for(;t<u;)r[t++]=e;for(e=l<c?1:-1;t<d;)r[t++]=e}})),o.isSome()};new Tr(a,Br).some((n=>e(n,W,t.colGroupChanges)));const r=new Tr(a,Ur).toArray(),o=L(r,(t=>Rr(K,t).isSome())),s=U(o,(t=>{var e,n;return(null!==(n=null===(e=t.textContent)||void 0===e?void 0:e.replace(/\s+/g,""))&&void 0!==n?n:"").length>0})).orThunk((()=>k.from(o[0])));return s.fold((()=>t.rowsChanges.push(0)),(n=>e(n,K,t.rowsChanges))),t},u=t=>{const e=new Tr(t);for(e.next(),e.forEach((t=>{z.delete(t),q.delete(t)}));t.firstChild;)t.removeChild(t.firstChild)},f=(t,e,n,r)=>{if(!n||e.length>=n.length)return;const o=r?pr:1;for(let s=0;s<n.length;s++)if(n[s]===o){const n=Gn("td"),o=y(e[s])?e[s]:null;t.insertBefore(n,o),r&&z.set(n,"remove")}},h=(t,e,r,o)=>{let s=0,i=0;for(const a of o)if(1===a){if(i<r.length){const e=hr(r[i++]);t.appendChild(e),z.set(e,"insert")}}else if(a===pr){if(s<e.length){const n=hr(e[s++]);t.appendChild(n),z.set(n,"remove")}}else if(0===a&&s<e.length&&i<r.length){const o=qr(e[s++],r[i++],n);for(const[t,e]of o.combinedMap)z.set(t,e);for(const[t,e]of o.formattingMap)q.set(t,e);for(const t of o.ignoreSet)G.add(t);t.appendChild(o.rootOutputNode)}};(()=>{const t=t=>Er(z,t,"insert")?1:Er(z,t,"remove")?pr:0;if(l(s)||l(i)){const e=(t=>{const e=(t=>{const e=[];return new Tr(a,Ur).forEach((n=>{Rr(K,n).each((r=>{const{oldRow:o,newRow:s}=r,i=lr(o),a=lr(s),l=i.length,c=a.length,d=Math.max(l,c),u=Math.min(l,c),f=[],h=lr(n);if(h.length===d)for(let e=0;e<h.length;e++)f.push(t(h[e]));else{let t=0;for(;t<u;)f[t++]=0;const e=l<c?1:pr;for(;t<d;)f[t++]=e}e.push(f)}))})),e})(t);return 0===e.length&&Sr(),new Tr(a,Ur).forEach(((n,r)=>{const o=lr(n);or(n).each((s=>{var i;Er(z,n,"insert")||Er(z,s,"insert")?f(n,o,e[r],!0):Er(z,n,"remove")||Er(z,s,"remove")?f(n,o,e[r],!1):(i=e[r],B(o,((e,n)=>!y(i)||t(e)===i[n]))||(u(n),Rr(K,n).each((({newRow:t,oldRow:o})=>{const s=lr(t),i=lr(o);h(n,i,s,e[r])}))))}))})),e})(t);d().colGroupChanges.length>0&&(t=>{new Tr(a,Br).forEach((e=>{B(t[0],(t=>0===t))||(u(e),Rr(W,e).each((({newRow:n,oldRow:r})=>{const o=lr(n),s=lr(r),i=$(t,((t,e)=>e.length>t.length?e:t),[]);h(e,s,o,i)})))}))})(e)}else{const n=(t=>{const e=d();return 0===e.rowsChanges.length&&Sr(),new Tr(a,Ur).forEach((n=>{const r=lr(n);or(n).each((o=>{Er(z,n,"insert")||Er(z,o,"insert")?f(n,r,e.rowsChanges,!0):Er(z,n,"remove")||Er(z,o,"remove")?f(n,r,e.rowsChanges,!1):B(r,((n,r)=>t(n)===e.rowsChanges[r]))||(u(n),Rr(K,n).each((({newRow:t,oldRow:r})=>{const o=lr(t),s=lr(r);h(n,s,o,e.rowsChanges)})))}))})),e})(t);n.colGroupChanges.length>0&&(e=n.rowsChanges,new Tr(a,Br).forEach((t=>{B(e,(t=>0===t))||(u(t),Rr(W,t).each((({newRow:n,oldRow:r})=>{const o=lr(n),s=lr(r);h(t,s,o,e)})))})))}var e})()}));const at=t=>{G.add(t),T(lr(t),at)};return Q.forEach((t=>{G.add(t),T(lr(t),at)})),{ignoreSet:G,rootOutputNode:A,combinedMap:z,formattingMap:q}},Vr=(t,e,n,r)=>{const o=(({addedClass:t="vdd-added",modifiedClass:e="vdd-modified",removedClass:n="vdd-removed",skipModified:r=!1,skipChildren:o,skipSelf:s,diffText:i=kr,normaliseNbsp:a=!1,atomicSelectors:l,ignoreAttributes:c,trackComment:d}={})=>({addedClass:t,diffText:i,modifiedClass:e,removedClass:n,skipModified:r,skipChildren:t=>{var e;return!Yn(t)&&!nr(t)&&!er(t)&&!Zn(t)||(null!==(e=null==o?void 0:o(t))&&void 0!==e?e:Pr.has(t.nodeName.toLowerCase()))||!(!Yn(t)||!y(l))&&P(l,(e=>t.matches(e)))},skipSelf:t=>{var e;return!tr(t)&&!Yn(t)&&!Zn(t)||(null!==(e=null==s?void 0:s(t))&&void 0!==e?e:Ir.has(t.nodeName.toLowerCase())&&!cr(t))},normaliseNbsp:a,trackComment:t=>w(d)&&d(t),atomicSelectors:null!=l?l:[],ignoreAttributes:null!=c?c:{}}))({...r}),{rootOutputNode:s,combinedMap:i,formattingMap:a,ignoreSet:l}=qr(t.dom,e.dom,o),c=new Set,d=t=>{let e=t;for(;null!==e&&e!==s;)c.add(e),e=e.parentNode};for(const t of i.keys())d(t);for(const t of l)d(t);return{diffSet:c,status:i,timestamp:n,rootOutputNode:s,formattingMap:a,ignoreSet:l}},Hr=(t,e)=>{e(t),"children"in t&&T(t.children,(t=>Hr(t,e)))},Kr=(t,e,n,r)=>{switch(!0){case ce(t)&&pe(e):return s=e,i=n,{processNewNode:()=>{var t,e,n;const r=Vn(s,i,{opData:o.opData});if("modify"!==(null===(t=o.opData)||void 0===t?void 0:t.type))return r;const{format:a,oldFormat:l}=Sn(null!==(e=o.oldFormat)&&void 0!==e?e:[],null!==(n=r.format)&&void 0!==n?n:[]);return{...r,...a.length>0?{format:a}:{},...l.length>0?{oldFormat:l}:{},...o.oldAttrs?{oldAttrs:o.oldAttrs}:{}}},processOldNode:()=>o,newModify:()=>{var t,e;const n=Vn(s,i,{oldFormat:null!==(t=o.format)&&void 0!==t?t:[],oldAttrs:null!==(e=o.attrs)&&void 0!==e?e:{}}),{oldAttrs:r,oldFormat:a,...l}=n;return{...l,...un(n.oldAttrs,n.attrs)?{}:{oldAttrs:n.oldAttrs},...dn(n.oldFormat,n.format)?{}:{oldFormat:n.oldFormat}}},integrateModify:()=>{var t,e,n,r;const a=null!==(e=null!==(t=o.oldAttrs)&&void 0!==t?t:o.attrs)&&void 0!==e?e:{},l=null!==(r=null!==(n=o.oldFormat)&&void 0!==n?n:o.format)&&void 0!==r?r:[],c=o.opData,d=Vn(s,i,{oldAttrs:a,oldFormat:l,opData:c}),u=un(a,d.attrs),f=dn(l,d.format);if(u&&f){if("modify"===c.type){const{opData:t,oldAttrs:e,oldFormat:n,...r}=d;return r}{const{oldAttrs:t,oldFormat:e,...n}=d;return n}}const{oldAttrs:h,oldFormat:g,...p}=d;return{...p,...u?{}:{oldAttrs:d.oldAttrs},...f?{}:{oldFormat:d.oldFormat}}},removeModify:()=>{var t,e,n,r;return Vn(s,i,{attrs:null!==(e=null!==(t=o.oldAttrs)&&void 0!==t?t:o.attrs)&&void 0!==e?e:{},format:null!==(r=null!==(n=o.oldFormat)&&void 0!==n?n:o.format)&&void 0!==r?r:[]})},matchResult:(o=t).type===s.nodeName.toLowerCase()?"Equal":"Different"};case ce(t)&&fe(e):return((t,e,n,r)=>{const o=t.type===e.nodeName.toLowerCase()?"Equal":"Different",s=n=>{if(void 0===t.children&&0===e.childNodes.length)return{};const o=r.integrateChildren(t.children||[],e.childNodes,n);return o.length>0?{children:o}:{}};return{processNewNode:()=>{const{children:r,...o}=qn(e,n,{children:[],opData:t.opData}),i=o.opData;return{...o,...s(i)}},processOldNode:e=>{if(e){const{children:e,...n}=t;return{...n,...s(t.opData)}}return t},newModify:()=>{var r;return qn(e,n,{...s(t.opData),oldAttrs:null!==(r=t.attrs)&&void 0!==r?r:{}})},integrateModify:()=>{var r;const o=t.opData,i=null!==(r=t.oldAttrs)&&void 0!==r?r:{},a=qn(e,n,{...s(t.opData),oldAttrs:i,opData:o});if(un(i,a.attrs)){if("modify"===o.type){const{opData:t,oldAttrs:e,...n}=a;return n}{const{oldAttrs:t,...e}=a;return e}}return a},removeModify:()=>{var r;const{children:o,...i}=qn(e,n,{children:[],attrs:null!==(r=t.oldAttrs)&&void 0!==r?r:{}}),a=i.opData;return{...i,...s(a)}},matchResult:o}})(t,e,n,{integrateChildren:r});case ae(t)&&ue(e):return((t,e,n)=>{const r=e.nodeValue||"";an(`Text decision. Old "${t.text}", new "${r}"`);const o=(s=t.text)===(i=r)?"Equal":i.startsWith(s)?"ExistingOld":s.startsWith(i)?"NewOp":"Different";var s,i;return{processNewNode:()=>{var r,o,s;const i=zn(e,n,{opData:t.opData});if("modify"!==(null===(r=t.opData)||void 0===r?void 0:r.type))return i;const{format:a,oldFormat:l}=Sn(null!==(o=t.oldFormat)&&void 0!==o?o:[],null!==(s=i.format)&&void 0!==s?s:[]);return{...i,format:a,oldFormat:l}},processOldNode:()=>t,newModify:()=>{var r;return zn(e,n,{oldFormat:null!==(r=t.format)&&void 0!==r?r:[]})},integrateModify:()=>{var r;const o=t.opData,s=null!==(r=t.oldFormat)&&void 0!==r?r:[],i=zn(e,n,{oldFormat:s,opData:o});if(dn(s,i.format)){if("modify"===o.type){const{opData:t,oldFormat:e,...n}=i;return n}{const{oldFormat:t,...e}=i;return e}}return i},removeModify:()=>{var r;return zn(e,n,{format:null!==(r=t.oldFormat)&&void 0!==r?r:[]})},matchResult:"Equal"===o||"Different"===o?o:{type:"NewOp"===o?"Data":"Dom",splitDom:()=>{const r=e.splitText(t.text.length),o=n.status.get(e);o&&n.status.set(r,o);const s=n.formattingMap.get(e);s&&n.formattingMap.set(r,s)},splitData:()=>{const e={...t,text:t.text.slice(r.length)};return t={...t,text:r},e}}}})(t,e,n);default:return((t,e,n)=>{const r=()=>Hn(e,n);return{processNewNode:r,processOldNode:()=>t,newModify:r,integrateModify:r,removeModify:r,matchResult:("type"in t?t.type:"unknown")===he(e)?"Equal":"Different"}})(t,e,n)}var o,s,i},Wr=t=>{switch(t.matchResult){case"Different":case"Equal":return{integrate:!0};default:switch(t.matchResult.type){case"Dom":return t.matchResult.splitDom(),{integrate:!0};case"Data":return{integrate:!0,remainder:t.matchResult.splitData()}}}},Gr=(t,e,{diffSet:r,status:s,timestamp:i,rootOutputNode:a,formattingMap:l,ignoreSet:c})=>{const d=(t=>{let e=-1;const n=new Set([0]),r=new Map;let o=t+1;const s=o,i=t=>{if(!t.opData)return t;const s=t.opData.id,i=((t,s=!1)=>{const i=r.get(t);if(!m(i))return i;if(t!==e&&n.has(t)){if(s)return t;const e=++o;return r.set(t,e),e}return t})(s,!!ce(t)&&["td","th","col"].includes(t.type));return i!==s?{...t,opData:{...t.opData,id:i}}:t},a=t=>{let e=t;return ce(t)&&t.children&&(e={...t,children:I(t.children,a)}),i(e)},l=t=>{if(t.opData){const r=t.opData.id;n.has(r)||(e=r,n.add(e))}(t=>t.hasOwnProperty("children"))(t)&&T(t.children,l)};return{currentActionId:s,maybeUpdateId:i,deepMaybeUpdateId:a,trackMergeOperations:(t,r)=>{r&&s===t&&s!==r&&(n.delete(t),e=r,n.add(e))},trackReplaceOperation:(t,e)=>{if(t&&e&&n.has(t)){const e=++o;r.set(t,e)}},trackAppendOperation:t=>{e=t,n.add(e)},trackUnchangedArea:l,trackAppendContent:()=>{e=-1,r.clear()},maxId:()=>Math.max(...n),seen:()=>new Set(n),discardNode:t=>{r.set(s,t)},hasReplacements:()=>r.size>0}})(t.maxId),u={uid:e,nextOpId:d.currentActionId,status:s,timestamp:i,formattingMap:l},f=(t,e,i)=>{var a,l,h,g,p;let v=0,y=0;const w=[],b=t=>{var e,n;const r=w[w.length-1],o=r&&t&&((t,e)=>{if(ae(t)&&ae(e)){const n=t.opData,r=e.opData;if(yn(t,e)){an(`text merging after that action: '${t.text}' + '${e.text}'`);const o=n&&r&&r.id<n.id;o&&an(`adjusting target ID ${n.id} to match append ID ${r.id}`);const s=o?{opData:{...n,id:r.id}}:{};return{...t,...s,text:t.text+e.text}}}})(r,t);void 0!==o?(w[w.length-1]=o,d.trackMergeOperations(null===(e=r.opData)||void 0===e?void 0:e.id,null===(n=o.opData)||void 0===n?void 0:n.id)):(t.opData&&d.trackAppendOperation(t.opData.id),w.push(t))};for(;v<t.length||y<e.length;){const n=t[v],o=e[y],w=t=>{"insert"===(null==i?void 0:i.type)?bn(t,_n).each(b):"remove"===(null==i?void 0:i.type)?bn(t,Cn).each(b):(m(t.opData)&&an(`checking in diff set "${r.has(o)}" with DOM op status "${m(t.opData)}" and parent op status "${m(i)}": ${o?se(ee(o)):""}`),m(t.opData)&&!r.has(o)&&m(i)&&d.trackAppendContent(),b(d.maybeUpdateId(t)))},_=ct((()=>Hn(o,u)));an("++ integration loop",v,y,"++ data",n,o&&`++ dom "${null!==(a=null==o?void 0:o.nodeValue)&&void 0!==a?a:o.outerHTML}"`);const C=null===(l=null==n?void 0:n.opData)||void 0===l?void 0:l.type,x=s.get(o),S=(t,e)=>{const n=ae(t)?"text":t.type;return c.has(e)&&n!==he(e)};if("remove"===C&&"insert"===x&&xn(n,_())){const{opData:t,...e}=_();b(e),v++,y++}else if(m(o)&&m(C))v++;else if(m(o)||"remove"===C)w(d.deepMaybeUpdateId(n)),v++;else if(m(n)||S(n,o)||"insert"===x)w(_()),y++;else{const e=Kr(n,o,u,f),i=Wr(e),a="Different"===e.matchResult&&"insert"===(null===(h=n.opData)||void 0===h?void 0:h.type)&&"remove"===s.get(o);if(v++,i.integrate&&!a)if(y++,i.remainder&&(Ce(t)&&(t=Array.from(t)),an("splicing in remainder of old data",i.remainder),t.splice(v,0,i.remainder)),c.has(o))w(e.processNewNode());else if(m(C)&&"modify"===x)w(e.newModify());else if("modify"===x)w(e.integrateModify());else if("modify"===C&&"remove"===x){const t=e.removeModify();w(t),d.trackReplaceOperation(null===(g=n.opData)||void 0===g?void 0:g.id,null===(p=t.opData)||void 0===p?void 0:p.id)}else if(m(C)&&"remove"===x)w(e.processNewNode());else if("insert"===C&&"remove"===x)n.opData&&d.discardNode(n.opData.id);else{if(!m(C)&&!m(x))throw new Error(`unhandled ${C} x ${x}`);{const t=r.has(o)||d.hasReplacements();t||d.trackUnchangedArea(n),w(e.processOldNode(t))}}}}return o(n).eq(w,t)?t:w},h=f(t.contents,a.childNodes,void 0),g=d.seen();return{version:t.version,maxId:d.maxId(),contents:h,history:X(t.history,((t,e)=>g.has(parseInt(e,10))))}},Qr=["full","feedback","read","none"],Jr=(Xr=[((t,e)=>Jt(t,t,{tag:"required",process:{}},e))("version",Vt),Xt("history"),Xt("contents")],{extract:(t,e)=>((t,e,n)=>{const r={},o=[];for(const s of n)Kt(s,((n,s,i,a)=>{const l=Gt(i,t,e,n,a);$t(l,(t=>{o.push(...t)}),(t=>{r[s]=t}))}),((t,n)=>{r[t]=n(e)}));return o.length>0?Ft(o):Lt(r)})(t,e,Xr),toString:()=>{const t=I(Xr,(t=>Kt(t,((t,e,n,r)=>t+" -> "+r.toString()),((t,e)=>"state("+t+")"))));return"obj{\n"+t.join("\n")+"}"}});var Xr;const Zr=t=>Qt("model",Jr,t).fold((t=>({valid:!1,message:"Invalid value for suggestededits_model option."})),(t=>{return(t=>1===t.version)(t)?{valid:!0,value:(e=t,(t=>{let e=0;const n=t=>{"opData"in t&&(e=Math.max(e,t.opData.id))};return T(t.contents,(t=>Hr(t,n))),{history:{},...t,maxId:e}})(e))}:{valid:!1,message:`Model is valid, but only version 1 is supported. Model is version ${t.version}.`};var e})),Yr=t=>u(t)&&R(Qr,t),to=t=>t.getContent({indent:!1,entity_encoding:"named"}),eo=t=>e=>z(I(e,(e=>{const n=k.from(e.opData),r=(ce(e)?k.from(e.children):k.none()).map(eo(t));return[...n.map(t).getOr([]),...r.getOr([])]}))),no=({id:t})=>[t.toString()],ro=({uid:t})=>[t],oo=t=>{const e=Dn(t,An),n=(t=>{const e={type:"div",children:t.contents},n=jn(e);return ie(ne(n))})(e);return se(n)},so=(t,e,n)=>((t,e,n)=>((t,e,n,r)=>{const o=Vr(t,t,n,r);return{version:1,maxId:0,history:{},contents:Un(o.rootOutputNode,{uid:e,timestamp:n,nextOpId:1,status:new Map,formattingMap:o.formattingMap})}})(t,e,me(),n))(ie(oe(t)),e,n),io="read",ao="SuggestedEditsHasChangesUpdate",lo="Review edits",co="tinymce.plugins.suggestededits.integration",uo="suggestededits",fo="suggestededits",ho="suggestededits-access",go="suggestededits",po={Annotation:{Added:"tox-suggestededits__annotation--added",Removed:"tox-suggestededits__annotation--removed",Modified:"tox-suggestededits__annotation--modified"}},mo={addition:po.Annotation.Added,removal:po.Annotation.Removed,modification:po.Annotation.Modified},vo=t=>e=>e.options.get(t),yo=t=>e=>k.from(t(e)),wo=vo("suggestededits_content"),bo=yo(vo("suggestededits_model")),_o=vo("suggestededits_access"),Co=vo("suggestededits_auto_approve"),xo=vo("suggestededits_view_js_url"),So=vo("disabled"),Do=yo(vo("pagebreak_separator")),Ao=vo("pad_empty_with_br"),Mo=vo("content_css_cors"),ko=yo(vo("content_style")),No=t=>{const e=H((n=t.schema.getComponentUrls(),Z(n,x)));var n;return I(e,(t=>({url:t,attributes:tinymce.ScriptLoader.getScriptAttributes(t)})))},Oo=t=>So(t)?"none":_o(t),Eo=(t,e)=>{switch(t){case"full":return"full"===e;case"feedback":return"full"===e||"feedback"===e;case"read":return"full"===e||"feedback"===e||"read"===e;case"none":return!0;default:return!1}},Ro=t=>t.dispatch("SuggestedEditsReviewCancelled"),Po=t=>t.execCommand("suggestededits"),Io=(t,e,n)=>(t=>R(Qr,t))(e)&&Eo(e,Oo(t))&&n.hasChanges(),To=t=>{t.execCommand("ToggleView",!1,fo)},jo=t=>{To(t),Ro(t)},Lo=t=>{const e=()=>(t=>{const e={"data-mce-annotation-uid":{ignore:!0},"data-mce-annotation":{predicate:t=>"tinycomments"===t},class:{ignoreTokens:["tox-comment","mce-annotation"]}},n={...e,"data-mce-annotation-classes":{predicate:t=>"tox-comment"===t}},{getTextInlineElements:r,getVoidElements:o,pagebreakSeparator:s}=t,i=s.fold((()=>A),(t=>e=>(t=>8===t.nodeType)(e)&&`\x3c!--${e.data}--\x3e`===t));return{skipSelf:t=>{const e=r();if(m(e))return;const n=t,o=n.nodeName.toLowerCase();return(y(e[o])||"a"===o)&&n.hasChildNodes()},skipChildren:t=>{const e=o();if(m(e))return;const n=t.nodeName.toLowerCase();return"col"!==n&&(y(e[n])||"svg"===n||"iframe"===n||"object"===n)},normaliseNbsp:!1,atomicSelectors:["div.mce-toc"],ignoreAttributes:{h1:{id:{ignore:!0}},h2:{id:{ignore:!0}},h3:{id:{ignore:!0}},h4:{id:{ignore:!0}},h5:{id:{ignore:!0}},h6:{id:{ignore:!0}},div:{...n},figure:{...n},pre:{...n},span:{...e},details:{open:{ignore:!0}},a:{"aria-invalid":{ignore:!0}}},trackComment:i}})({pagebreakSeparator:Do(t),getTextInlineElements:()=>{var e;return null===(e=t.schema)||void 0===e?void 0:e.getTextInlineElements()},getVoidElements:()=>{var e;return null===(e=t.schema)||void 0===e?void 0:e.getVoidElements()}}),n=nt({}),r=(t=>{const e=nt({html:"",model:t});let n;return{get:e.get,set:t=>{var r;e.set(t),n=(r=t.model,H(eo(no)(r.contents))).length>0},hasChanges:()=>n}})(so("",t.userLookup.userId,e())),o=n.get,s=()=>{const n=r.get(),o=to(t),s=((t,e,n,r,o,s)=>{const i=((t,e,n,r,o,s=me())=>{const i=Vr(e,n,s,o);return 0===i.diffSet.size?t:((t,e,n)=>sn(t,(t=>Gr(t,e,n))))(t,r,i)})(t,ie(oe(e)),ie(oe(n)),r,o);return s?((t,e)=>Dn(t,(t=>{return n={opData:t,resolution:"accept"},t.uid===e?k.some(n):k.none();var n})))(i,r):i})(n.model,n.html,o,t.userLookup.userId,e(),Co(t));r.set({html:o,model:s})},i=()=>{const n=to(t),o=so(n,t.userLookup.userId,e());r.set({html:n,model:o})};return t.on("BeforeSetContent",(e=>{!0===e.load&&bo(t).each((n=>{const o=oo(n);"model"===wo(t)&&(e.content=o),r.set({html:o,model:n})}))})),t.on("SetContent",(e=>{const o=()=>{bo(t).fold(i,(e=>{r.set({html:to(t),model:e})}))};var a,l;!0===e.load?(o(),n.set(t.userLookup.fetchUsers([t.userLookup.userId,...(a=r.get().model,H([...eo(ro)(a.contents),...(l=a.history,z(Z(l,(t=>I(t,(({uid:t})=>t))))))]))]))):!0===e.initial?"raw"===e.format?o():i():!0!==e.selection&&s()}),!0),t.on("AddUndo",s,!0),t.on("Undo",s,!0),t.on("Redo",s,!0),{getModel:()=>(t.undoManager.typing&&s(),r.get().model),getUserCache:o,setModel:e=>{const n=oo(e);t.setContent(n);const o=to(t);t.off("AddUndo",s),t.undoManager.add(),t.on("AddUndo",s,!0),r.set({html:o,model:e})},updateFeedback:t=>{const e=r.get(),n={...e.model,history:t};r.set({...e,model:n})},resetModel:i,hasChanges:()=>r.hasChanges()||!t.mode.isReadOnly()&&t.undoManager.typing&&!Co(t)}},Fo=(t,e,n)=>{const r=(()=>{const t=(t=>{const e=nt(k.none()),n=()=>e.get().each(t);return{clear:()=>{n(),e.set(k.none())},isSet:()=>e.get().isSome(),get:()=>e.get(),set:t=>{n(),e.set(k.some(t))}}})(_);return{...t,on:e=>t.get().each(e)}})(),o=nt(_),s=()=>{o.get()()},i=(n,r)=>((t,e,n,r)=>{To(t);const o=X(n,(t=>"pending"!==t)),s=X(r,((t,e)=>m(o[e])));e.updateFeedback(s);const i=(a=e.getModel(),l=o,Dn(a,(t=>Y(l,t.id.toString()).map((e=>({opData:t,resolution:e}))))));var a,l;e.setModel(i),(t=>{t.dispatch("SuggestedEditsReviewComplete")})(t),t.focus()})(t,e,n,r),a=n=>((t,e,n)=>{To(t),e.updateFeedback(n),Ro(t),t.focus()})(t,e,n);var l,c;(l=co,c=xo(t),tinymce.Resource.load(l,c)).then(r.set).catch((t=>{console.error(`Failed to load the "${co}" resource:`,t)})),t.on("remove",s);const d={onHide:s,onShow:s=>r.get().fold((()=>{jo(t);const e=`The ${fo} UI is not loaded. Please ensure that the "${co}" resource is available.`;console.warn(e),t.notificationManager.open({text:e,type:"error",timeout:5e3})}),(r=>{const l=s.getContainer(),c=e.getModel(),d=t.userLookup.userId,u=e.getUserCache(),f=Oo(t),h=(t=>({encodedBaseURI:t.dom.encode(t.documentBaseURI.getURI()),shouldUseCors:Mo(t),absoluteContentCSSUrls:I(t.contentCSS,(e=>t.documentBaseURI.toAbsolute(e))),contentStyle:ko(t),componentScripts:No(t)}))(t),g=(t=>{const e=k.from(t.options.get("suggestededits_diff_classes")).getOr({});return Q(mo,((t,n)=>Y(e,n).getOr(t)))})(t),p=Do(t),m=Ao(t),v=r({root:l,universe:n,document:c,userId:d,userCache:u,accessLevel:f,headConfig:h,diffClasses:g,onComplete:i,onCancel:a,pagebreakSeparator:p,transparentSrc:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",padEmptyWithBr:m});o.set(v)}))};t.ui.registry.addView(fo,d)};((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,It(t,e))})("suggestededits",{setup:(t,e)=>{const n={translate:t=>tinymce.translate(t),getIcon:e=>{var n;return null!==(n=t.ui.registry.getAll().icons[e])&&void 0!==n?n:"temporary-placeholder"}};((t,e)=>{const n=t.options.register;n("suggestededits_content",{processor:"string",default:"html"}),n("suggestededits_model",{processor:Zr}),n("suggestededits_access",{processor:Yr,default:"full"}),n("suggestededits_view_js_url",{processor:"string",default:e+"/js/suggestededits-view.js"}),n("suggestededits_diff_classes",{processor:"object"}),n("suggestededits_auto_approve",{processor:"boolean",default:!1})})(t,e);const r=Lo(t);return(t=>{t.addCommand("suggestededits",(()=>{const e=Oo(t);Eo(io,e)&&(t.queryCommandValue("ToggleView")===fo?jo(t):(t=>{(t=>{t.dispatch("SuggestedEditsBeginReview")})(t),To(t)})(t))}))})(t),((t,e)=>{t.ui.registry.addContext(ho,(n=>{const r=Io(t,n,e);return((t,e)=>{t.dispatch(ao,{hasChanges:e})})(t,r),r}))})(t,r),((t,e)=>{t.ui.registry.addButton(uo,{icon:go,tooltip:lo,context:`${ho}:${io}`,onAction:()=>Po(t),onSetup:n=>{const r=t=>{n.setIcon(t?"suggestededits-badge":go)};r(Io(t,io,e));const o=({hasChanges:t})=>r(t);return t.on(ao,o),()=>t.off(ao,o)}}),t.ui.registry.addButton("suggestededits-label",{text:lo,context:`${ho}:${io}`,onAction:()=>Po(t)}),t.ui.registry.addMenuItem(uo,{icon:go,text:lo,context:`${ho}:${io}`,onAction:()=>Po(t)})})(t,r),Fo(t,r,n),(t=>({getModel:()=>{const{maxId:e,...n}=t.getModel();return n},setModel:e=>{const n=Zr(e);if(!n.valid)throw new Error(n.message);t.setModel(n.value)},resetModel:t.resetModel,hasChanges:t.hasChanges}))(r)},protection:{api:{protect:!1}}})}();