@contentful/field-editor-rich-text 2.0.0-next.26 → 2.0.0-next.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +410 -0
- package/dist/field-editor-rich-text.cjs.development.js +121 -87
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +125 -91
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/helpers/editor.d.ts +1 -3
- package/dist/plugins/Table/insertTableFragment.d.ts +3 -0
- package/dist/plugins/Table/onKeyDownTable.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),r=require("@contentful/field-editor-reference"),i=require("@contentful/field-editor-shared"),o=require("@contentful/rich-text-types"),a=require("@udecode/plate-core"),l=require("emotion"),s=e(require("fast-deep-equal")),c=e(require("lodash/noop")),u=require("@udecode/plate-serializer-docx"),d=require("@udecode/plate-break"),f=require("@udecode/plate-reset-node"),m=e(require("is-hotkey")),p=require("slate"),E=require("slate-react"),y=e(require("constate")),h=require("@contentful/f36-components"),v=e(require("@contentful/mimetype")),g=e(require("lodash/get")),L=require("@contentful/f36-icons"),T=e(require("@contentful/f36-tokens")),S=e(require("lodash/find")),N=e(require("lodash/flow")),b=require("@udecode/plate-list"),C=e(require("lodash/castArray")),I=require("@udecode/plate-basic-marks"),k=e(require("is-plain-obj")),A=require("@udecode/plate-paragraph"),O=require("@udecode/plate-select"),D=require("@udecode/plate-table"),B=require("@contentful/contentful-slatejs-adapter"),R=require("@contentful/rich-text-plain-text-renderer"),x=require("@udecode/plate-trailing-block"),w=e(require("lodash/debounce")),K=e(require("prop-types"));function _(e,t,n,r,i,o,a){try{var l=e[o](a),s=l.value}catch(e){return void n(e)}l.done?t(s):Promise.resolve(s).then(r,i)}function P(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){_(o,r,i,a,l,"next",e)}function l(e){_(o,r,i,a,l,"throw",e)}a(void 0)}))}}function H(){return(H=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function M(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,z(e,t)}function F(e){return(F=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function z(e,t){return(z=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function G(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function j(e,t,n){return(j=G()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&z(i,n.prototype),i}).apply(null,arguments)}function Y(e){var t="function"==typeof Map?new Map:void 0;return(Y=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return j(e,arguments,F(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),z(n,e)})(e)}function q(e,t){return t||(t=e.slice(0)),e.raw=t,e}function U(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function V(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return U(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?U(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function W(e){var t=e.field;return"rich-text-editor-"+e.entry.getSys().id+"-"+t.id+"-"+t.locale}var Q=t.createContext(""),X=Q.Provider;function $(e){var n=t.useContext(Q);if(e)return e;if(!n)throw new Error("could not find editor id. Please ensure the component is wrapped in <ContentfulEditorIdProvider> ");return n}function Z(e){var t=$(e);return a.usePlateEditorState(t)}var J="undefined"!=typeof navigator&&/Edge?\/(?:[0-6][0-9]|[0-7][0-8])/i.test(navigator.userAgent),ee=!("undefined"!=typeof navigator&&/Chrome?\/(?:[0-7][0-5]|[0-6][0-9])/i.test(navigator.userAgent))&&!J&&"undefined"!=typeof globalThis&&globalThis.InputEvent&&"function"==typeof globalThis.InputEvent.prototype.getTargetRanges,te="undefined"!=typeof navigator&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),ne=[o.INLINES.HYPERLINK,o.INLINES.ENTRY_HYPERLINK,o.INLINES.ASSET_HYPERLINK];function re(e,t){return!!Array.from(p.Editor.nodes(e,{match:function(e){return p.Element.isElement(e)&&e.type===t}}))[0]}function ie(e){return 1===e.length}function oe(e,t,n){var r,i;if(!(n=null!=(r=n)?r:null==(i=e.selection)?void 0:i.focus.path))return[];for(var o=Array.isArray(t)?t:[t],a=0;a<n.length;a++){var l=p.Editor.node(e,n.slice(0,a+1));if(o.includes(l[0].type))return l}return[]}function ae(e,t){return!!e&&!!oe(e,t)[0]}function le(e){p.Transforms.move(e,{distance:1,unit:"character"})}function se(e){p.Transforms.insertNodes(e,{type:o.BLOCKS.PARAGRAPH,children:[{text:""}],data:{},isVoid:!1})}function ce(e,t){e.selection&&function(e,t){var n=t.text,r=t.url,i=t.target,o=t.type,a=t.path;ue(e)&&!a&&de(e);var l=e.selection,s=l&&p.Range.isCollapsed(l),c={type:o,data:{},children:s?[{text:n}]:[]};r&&(c.data={uri:r}),i&&(c.data={target:i}),a?(p.Transforms.setNodes(e,c,{at:a}),p.Transforms.insertText(e,n,{at:a}),p.Transforms.select(e,a)):s?p.Transforms.insertNodes(e,c):(p.Transforms.wrapNodes(e,c,{split:!0}),p.Transforms.delete(e),p.Transforms.insertText(e,n),p.Transforms.collapse(e,{edge:"end"}))}(e,t)}function ue(e){return!!e&&!!Array.from(p.Editor.nodes(e,{match:function(e){return!p.Editor.isEditor(e)&&p.Element.isElement(e)&&ne.includes(e.type)}}))[0]}function de(e){p.Transforms.unwrapNodes(e,{match:function(e){return!p.Editor.isEditor(e)&&p.Element.isElement(e)&&ne.includes(e.type)}})}var fe=Object.values(o.INLINES),me=function(e){return p.Text.isText(e)||p.Element.isElement(e)&&fe.includes(e.type)},pe=function(e){var t=window.scrollX,n=window.scrollY;E.ReactEditor.focus(e),te&&setTimeout((function(){window.scrollTo(t,n)}),0)};function Ee(e,t,n){a.toggleNodeType(e,t,n),p.Transforms.setNodes(e,{data:{}})}function ye(e){return function(t){var r,i=(r=$(void 0),a.usePlateEditorRef(r)),o=n.useCallback((function(){return i.tracking.onViewportAction("linkRendered")}),[i]);return n.createElement(e,Object.assign({},t,{onEntityFetchComplete:o}))}}function he(e){var n=e.sdk;return t.useMemo((function(){return n}),[])}var ve=y(he),ge=ve[0],Le=ve[1],Te={scheduleIcon:l.css({marginRight:T.spacing2Xs})};function Se(e){var n=e.entity,i=e.entityType,o=r.useEntities();return t.createElement(r.ScheduledIconWithTooltip,{getEntityScheduledActions:o.loadEntityScheduledActions,entityType:i,entityId:n.sys.id},t.createElement(L.ClockIcon,{className:Te.scheduleIcon,size:"small",color:"muted",testId:"schedule-icon"}))}var Ne={assetCard:l.css({cursor:"pointer"}),cardDropdown:l.css({width:"300px"}),truncated:l.css({overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"})};function be(e){var n=e.entityFile,r=g(n,"fileName"),o=g(n,"contentType"),a=g(n,"details.size"),l=g(n,"details.image");return[t.createElement(h.Menu.SectionTitle,{key:"file-section"},"File info"),r&&t.createElement(h.Menu.Item,{key:"file-name"},t.createElement(h.Text,{isTruncated:!0},r)),o&&t.createElement(h.Menu.Item,{key:"file-type"},t.createElement(h.Text,{isTruncated:!0},o)),a&&t.createElement(h.Menu.Item,{key:"file-size"},i.shortenStorageUnit(a,"B")),l&&t.createElement(h.Menu.Item,{key:"file-dimentions"},l.width+" × "+l.height)].filter((function(e){return e}))}function Ce(e){var n=e.entityFile,r=e.isDisabled,i=e.onEdit,o=e.onRemove;return[t.createElement(h.Menu.SectionTitle,{key:"section-title"},"Actions"),i?t.createElement(h.Menu.Item,{key:"edit",disabled:r,onClick:i,testId:"card-action-edit"},"Edit"):null,n?t.createElement(h.Menu.Item,{key:"download",onClick:function(){var e,t;"string"==typeof n.url&&(e=n.url,t=g(n,"fileName"),fetch(e,{method:"GET",headers:{}}).then((function(e){e.arrayBuffer().then((function(e){var n=window.URL.createObjectURL(new Blob([e])),r=document.createElement("a");r.href=n,r.setAttribute("download",t),document.body.appendChild(r),r.click(),document.body.removeChild(r)}))})).catch((function(e){h.Notification.error("Failed to download asset"),console.log(e)})))},testId:"card-action-download"},"Download"):null,o?t.createElement(h.Menu.Item,{key:"remove",disabled:r,onClick:o,testId:"card-action-remove"},"Remove"):null].filter((function(e){return e}))}function Ie(e){var n,o=r.useEntities(),a=o.getOrLoadAsset,l=o.assets[e.assetId],s=e.sdk.locales.default,c=null!=l&&null!=(n=l.fields)&&n.file?l.fields.file[e.locale]||l.fields.file[s]:void 0,u=e.onEntityFetchComplete;if(t.useEffect((function(){a(e.assetId)}),[e.assetId]),t.useEffect((function(){l&&(null==u||u())}),[l,u]),void 0===l)return t.createElement(h.AssetCard,{size:"small",isLoading:!0});if("failed"===l)return t.createElement(r.MissingEntityCard,{entityType:"Asset",isDisabled:e.isDisabled,onRemove:e.onRemove});var d=l?i.entityHelpers.getEntryStatus(l.sys):void 0;if("deleted"===d)return t.createElement(r.MissingEntityCard,{entityType:"Asset",asSquare:!0,isDisabled:e.isDisabled,onRemove:e.onRemove});var f,m,p=i.entityHelpers.getAssetTitle({asset:l,localeCode:e.locale,defaultLocaleCode:s,defaultTitle:"Untitled"});return t.createElement(h.AssetCard,{title:p,isSelected:e.isSelected,size:"small",src:null!=c&&c.url?c.url+"?h=300":"",type:(f={image:"image",video:"video",audio:"audio",richtext:"richtext",presentation:"presentation",spreadsheet:"spreadsheet",pdfdocument:"pdf",archive:"archive",plaintext:"plaintext",code:"code",markup:"markup"},m=f.archive,c&&f[v.getGroupLabel({type:c.contentType,fallbackFileName:c.fileName})]||m),status:d,icon:t.createElement(Se,{entityType:"Asset",entity:l}),className:Ne.assetCard,actions:[Ce({entityFile:c,isDisabled:e.isDisabled,onEdit:e.onEdit,onRemove:e.onRemove}),c?be({entityFile:c}):null].filter((function(e){return e}))})}var ke={entryCard:l.css({cursor:"pointer"})};function Ae(e){var n=e.file;return i.isValidImage(n)?t.createElement(r.AssetThumbnail,{file:n}):null}function Oe(e){var n=r.useEntities(),o=n.getOrLoadEntry,a=n.entries,l=n.getOrLoadAsset,s=t.useState(null),c=s[0],u=s[1],d=a[e.entryId],f=t.useMemo((function(){if(d&&"failed"!==d)return e.sdk.space.getCachedContentTypes().find((function(e){return e.sys.id===d.sys.contentType.sys.id}))}),[e.sdk,d]),m=e.sdk.locales.default,p=e.onEntityFetchComplete;if(t.useEffect((function(){if(d&&"failed"!==d){var t=!0;return i.entityHelpers.getEntryImage({entry:d,contentType:f,localeCode:e.locale,defaultLocaleCode:m},l).catch((function(){return null})).then((function(e){t&&u(e)})),function(){t=!1}}}),[d,f,e.locale,m,e.sdk,c,l]),t.useEffect((function(){o(e.entryId)}),[e.entryId]),t.useEffect((function(){d&&(null==p||p())}),[d,p]),void 0===d)return t.createElement(h.EntryCard,{size:"default",isLoading:!0});if("failed"===d)return t.createElement(r.MissingEntityCard,{entityType:"Entry",isDisabled:e.isDisabled,onRemove:e.onRemove});var E=d?i.entityHelpers.getEntryStatus(d.sys):void 0;if("deleted"===E)return t.createElement(r.MissingEntityCard,{entityType:"Entry",isDisabled:e.isDisabled,onRemove:e.onRemove});var y=i.entityHelpers.getEntryTitle({entry:d,contentType:f,localeCode:e.locale,defaultLocaleCode:m,defaultTitle:"Untitled"}),v=i.entityHelpers.getEntityDescription({entity:d,contentType:f,localeCode:e.locale,defaultLocaleCode:m});return t.createElement(h.EntryCard,{contentType:null==f?void 0:f.name,title:y,description:v,size:"default",isSelected:e.isSelected,status:E,className:ke.entryCard,thumbnailElement:c?t.createElement(Ae,{file:c}):void 0,icon:t.createElement(Se,{entityType:"Entry",entity:d}),withDragHandle:!1,actions:function(){if(e.onEdit&&e.onRemove)return[e.onEdit?t.createElement(h.MenuItem,{key:"edit",disabled:e.isDisabled,testId:"card-action-edit",onClick:function(){e.onEdit&&e.onEdit()}},"Edit"):null,e.onRemove?t.createElement(h.MenuItem,{key:"delete",disabled:e.isDisabled,testId:"card-action-remove",onClick:function(){e.onRemove&&e.onRemove()}},"Remove"):null].filter((function(e){return e}))}()})}var De={root:l.css({marginBottom:"1.25rem !important",display:"block"}),container:l.css({display:"inline-block",verticalAlign:"text-top"})};function Be(e){var t=e.attributes,r=e.children,i=e.element,o=e.onEntityFetchComplete,a=E.useSelected(),l=Z(),s=Le(),c=E.useReadOnly(),u=i.data.target.sys,d=u.id,f=u.linkType,m=function(){return("Asset"===f?s.navigator.openAsset:s.navigator.openEntry)(d,{slideIn:!0})},y=function(){if(l){var e=E.ReactEditor.findPath(l,i);p.Transforms.removeNodes(l,{at:e})}};return n.createElement("div",Object.assign({},t,{className:De.root,"data-entity-type":f,"data-entity-id":d,contentEditable:!!ee&&void 0,draggable:!ee||void 0}),n.createElement("div",{contentEditable:!ee&&void 0,draggable:!!ee||void 0,className:De.container},"Entry"===f&&n.createElement(Oe,{sdk:s,entryId:d,locale:s.field.locale,isDisabled:c,isSelected:a,onRemove:y,onEdit:m,onEntityFetchComplete:o}),"Asset"===f&&n.createElement(Ie,{sdk:s,assetId:d,locale:s.field.locale,isDisabled:c,isSelected:a,onRemove:y,onEdit:m,onEntityFetchComplete:o})),r)}function Re(e,t){return e(t={exports:{}},t.exports),t.exports}var xe=Re((function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function s(e,t,n,r){var i=Object.create((t&&t.prototype instanceof d?t:d).prototype),o=new N(r||[]);return i._invoke=function(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var l=L(a,n);if(l){if(l===u)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var s=c(e,t,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===u)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}(e,n,o),i}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var u={};function d(){}function f(){}function m(){}var p={};l(p,i,(function(){return this}));var E=Object.getPrototypeOf,y=E&&E(E(b([])));y&&y!==t&&n.call(y,i)&&(p=y);var h=m.prototype=d.prototype=Object.create(p);function v(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){var r;this._invoke=function(i,o){function a(){return new t((function(r,a){!function r(i,o,a,l){var s=c(e[i],e,o);if("throw"!==s.type){var u=s.arg,d=u.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,a,l)}),(function(e){r("throw",e,a,l)})):t.resolve(d).then((function(e){u.value=e,a(u)}),(function(e){return r("throw",e,a,l)}))}l(s.arg)}(i,o,r,a)}))}return r=r?r.then(a,a):a()}}function L(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,L(e,t),"throw"===t.method))return u;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var r=c(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,u;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,u):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,u)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function b(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return f.prototype=m,l(h,"constructor",m),l(m,"constructor",f),f.displayName=l(m,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,a,"GeneratorFunction")),e.prototype=Object.create(h),e},e.awrap=function(e){return{__await:e}},v(g.prototype),l(g.prototype,o,(function(){return this})),e.AsyncIterator=g,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new g(s(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},v(h),l(h,a,"Generator"),l(h,i,(function(){return this})),l(h,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=b,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var l=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(l&&s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,u):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:b(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),u}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}));function we(e,t){return N((function(e){return S(e,"nodes")}),(function(e){return g(e,["nodes",t])}),(function(e){return S(e,"linkContentType")}),(function(e){return g(e,"linkContentType",[])}))(e.validations)}function Ke(e,t){return{entityType:_e(t),locale:e.locale||null,contentTypes:we(e,t)}}function _e(e){var t=e.split("-");if(-1!==t.indexOf("entry"))return"Entry";if(-1!==t.indexOf("asset"))return"Asset";throw new Error("RichText node type `"+e+"` has no associated `entityType`")}function Pe(e,t,n,r){return He.apply(this,arguments)}function He(){return(He=P(xe.mark((function e(t,n,r,i){var o,a,l,s,c,u;return xe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i("openCreateEmbedDialog",{nodeType:t}),o=n.dialogs,a=Ke(n.field,t),l="Asset"===a.entityType?o.selectSingleAsset:o.selectSingleEntry,s=H({},a,{withCreate:!0}),c=r.selection,e.next=8,l(s);case 8:if(u=e.sent){e.next=12;break}return i("cancelCreateEmbedDialog",{nodeType:t}),e.abrupt("return");case 12:p.Transforms.select(r,c),Fe(r,t,u),Me(r),i("insert",{nodeType:t});case 16:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Me(e){var t=p.Editor.next(e);if(!t)return se(e);var n=p.Editor.above(e,{voids:!1,match:function(e){return!p.Element.isElement(e)||![o.BLOCKS.EMBEDDED_ASSET,o.BLOCKS.EMBEDDED_ENTRY].includes(e.type)}});if(p.Editor.isEditor(n))le(e);else{var r=p.Editor.above(e,{at:t[1],match:function(e){return p.Element.isElement(e)&&o.TEXT_CONTAINERS.includes(e.type)}});if(!r||!n||!p.Path.isChild(r[1],n[1]))return se(e);le(e)}}function Fe(e,t,n){if(null!=e&&e.selection){var r=function(e,t){return{type:e,data:{target:{sys:{id:t.sys.id,type:"Link",linkType:t.sys.type}}},children:[{text:""}],isVoid:!0}}(t,n);e.selection&&a.getText(e,e.selection.focus.path)?p.Transforms.insertNodes(e,r):p.Transforms.setNodes(e,r),pe(e)}}var ze,Ge=l.css({marginRight:"10px"});function je(e){var t=e.isButton,r=e.isDisabled,i=e.nodeType,o=e.onClose,a=Z(),l=Le(),s=function(){var e=P(xe.mark((function e(t){return xe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),o(),e.next=4,Pe(i,l,a,a.tracking.onToolbarAction);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),c=function(e){var t=e.toLowerCase().split("-");if(t.includes("entry"))return"Entry";if(t.includes("asset"))return"Asset";throw new Error("Node type `"+e+"` has no associated `entityType`")}(i),u="rich-text__"+i;return t?n.createElement(h.Button,{isDisabled:r,className:u+"-button",size:"small",onClick:s,startIcon:n.createElement("Asset"===c?L.AssetIcon:L.EmbeddedEntryBlockIcon,null),variant:"secondary",testId:"toolbar-toggle-"+i},"Embed "+c.toLowerCase()):n.createElement(h.Menu.Item,{disabled:r,className:u+"-list-item",onClick:s,testId:"toolbar-toggle-"+i},n.createElement(h.Flex,{alignItems:"center",flexDirection:"row"},n.createElement(h.Icon,{as:"Asset"===c?L.AssetIcon:L.EmbeddedEntryBlockIcon,className:"rich-text__embedded-entry-list-icon "+Ge,variant:"secondary"}),n.createElement("span",null,c)))}var Ye=((ze={})[o.BLOCKS.EMBEDDED_ENTRY]="Entry",ze[o.BLOCKS.EMBEDDED_ASSET]="Asset",ze);function qe(e,t){return function(n,r){var i=r.options.hotkey;return function(r){var o=oe(n,e)[1];o?("Delete"===r.key||"Backspace"===r.key)&&(r.preventDefault(),p.Transforms.removeNodes(n,{at:o})):i&&m(i,r)&&Pe(e,t,n,n.tracking.onShortcutAction)}}}var Ue=function(e,t){return function(n){return{key:e,type:e,isElement:!0,isVoid:!0,component:ye(Be),options:{hotkey:t},handlers:{onKeyDown:qe(e,n)},deserializeHtml:{rules:[{validAttribute:{"data-entity-type":Ye[e]}}],withoutChildren:!0,getNode:function(t){return{type:e,children:[{text:""}],isVoid:!0,data:{target:{sys:{id:t.getAttribute("data-entity-id"),linkType:t.getAttribute("data-entity-type"),type:"Link"}}}}}}}}},Ve=Ue(o.BLOCKS.EMBEDDED_ENTRY,"mod+shift+e"),We=Ue(o.BLOCKS.EMBEDDED_ASSET,"mod+shift+a"),Qe=i.entityHelpers.getEntryTitle,Xe=i.entityHelpers.getEntryStatus,$e={scheduledIcon:l.css({verticalAlign:"text-bottom",marginRight:T.spacing2Xs})};function Ze(e){var t=r.useEntities(),i=t.getOrLoadEntry,a=t.loadEntityScheduledActions,l=t.entries,s=n.useMemo((function(){return l[e.entryId]}),[l,e.entryId]),c=e.sdk.space.getCachedContentTypes(),u=e.onEntityFetchComplete,d=n.useMemo((function(){if(s&&"failed"!==s&&c)return c.find((function(e){return e.sys.id===s.sys.contentType.sys.id}))}),[c,s]);n.useEffect((function(){s&&(null==u||u())}),[s,u]);var f=d?d.name:"",m=n.useMemo((function(){return Qe({entry:s,contentType:d,localeCode:e.sdk.field.locale,defaultLocaleCode:e.sdk.locales.default,defaultTitle:"Untitled"})}),[s,d,e.sdk.field.locale,e.sdk.locales.default]);if(n.useEffect((function(){e.entryId&&i(e.entryId)}),[e.entryId]),"failed"===s)return n.createElement(h.InlineEntryCard,{title:"Entry missing or inaccessible",testId:o.INLINES.EMBEDDED_ENTRY,isSelected:e.isSelected});if(void 0===s)return n.createElement(h.InlineEntryCard,{isLoading:!0});var p=Xe(s.sys);return"deleted"===p?n.createElement(h.InlineEntryCard,{title:"Entry missing or inaccessible",testId:o.INLINES.EMBEDDED_ENTRY,isSelected:e.isSelected,actions:[n.createElement(h.MenuItem,{key:"remove",onClick:e.onRemove,testId:"card-action-remove"},"Remove")]}):n.createElement(h.InlineEntryCard,{testId:o.INLINES.EMBEDDED_ENTRY,isSelected:e.isSelected,title:f+": "+m,status:p,actions:[n.createElement(h.MenuItem,{key:"edit",onClick:e.onEdit,disabled:e.isDisabled},"Edit"),n.createElement(h.MenuItem,{key:"remove",onClick:e.onRemove,disabled:e.isDisabled,testId:"card-action-remove"},"Remove")]},n.createElement(r.ScheduledIconWithTooltip,{getEntityScheduledActions:a,entityType:"Entry",entityId:s.sys.id},n.createElement(L.ClockIcon,{className:$e.scheduledIcon,variant:"muted",testId:"scheduled-icon"})),n.createElement(h.Text,null,m))}function Je(e){return{type:o.INLINES.EMBEDDED_ENTRY,children:[{text:""}],data:{target:{sys:{id:e,type:"Link",linkType:"Entry"}}}}}var et={icon:l.css({marginRight:"10px"}),root:l.css({display:"inline-block",margin:"0 "+T.spacing2Xs,fontSize:"inherit",span:{userSelect:"none"}})};function tt(e){var n=Z(),r=Le(),i=E.useSelected(),o=e.element.data.target.sys.id,a=E.useReadOnly();return t.createElement("span",Object.assign({},e.attributes,{className:et.root,"data-embedded-entity-inline-id":o,contentEditable:!!ee&&void 0,draggable:!ee||void 0}),t.createElement("span",{contentEditable:!ee&&void 0,draggable:!!ee||void 0},t.createElement(Ze,{sdk:r,entryId:o,isSelected:i,isDisabled:a,onRemove:function(){if(n){var t=E.ReactEditor.findPath(n,e.element);p.Transforms.removeNodes(n,{at:t})}},onEdit:function(){return r.navigator.openEntry(o,{slideIn:!0})},onEntityFetchComplete:e.onEntityFetchComplete})),e.children)}function nt(e,t,n){return rt.apply(this,arguments)}function rt(){return(rt=P(xe.mark((function e(t,n,r){var i,a,l,s;return xe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r("openCreateEmbedDialog",{nodeType:o.INLINES.EMBEDDED_ENTRY}),i=H({},Ke(n.field,o.INLINES.EMBEDDED_ENTRY),{withCreate:!0}),a=t.selection,e.next=5,n.dialogs.selectSingleEntry(i);case 5:if(l=e.sent,pe(t),l){e.next=10;break}return r("cancelCreateEmbedDialog",{nodeType:o.INLINES.EMBEDDED_ENTRY}),e.abrupt("return");case 10:return s=Je(l.sys.id),r("insert",{nodeType:o.INLINES.EMBEDDED_ENTRY}),e.abrupt("return",new Promise((function(e){setTimeout((function(){p.Transforms.setSelection(t,a),p.Transforms.insertNodes(t,s),e()}),0)})));case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function it(e){var n=Z(),r=Le();function i(e){return a.apply(this,arguments)}function a(){return(a=P(xe.mark((function t(i){return xe.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i.preventDefault(),n){t.next=3;break}return t.abrupt("return");case 3:return e.onClose(),t.next=6,nt(n,r,n.tracking.onToolbarAction);case 6:le(n);case 7:case"end":return t.stop()}}),t)})))).apply(this,arguments)}return e.isButton?t.createElement(h.Button,{isDisabled:e.isDisabled,className:o.INLINES.EMBEDDED_ENTRY+"-button",size:"small",onClick:i,startIcon:t.createElement(L.EmbeddedEntryInlineIcon,null),variant:"secondary",testId:"toolbar-toggle-"+o.INLINES.EMBEDDED_ENTRY},"Embed inline entry"):t.createElement(h.Menu.Item,{disabled:e.isDisabled,className:"rich-text__entry-link-block-button",testId:"toolbar-toggle-"+o.INLINES.EMBEDDED_ENTRY,onClick:i},t.createElement(h.Flex,{alignItems:"center",flexDirection:"row"},t.createElement(L.EmbeddedEntryInlineIcon,{variant:"secondary",className:"rich-text__embedded-entry-list-icon "+et.icon}),t.createElement("span",null,"Inline entry")))}function ot(e){return{key:o.INLINES.EMBEDDED_ENTRY,type:o.INLINES.EMBEDDED_ENTRY,isElement:!0,isInline:!0,isVoid:!0,component:ye(tt),options:{hotkey:"mod+shift+2"},handlers:{onKeyDown:at(e)},deserializeHtml:{rules:[{validAttribute:"data-embedded-entity-inline-id"}],withoutChildren:!0,getNode:function(e){return Je(e.getAttribute("data-embedded-entity-inline-id"))}}}}function at(e){return function(t,n){var r=n.options.hotkey;return function(n){t&&r&&m(r,n)&&nt(t,e,t.tracking.onShortcutAction)}}}var lt,st,ct,ut,dt,ft,mt,pt,Et,yt,ht=[o.BLOCKS.DOCUMENT,o.BLOCKS.PARAGRAPH,"text"],vt=function(e,t,n){var r=function(e,t){return N((function(e){return S(e,t)}),(function(e){return g(e,t)}))(e.validations)}(e,t);return void 0===r||ht.concat(r).includes(n)},gt=function(e,t){return vt(e,"enabledNodeTypes",t)},Lt=function(e,t){return vt(e,"enabledMarks",t)},Tt={dropdown:(Et={root:l.css(lt||(lt=q(["\n font-weight: ",";\n "])),T.fontWeightDemiBold)},Et[o.BLOCKS.PARAGRAPH]=l.css(st||(st=q(["\n font-size: ",";\n "])),T.fontSizeL),Et[o.BLOCKS.HEADING_1]=l.css(ct||(ct=q(["\n font-size: 1.625rem;\n "]))),Et[o.BLOCKS.HEADING_2]=l.css(ut||(ut=q(["\n font-size: 1.4375rem;\n "]))),Et[o.BLOCKS.HEADING_3]=l.css(dt||(dt=q(["\n font-size: 1.25rem;\n "]))),Et[o.BLOCKS.HEADING_4]=l.css(ft||(ft=q(["\n font-size: 1.125rem;\n "]))),Et[o.BLOCKS.HEADING_5]=l.css(mt||(mt=q(["\n font-size: 1rem;\n "]))),Et[o.BLOCKS.HEADING_6]=l.css(pt||(pt=q(["\n font-size: 0.875rem;\n "]))),Et)},St=((yt={})[o.BLOCKS.PARAGRAPH]="Normal text",yt[o.BLOCKS.HEADING_1]="Heading 1",yt[o.BLOCKS.HEADING_2]="Heading 2",yt[o.BLOCKS.HEADING_3]="Heading 3",yt[o.BLOCKS.HEADING_4]="Heading 4",yt[o.BLOCKS.HEADING_5]="Heading 5",yt[o.BLOCKS.HEADING_6]="Heading 6",yt);function Nt(e){var n=Le(),r=Z(),i=t.useState(!1),a=i[0],s=i[1],c=t.useState(o.BLOCKS.PARAGRAPH),u=c[0],d=c[1];t.useEffect((function(){if(null!=r&&r.selection){var e=function(e){return e.selection?Array.from(p.Editor.nodes(e,{at:e.selection,match:function(e){return p.Element.isElement(e)}})).flat():[]}(r)[0].type;d(St[e]?e:o.BLOCKS.PARAGRAPH)}}),[null==r?void 0:r.operations,null==r?void 0:r.selection]);var f=t.useMemo((function(){var e=Object.fromEntries(Object.keys(St).map((function(e){return[e,gt(n.field,e)]})));return[e,Object.values(e).filter(Boolean).length>0]}),[n.field]),m=f[0],E=f[1];return r?t.createElement(h.Menu,{isOpen:a,onClose:function(){return s(!1)}},t.createElement(h.Menu.Trigger,null,t.createElement(h.Button,{size:"small",testId:"toolbar-heading-toggle",variant:"transparent",endIcon:t.createElement(L.ChevronDownIcon,null),isDisabled:e.isDisabled,onClick:function(){return E&&s(!a)}},St[u])),t.createElement(h.Menu.List,{testId:"dropdown-heading-list"}," ",Object.keys(St).map((function(n){return m[n]&&t.createElement(h.Menu.Item,{key:n,isInitiallyFocused:u===n,onClick:(i=n,function(e){if(e.preventDefault(),null!=r&&r.selection){d(i),s(!1);var t=r.onChange;r.onChange=function(){pe(r),r.onChange=t,t.apply(void 0,arguments)};var n=re(r,i);r.tracking.onToolbarAction(n?"remove":"insert",{nodeType:i}),Ee(r,{activeType:i,inactiveType:i})}}),testId:"dropdown-option-"+n,disabled:e.isDisabled},t.createElement("span",{className:l.cx(Tt.dropdown.root,Tt.dropdown[n])},St[n]));var i})).filter(Boolean))):null}var bt,Ct,It,kt,At,Ot,Dt,Bt,Rt,xt,wt,Kt,_t,Pt,Ht,Mt,Ft,zt,Gt=function(e,t){p.Transforms.removeNodes(e,{at:t[1]})},jt=function(e,t){var n=t[1],r=function(e,t){return function(e,t,n){return Array.from(a.getNodes(e,{match:{type:o.TEXT_CONTAINERS},at:t,mode:"lowest"})).map((function(e){return e[0]}))}(e,t).map((function(e){return H({},e,{type:o.BLOCKS.PARAGRAPH})}))}(e,n);Gt(e,t),p.Transforms.insertNodes(e,r,{at:n})},Yt=function(e,t){p.Transforms.unwrapNodes(e,{at:t[1]})},qt=function(e){return function(t,n){p.Transforms.wrapNodes(t,{type:e,data:{},children:[]},{at:n[1]})}},Ut=function(e,t){p.Transforms.liftNodes(e,{at:t[1]})},Vt={dropdown:(Rt={root:l.css(bt||(bt=q(["\n font-weight: ",";\n "])),T.fontWeightDemiBold)},Rt[o.BLOCKS.PARAGRAPH]=l.css(Ct||(Ct=q(["\n font-size: ",";\n "])),T.fontSizeL),Rt[o.BLOCKS.HEADING_1]=l.css(It||(It=q(["\n font-size: 1.625rem;\n "]))),Rt[o.BLOCKS.HEADING_2]=l.css(kt||(kt=q(["\n font-size: 1.4375rem;\n "]))),Rt[o.BLOCKS.HEADING_3]=l.css(At||(At=q(["\n font-size: 1.25rem;\n "]))),Rt[o.BLOCKS.HEADING_4]=l.css(Ot||(Ot=q(["\n font-size: 1.125rem;\n "]))),Rt[o.BLOCKS.HEADING_5]=l.css(Dt||(Dt=q(["\n font-size: 1rem;\n "]))),Rt[o.BLOCKS.HEADING_6]=l.css(Bt||(Bt=q(["\n font-size: 0.875rem;\n "]))),Rt),headings:(Ft={root:l.css(xt||(xt=q(["\n font-weight: ",";\n line-height: 1.3;\n margin: 0 0 ",";\n "])),T.fontWeightMedium,T.spacingS)},Ft[o.BLOCKS.HEADING_1]=l.css(wt||(wt=q(["\n font-size: 1.875rem;\n "]))),Ft[o.BLOCKS.HEADING_2]=l.css(Kt||(Kt=q(["\n font-size: 1.5625rem;\n "]))),Ft[o.BLOCKS.HEADING_3]=l.css(_t||(_t=q(["\n font-size: 1.375rem;\n "]))),Ft[o.BLOCKS.HEADING_4]=l.css(Pt||(Pt=q(["\n font-size: 1.25rem;\n "]))),Ft[o.BLOCKS.HEADING_5]=l.css(Ht||(Ht=q(["\n font-size: 1.125rem;\n "]))),Ft[o.BLOCKS.HEADING_6]=l.css(Mt||(Mt=q(["\n font-size: 1rem;\n "]))),Ft)};function Wt(e,n){return function(r){return t.createElement(e,Object.assign({},r.attributes,{className:l.cx(Vt.headings.root,Vt.headings[n])}),r.children)}}var Qt,Xt,$t,Zt=((zt={})[o.BLOCKS.HEADING_1]=t.memo(Wt("h1",o.BLOCKS.HEADING_1)),zt[o.BLOCKS.HEADING_2]=t.memo(Wt("h2",o.BLOCKS.HEADING_2)),zt[o.BLOCKS.HEADING_3]=t.memo(Wt("h3",o.BLOCKS.HEADING_3)),zt[o.BLOCKS.HEADING_4]=t.memo(Wt("h4",o.BLOCKS.HEADING_4)),zt[o.BLOCKS.HEADING_5]=t.memo(Wt("h5",o.BLOCKS.HEADING_5)),zt[o.BLOCKS.HEADING_6]=t.memo(Wt("h6",o.BLOCKS.HEADING_6)),zt),Jt=function(){var e;return{key:"HeadingPlugin",softBreak:[{hotkey:"shift+enter",query:{allow:o.HEADINGS}}],normalizer:[{match:{type:o.HEADINGS},validChildren:function(e,t){return me(t[0])},transform:(e={},e[o.BLOCKS.PARAGRAPH]=Yt,e.default=Ut,e)}],then:function(e){return{exitBreak:[{hotkey:"enter",query:{allow:o.HEADINGS,end:!0,start:!0,filter:function(t){return!a.getAbove(e,{at:t[1],match:{type:o.BLOCKS.LIST_ITEM}})}}}]}},plugins:o.HEADINGS.map((function(e,t){var n,r=t+1;return{key:e,type:e,isElement:!0,component:Zt[e],options:{hotkey:["mod+alt+"+r]},handlers:{onKeyDown:(n=e,function(e,t){var r=t.options.hotkey;return function(t){if(e.selection&&r&&m(r,t)){var i=re(e,n);e.tracking.onShortcutAction(i?"remove":"insert",{nodeType:n}),Ee(e,{activeType:n,inactiveType:o.BLOCKS.PARAGRAPH})}}})},deserializeHtml:{rules:[{validNodeName:("h"+r).toUpperCase()}]}}}))}},en={button:l.css({height:"30px",width:"30px",marginLeft:T.spacing2Xs,marginRight:T.spacing2Xs}),tooltip:l.css({zIndex:Number(T.zIndexTooltip)})};function tn(e){var t=e.title,r=e.testId,i=e.isActive,o=e.children,a=e.isDisabled,s=void 0!==a&&a,c=n.createElement(h.Button,{className:l.cx(en.button,e.className),isDisabled:s,startIcon:o,onClick:function(t){t.preventDefault(),e.onClick()},testId:r,variant:i?"secondary":"transparent",size:"small"});return t?n.createElement(h.Tooltip,{className:en.tooltip,placement:"bottom",content:t},c):c}var nn={container:l.css(Qt||(Qt=q(["\n margin: 0 0 ",";\n "])),T.spacingL),hr:l.css(Xt||(Xt=q(["\n margin: 0;\n height: ",";\n background: transparent;\n position: relative;\n border: 0;\n user-select: none;\n &:hover {\n cursor: pointer;\n }\n &::after {\n content: '';\n position: absolute;\n width: 100%;\n height: 1px;\n background: ",";\n top: 50%;\n }\n "])),T.spacingM,T.gray300),hrSelected:l.css($t||($t=q(["\n &::after {\n background: ",";\n -webkit-box-shadow: 0px 0px 5px ",";\n box-shadow: 0px 0px 5px ",";\n }\n "])),T.colorPrimary,T.colorPrimary,T.colorPrimary)};function rn(e){return function(t){if(e){var n=oe(e,o.BLOCKS.HR)[1];n&&("Backspace"===t.key||"Delete"===t.key)&&(t.preventDefault(),p.Transforms.removeNodes(e,{at:n}))}}}function on(e){var n=Z();return n?t.createElement(tn,{title:"HR",isDisabled:e.isDisabled,onClick:function(){if(null!=n&&n.selection){var e={type:o.BLOCKS.HR,data:{},children:[{text:""}],isVoid:!0};a.getText(n,n.selection.focus.path)?p.Transforms.insertNodes(n,e):a.setNodes(n,e),function(e){p.Transforms.move(e,{distance:1,unit:"line"})}(n),pe(n)}},testId:"hr-toolbar-button",isActive:re(n,o.BLOCKS.HR)},t.createElement(L.HorizontalRuleIcon,null)):null}function an(e){var n=E.useSelected(),r=E.useFocused();return t.createElement("div",Object.assign({},e.attributes,{className:nn.container,"data-void-element":o.BLOCKS.HR}),t.createElement("div",{draggable:!0,contentEditable:!1},t.createElement("hr",{className:l.cx(nn.hr,n&&r?nn.hrSelected:void 0)})),e.children)}var ln,sn,cn,un={removeSelectionLabel:l.css(ln||(ln=q(["\n margin-left: ",";\n "])),T.spacingS)},dn=((sn={})[o.INLINES.ENTRY_HYPERLINK]="Entry",sn[o.INLINES.ASSET_HYPERLINK]="Asset",sn),fn=((cn={})[o.INLINES.HYPERLINK]="URL",cn[o.INLINES.ENTRY_HYPERLINK]="Entry",cn[o.INLINES.ASSET_HYPERLINK]="Asset",cn);function mn(e){var n,i,a,l,s=ne.filter((function(t){return gt(e.sdk.field,t)})),c=s[0],u=t.useState(null!=(n=e.linkText)?n:""),d=u[0],f=u[1],m=t.useState(null!=(i=e.linkType)?i:c),p=m[0],E=m[1],y=t.useState(null!=(a=e.linkTarget)?a:""),v=y[0],g=y[1],L=t.useState(null!=(l=e.linkEntity)?l:null),T=L[0],S=L[1];function N(e){var t=e.sys;return{sys:{id:t.id,type:"Link",linkType:t.type}}}function b(){return(b=P(xe.mark((function t(){var n,r;return xe.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={locale:e.sdk.field.locale,contentTypes:we(e.sdk.field,o.INLINES.ENTRY_HYPERLINK)},t.next=3,e.sdk.dialogs.selectSingleEntry(n);case 3:r=t.sent,g(""),S(N(r));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function C(){return(C=P(xe.mark((function t(){var n,r;return xe.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={locale:e.sdk.field.locale},t.next=3,e.sdk.dialogs.selectSingleAsset(n);case 3:r=t.sent,g(""),S(N(r));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}return t.createElement(r.EntityProvider,{sdk:e.sdk},t.createElement(t.Fragment,null,t.createElement(h.ModalContent,null,t.createElement(h.Form,null,!e.linkType&&t.createElement(h.FormControl,{id:"link-text",isRequired:!0},t.createElement(h.FormControl.Label,null,"Link text"),t.createElement(h.TextInput,{testId:"link-text-input",name:"link-text",value:d,onChange:function(e){return f(e.target.value)}})),s.length>1&&t.createElement(h.FormControl,{id:"link-type"},t.createElement(h.FormControl.Label,null,"Link type"),t.createElement(h.Select,{value:p,onChange:function(e){return E(e.target.value)},testId:"link-type-input"},s.map((function(e){return t.createElement(h.Select.Option,{key:e,value:e},fn[e])})))),p===o.INLINES.HYPERLINK&&t.createElement(h.FormControl,{id:"linkTarget",isRequired:!0},t.createElement(h.FormControl.Label,null,"Link target"),t.createElement(h.TextInput,{name:"linkTarget",value:v,onChange:function(e){S(null),g(e.target.value)},testId:"link-target-input"}),t.createElement(h.FormControl.HelpText,null,"A protocol may be required, e.g. https://")),p!==o.INLINES.HYPERLINK&&t.createElement("div",null,t.createElement(h.FormLabel,{isRequired:!0,htmlFor:""},"Link target"," "),T&&T.sys.linkType===dn[p]?t.createElement(t.Fragment,null,t.createElement(h.TextLink,{testId:"entity-selection-link",onClick:function(e){e.preventDefault(),S(null)},className:un.removeSelectionLabel},"Remove selection"),t.createElement("div",null,p===o.INLINES.ENTRY_HYPERLINK&&t.createElement(Oe,{sdk:e.sdk,locale:e.sdk.field.locale,entryId:T.sys.id,isDisabled:!0,isSelected:!1}),p===o.INLINES.ASSET_HYPERLINK&&t.createElement(Ie,{sdk:e.sdk,locale:e.sdk.field.locale,assetId:T.sys.id,isDisabled:!0,isSelected:!1}))):t.createElement("div",null,p===o.INLINES.ENTRY_HYPERLINK&&t.createElement(h.TextLink,{testId:"entity-selection-link",onClick:function(){return b.apply(this,arguments)}},"Select entry"),p===o.INLINES.ASSET_HYPERLINK&&t.createElement(h.TextLink,{testId:"entity-selection-link",onClick:function(){return C.apply(this,arguments)}},"Select asset"))))),t.createElement(h.ModalControls,null,t.createElement(h.Button,{type:"button",onClick:function(){return e.onClose(null)},variant:"secondary",testId:"cancel-cta",size:"small"},"Cancel"),t.createElement(h.Button,{type:"submit",variant:"positive",size:"small",isDisabled:!(p===o.INLINES.HYPERLINK?d&&v:Object.keys(dn).includes(p)&&d&&T),onClick:function(t){t.preventDefault(),e.onClose({linkText:d,linkType:p,linkTarget:v,linkEntity:T})},testId:"confirm-cta"},e.linkType?"Update":"Insert"))))}function pn(e,t,n,r){return En.apply(this,arguments)}function En(){return(En=P(xe.mark((function e(n,r,o,a){var l,s,c,u,d,f,m,E,y,h,v,g,L,T,S,N,b;return xe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=n.selection?H({},n.selection):void 0,a||s){e.next=3;break}return e.abrupt("return");case 3:return m=oe(n,ne,a),y=m[1],(E=m[0])&&y&&(c=E.type,u=p.Editor.string(n,y),d=E.data.uri||"",f=E.data.target),h=null!=a?a:s,v=u||(n.selection?p.Editor.string(n,n.selection):""),g=Boolean(E&&y),o(g?"openEditHyperlinkDialog":"openCreateHyperlinkDialog"),e.next=11,i.ModalDialogLauncher.openDialog({title:g?"Edit hyperlink":"Insert hyperlink",width:"large",shouldCloseOnEscapePress:!0,shouldCloseOnOverlayClick:!0,allowHeightOverflow:!0},(function(e){return t.createElement(mn,{linkTarget:d,linkText:v,linkType:c,linkEntity:f,onClose:e.onClose,sdk:r})}));case 11:if(L=e.sent,p.Transforms.select(n,h),L){e.next=17;break}return pe(n),o(g?"cancelEditHyperlinkDialog":"cancelCreateHyperlinkDialog"),e.abrupt("return");case 17:T=L.linkText,S=L.linkTarget,N=L.linkType,b=L.linkEntity,p.Editor.withoutNormalizing(n,(function(){ce(n,{text:T,url:S,type:N,target:b,path:y})})),o(g?"edit":"insert",{nodeType:N,linkType:null!=(l=null==b?void 0:b.sys.linkType)?l:"uri"}),pe(n);case 21:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function yn(e){var n=Z(),r=!(!n||!ue(n)),i=Le();function o(){return(o=P(xe.mark((function e(){return xe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}return e.abrupt("return");case 2:r?(de(n),n.tracking.onToolbarAction("unlinkHyperlinks")):pn(n,i,n.tracking.onToolbarAction);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return n?t.createElement(tn,{title:"Hyperlink",testId:"hyperlink-toolbar-button",onClick:function(){return o.apply(this,arguments)},isActive:r,isDisabled:e.isDisabled},t.createElement(L.LinkIcon,null)):null}var hn=function(e,t){var n=t[0];return!a.isAncestorEmpty(e,n)&&""!==p.Node.string(n).trim()};function vn(){return(vn=P(xe.mark((function e(t){var n,r,o,a,l,s,c,u,d,f,m,p,E;return xe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.sdk,r=t.entityId,a=t.localeCode,l=t.defaultLocaleCode,c="Entry"===(o=t.entityType)?n.space.getEntry:n.space.getAsset,e.next=4,c(r);case 4:return(u=e.sent).sys.contentType&&(d=u.sys.contentType.sys.id,s=n.space.getCachedContentTypes().find((function(e){return e.sys.id===d}))),f="Entry"===o?i.entityHelpers.getEntryTitle({entry:u,contentType:s,localeCode:a,defaultLocaleCode:l,defaultTitle:"Untitled"}):i.entityHelpers.getAssetTitle({asset:u,localeCode:a,defaultLocaleCode:l,defaultTitle:"Untitled"}),m=i.entityHelpers.getEntityDescription({entity:u,contentType:s,localeCode:a,defaultLocaleCode:l}),e.next=10,n.space.getEntityScheduledActions(o,r);case 10:return p=e.sent,E=i.entityHelpers.getEntryStatus(u.sys),e.abrupt("return",{jobs:p,entity:u,entityTitle:f,entityDescription:m,entityStatus:E,contentTypeName:s?s.name:""});case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var gn={hyperlinkWrapper:l.css({display:"inline",position:"static",a:{fontSize:"inherit !important"}}),hyperlink:l.css({fontSize:"inherit !important",display:"inline !important","&:hover":{fill:T.gray900},"&:focus":{fill:T.gray900}})};function Ln(e){var n=Z(),i=E.useReadOnly(),o=Le(),a=e.element.data.target,l=function(e){var n,i,o,a,l,s,c,u=(i=(n=e).sdk,o=n.target,a=n.onEntityFetchComplete,s=(l=t.useState({type:"loading"}))[0],c=l[1],t.useEffect((function(){var e,t;o&&function(e){return vn.apply(this,arguments)}({sdk:i,entityId:null==o||null==(e=o.sys)?void 0:e.id,entityType:null==o||null==(t=o.sys)?void 0:t.linkType,localeCode:i.field.locale,defaultLocaleCode:i.locales.default}).then((function(e){c({type:"success",data:e})})).catch((function(e){console.log(e),c({type:"error",error:e})})).finally((function(){null==a||a()}))}),[i,o,a]),s),d=e.target.sys.linkType;return"loading"===u.type?"Loading "+d.toLowerCase()+"...":"error"===u.type?d+" missing or inaccessible":function(e){if(!e)return"";var t,n=e.entityStatus,i=e.jobs;return(e.contentTypeName||"Asset")+' "'+(("string"==typeof(t=e.entityTitle)&&t.length>60?t&&t.substr(0,61).replace(/(\s+\S(?=\S)|\s*)\.?.$/,"…"):t)||"Untitled")+'", '+n+" "+(i.length>0?r.getScheduleTooltipContent({job:i[0],jobsCount:i.length}):"")}(u.data)}({target:a,sdk:o,onEntityFetchComplete:e.onEntityFetchComplete});return a?t.createElement(h.Tooltip,{content:l,targetWrapperClassName:gn.hyperlinkWrapper,placement:"bottom",maxWidth:"auto"},t.createElement(h.TextLink,{as:"a",onClick:function(e){if(e.preventDefault(),e.stopPropagation(),n){var t=E.ReactEditor.toSlatePoint(n,[e.target,0],{exactMatch:!1,suppressThrow:!1});pn(n,o,n.tracking.onViewportAction,t.path)}},isDisabled:i,className:gn.hyperlink,"data-link-type":a.sys.linkType,"data-link-id":a.sys.id},e.children)):null}function Tn(e){var n=Z(),r=E.useReadOnly(),i=Le(),o=e.element.data.uri;return t.createElement(h.Tooltip,{content:o,targetWrapperClassName:gn.hyperlinkWrapper,placement:"bottom",maxWidth:"auto"},t.createElement(h.TextLink,{as:"a",href:o,rel:"noopener noreferrer",onClick:function(e){if(e.preventDefault(),e.stopPropagation(),n){var t=E.ReactEditor.toSlatePoint(n,[e.target,0],{exactMatch:!1,suppressThrow:!1});pn(n,i,n.tracking.onViewportAction,t.path)}},isDisabled:r,className:gn.hyperlink},e.children))}var Sn,Nn,bn,Cn,In=function(e){return"A"===e.nodeName&&"Entry"===e.getAttribute("data-link-type")},kn=function(e){return"A"===e.nodeName&&"Asset"===e.getAttribute("data-link-type")},An=function(e){return function(t,n){var r=n.options.hotkey;return function(n){t.selection&&(r&&!m(r,n)||(ue(t)?(de(t),t.tracking.onShortcutAction("unlinkHyperlinks")):pn(t,e,t.tracking.onShortcutAction)))}}},On=function(e){return function(t,n){return{type:e,children:n.children,data:e===o.INLINES.HYPERLINK?{uri:t.getAttribute("href")}:{target:{sys:{id:t.getAttribute("data-link-id"),linkType:t.getAttribute("data-link-type"),type:"Link"}}}}}},Dn=function(e){var t={isElement:!0,isInline:!0};return{key:"HyperlinkPlugin",options:{hotkey:"mod+k"},handlers:{onKeyDown:An(e)},plugins:[H({},t,{key:o.INLINES.HYPERLINK,type:o.INLINES.HYPERLINK,component:Tn,deserializeHtml:{rules:[{validNodeName:["A"]}],query:function(e){return!("A"!==(t=e).nodeName||!t.getAttribute("href")||"#"===t.getAttribute("href")||In(e)||kn(e));var t},getNode:On(o.INLINES.HYPERLINK)}}),H({},t,{key:o.INLINES.ENTRY_HYPERLINK,type:o.INLINES.ENTRY_HYPERLINK,component:ye(Ln),deserializeHtml:{rules:[{validNodeName:["A"]}],query:function(e){return In(e)},getNode:On(o.INLINES.ENTRY_HYPERLINK)}}),H({},t,{key:o.INLINES.ASSET_HYPERLINK,type:o.INLINES.ASSET_HYPERLINK,component:ye(Ln),deserializeHtml:{rules:[{validNodeName:["A"]}],query:function(e){return kn(e)},getNode:On(o.INLINES.ASSET_HYPERLINK)}})],normalizer:[{match:{type:[o.INLINES.HYPERLINK,o.INLINES.ASSET_HYPERLINK,o.INLINES.ENTRY_HYPERLINK]},validNode:hn,transform:Gt}]}},Bn=l.css(Sn||(Sn=q(["\n padding: 0;\n margin: 0 0 1.25rem 1.25rem;\n\n div:first-child {\n margin: 0;\n line-height: ",";\n }\n"])),T.lineHeightDefault),Rn=((Cn={})[o.BLOCKS.UL_LIST]=l.css(Nn||(Nn=q(["\n list-style-type: disc;\n ul {\n list-style-type: circle;\n ul {\n list-style-type: square;\n }\n }\n "]))),Cn[o.BLOCKS.OL_LIST]=l.css(bn||(bn=q(["\n list-style-type: decimal;\n ol {\n list-style-type: upper-alpha;\n ol {\n list-style-type: lower-roman;\n ol {\n list-style-type: lower-alpha;\n }\n }\n }\n "]))),Cn);function xn(e,n){return function(r){return t.createElement(e,Object.assign({},r.attributes,{className:l.cx(Bn,Rn[n])}),r.children)}}var wn,Kn=xn("ul",o.BLOCKS.UL_LIST),_n=xn("ol",o.BLOCKS.OL_LIST),Pn=l.css(wn||(wn=q(["\n margin: 0;\n list-style: inherit;\n margin-top: ",";\n\n ol,\n ul {\n margin: 0 0 0 ",";\n }\n"])),T.spacingXs,T.spacingL);function Hn(e){return t.createElement("li",Object.assign({},e.attributes,{className:Pn}),e.children)}function Mn(e,t){return p.Editor.nodes(e,{at:t,match:function(e,t){return p.Element.isElement(e)&&e.type===o.BLOCKS.LIST_ITEM&&t.length>=2}}).next().done}var Fn=function(e,t){var n=(void 0===t?{}:t).at;p.Editor.withoutNormalizing(e,(function(){do{p.Transforms.liftNodes(e,{at:n,match:function(e){return p.Element.isElement(e)&&e.type===o.BLOCKS.LIST_ITEM},mode:"lowest"})}while(!Mn(e,n));a.unwrapNodes(e,{at:n,match:{type:o.BLOCKS.LIST_ITEM},split:!1})}))},zn=[o.BLOCKS.UL_LIST,o.BLOCKS.OL_LIST],Gn=function(e,t){var n=t.type;return p.Editor.withoutNormalizing(e,(function(){if(e.selection)if(a.isCollapsed(e.selection)||!a.isRangeAcrossBlocks(e)){var t=b.getListItemEntry(e);if(t)t.list[0].type!==n?a.setNodes(e,{type:n},{at:e.selection,match:function(e){return zn.includes(e.type)},mode:"lowest"}):Fn(e);else{a.wrapNodes(e,{type:n,children:[],data:{}});for(var r,i=[].concat(a.getNodes(e,{match:{type:a.getPluginType(e,a.ELEMENT_DEFAULT)}})),l={type:o.BLOCKS.LIST_ITEM,children:[],data:{}},s=V(i);!(r=s()).done;)a.wrapNodes(e,l,{at:r.value[1]})}}else{var c=p.Range.edges(e.selection),u=p.Node.common(e,c[0].path,c[1].path);if(zn.includes(u[0].type)||u[0].type===o.BLOCKS.LIST_ITEM){var d=u[0].type;if(u[0].type===o.BLOCKS.LIST_ITEM&&(d=p.Editor.parent(e,u[1])[0].type),d!==n){var f=a.findNode(e,{at:p.Range.start(e.selection),match:{type:zn},mode:"lowest"}),m=a.findNode(e,{at:p.Range.end(e.selection),match:{type:zn},mode:"lowest"});if(!f||!m)return;var E=Math.min(f[1].length,m[1].length);a.setNodes(e,{type:n},{at:e.selection,match:function(e,t){return zn.includes(e.type)&&t.length>=E},mode:"all"})}else Fn(e)}else{var y=u[1].length;Array.from(a.getNodes(e,{mode:"all"})).filter((function(e){return e[1].length===y+1})).reverse().forEach((function(t){zn.includes(t[0].type)?a.setNodes(e,{type:n},{at:t[1]}):(a.setNodes(e,{type:a.getPluginType(e,b.ELEMENT_LIC)},{at:t[1]}),a.wrapNodes(e,{type:o.BLOCKS.LIST_ITEM,children:[],data:{}},{at:t[1]}),a.wrapNodes(e,{type:n,children:[],data:{}},{at:t[1]}))}))}}}))},jn=function(e,t){var n=t.type,r=t.options.hotkey;return function(t){if("Tab"===t.key&&e.selection&&a.getAbove(e,{at:e.selection,match:{type:n}}))return t.preventDefault(),void function(e,t){var n,r=void 0===t?{}:t,i=r.increase,o=void 0===i||i,l=r.at,s=void 0===l?null!=(n=e.selection)?n:void 0:l,c=a.getNodes(e,{at:s,match:{type:a.getPluginType(e,b.ELEMENT_LIC)}}),u=Array.from(c);if(u.length){var d=[],f=[];u.forEach((function(t){var n=t[1],r=p.Path.parent(n);d.some((function(e){var t=p.Path.parent(e);return p.Path.isAncestor(t,r)}))||(d.push(n),f.push(p.Editor.pathRef(e,n)))}));var m=o?f:f.reverse();p.Editor.withoutNormalizing(e,(function(){m.forEach((function(t){var n=t.unref();if(n){var r=b.getListItemEntry(e,{at:n});r&&(o?function(e,t){var n,r=t.list[0],i=t.listItem[1];try{n=p.Path.previous(i)}catch(e){return}var o=p.Editor.node(e,n);if(o){var l=Array.from(p.Node.children(e,o[1])).find((function(t){return a.match(t[0],{type:b.getListTypes(e)})})),s=p.Path.next(a.getLastChildPath(null!=l?l:o));p.Editor.withoutNormalizing(e,(function(){l||a.wrapNodes(e,{type:r.type,children:[],data:{}},{at:i}),p.Transforms.moveNodes(e,{at:i,to:s})}))}}(e,r):b.isListNested(e,r.list[1])&&b.moveListItemUp(e,r))}}))}))}}(e,{increase:!t.shiftKey});if(r)for(var i,o=V(C(r));!(i=o()).done;)m(i.value)(t)&&Gn(e,{type:n})}},Yn=function(e){return[o.BLOCKS.OL_LIST,o.BLOCKS.UL_LIST].includes(e.type)},qn=function(e,t){var n=a.getParent(e,t[1])||[];return Yn(n[0])},Un=function(e,t){var n=t[1],r=function(e,t){return a.getAbove(e,{at:t,mode:"lowest",match:Yn})||[]}(e,n)[0];p.Transforms.wrapNodes(e,{type:(null==r?void 0:r.type)||o.BLOCKS.UL_LIST,children:[],data:{}},{at:n})},Vn=function(e,t){return 0!==Array.from(p.Node.children(e,t[1])).length},Wn=function(e,t){var n=t[0];if(1===n.children.length){var r=n.children[0];return!p.Text.isText(r)&&!Yn(r)}return!0},Qn=function(e,t){p.Transforms.insertNodes(e,[{type:o.BLOCKS.PARAGRAPH,data:{},children:[{text:""}]}],{at:t[1].concat([0])})},Xn=function(e,t){var n=t[0],r=t[1];p.Transforms.removeNodes(e,{at:r}),p.Transforms.insertNodes(e,n.children[0].children,{at:r})},$n=function(e,t){var n=e.selection;if(!n)return!1;if(p.Range.isExpanded(n)){var r=p.Range.edges(n);if(p.Node.common(e,r[0].path,r[1].path)[0].type===t)return!0}var i=a.getBlockAbove(e,{match:{type:[o.BLOCKS.OL_LIST,o.BLOCKS.UL_LIST]},mode:"lowest"});return(null==i?void 0:i[0].type)===t},Zn=function(e){return[o.BLOCKS.UL_LIST,o.BLOCKS.OL_LIST].includes(e.type)},Jn=o.LIST_ITEM_BLOCKS,er=function(e){var t=e.deleteBackward,n=e.deleteForward,r=e.deleteFragment;return e.deleteBackward=function(n){(function(e,t){var n=b.getListItemEntry(e,{}),r=!1;if(n){var i=n.list,l=n.listItem;a.isSelectionAtBlockStart(e,{match:function(e){return e.type===o.BLOCKS.LIST_ITEM}})&&p.Editor.withoutNormalizing(e,(function(){if(!(r=b.removeFirstListItem(e,{list:i,listItem:l}))&&!(r=b.removeListItem(e,{list:i,listItem:l}))){if(a.isFirstChild(l[1])&&!b.isListNested(e,i[1]))return f.onKeyDownResetNode(e,a.mockPlugin({options:{rules:[{types:[o.BLOCKS.LIST_ITEM],defaultType:o.BLOCKS.PARAGRAPH,hotkey:"backspace",predicate:function(){return a.isSelectionAtBlockStart(e)},onReset:function(e){return Fn(e)}}]}}))(f.SIMULATE_BACKSPACE),void(r=!0);a.deleteFragment(e,{unit:t,reverse:!0}),r=!0}}))}return r})(e,n)||t(n)},e.deleteForward=function(t){b.deleteForwardList(e)||n(t)},e.deleteFragment=function(){b.deleteFragmentList(e)||r()},e.insertBreak=function(e){var t=e.insertBreak;return function(){(function(e){if(!e.selection)return!1;var t,n=b.getListItemEntry(e,{});if(n){var r=n.list,i=n.listItem,l=i[0].children[0];if(a.isBlockAboveEmpty(e)&&1===i[0].children.length&&o.TEXT_CONTAINERS.includes(l.type)&&(t=b.moveListItemUp(e,{list:r,listItem:i})))return!0}return!!f.onKeyDownResetNode(e,a.mockPlugin({options:{rules:[{types:[a.getPluginType(e,b.ELEMENT_LI)],defaultType:a.getPluginType(e,a.ELEMENT_DEFAULT),predicate:function(){return!t&&a.isBlockAboveEmpty(e)},onReset:function(e){return b.unwrapList(e)}}]}}))(f.SIMULATE_BACKSPACE)||!(t||!function(e){if(!e.selection)return!1;var t=a.getAbove(e,{match:{type:o.TEXT_CONTAINERS}});if(!t)return!1;var n=t[1],r=a.getParent(e,n);if(!r)return!1;var i=r[1];return r[0].type===o.BLOCKS.LIST_ITEM&&(p.Editor.withoutNormalizing(e,(function(){if(e.selection){var t=a.isSelectionAtBlockStart(e),r=a.isSelectionAtBlockEnd(e),l=t&&a.isFirstChild(n),s=!t&&!r;s&&p.Transforms.splitNodes(e);var c=l?i:p.Path.next(i);a.insertNodes(e,function(e,t){void 0===t&&(t=!1);var n=[];if(t){var r=p.Editor.marks(e)||{};n=[{type:o.BLOCKS.PARAGRAPH,data:{},children:[H({text:""},r)]}]}return{type:o.BLOCKS.LIST_ITEM,data:{},children:n}}(e,!s),{at:c});var u=t?n:p.Path.next(n),d=u[u.length-1]||0,f=c.concat([s?0:1]);l||a.moveChildren(e,{at:i,to:f,fromStartIndex:d}),p.Transforms.select(e,c),p.Transforms.collapse(e,{edge:"start"})}})),!0)}(e))})(e)||t()}}(e),e.insertFragment=function(e){var t=e.insertFragment;return function(n){if(e.selection){if(a.findNode(e,{match:{type:o.BLOCKS.LIST_ITEM},mode:"lowest"})){var r=function(e){var t=e[0];return o.TEXT_CONTAINERS.includes(t.type)?[].concat(t.children,e.slice(1)):e}(function(e){if(1!==e.length)return e;var t=e[0];return t.type!==o.BLOCKS.LIST_ITEM||1!==t.children.length?e:t.children}(n.flatMap((function(e){return function(e){if(!Zn(e))return[e];var t=Array.from(p.Node.texts(e)),n=t.reduce((function(t,n){return p.Path.isAncestor(t[1],n[1])?t:p.Node.common(e,n[1],t[1])}),function(e,t){for(var n=p.Path.parent(t[1]);p.Node.get(e,n).type!==o.BLOCKS.LIST_ITEM;)n=p.Path.parent(n);return[p.Node.get(e,n),n]}(e,t[0]));return Zn(n[0])?n[0].children:[n[0]]}(e)})))),i=r.findIndex((function(t){return p.Editor.isBlock(e,t)}));i<0&&(i=r.length);var l=r.slice(0,i),s=r.slice(i);return p.Transforms.insertNodes(e,l,{at:e.selection,select:!0}),p.Transforms.insertNodes(e,s,{at:e.selection,select:!0})}var c=Zn(n[0])?[{text:""}].concat(n):n;return t(c)}}}(e),e.normalizeNode=b.normalizeList(e,{validLiChildrenTypes:Jn}),e};function tr(e){var n=Le(),r=Z();function i(e){return function(){null!=r&&r.selection&&(Gn(r,{type:e}),pe(r))}}return r?t.createElement(t.Fragment,null,gt(n.field,o.BLOCKS.UL_LIST)&&t.createElement(tn,{title:"UL",testId:"ul-toolbar-button",onClick:i(o.BLOCKS.UL_LIST),isActive:$n(r,o.BLOCKS.UL_LIST),isDisabled:e.isDisabled},t.createElement(L.ListBulletedIcon,null)),gt(n.field,o.BLOCKS.OL_LIST)&&t.createElement(tn,{title:"OL",testId:"ol-toolbar-button",onClick:i(o.BLOCKS.OL_LIST),isActive:$n(r,o.BLOCKS.OL_LIST),isDisabled:e.isDisabled},t.createElement(L.ListNumberedIcon,null))):null}var nr=function(e){var n=e.mark,r=e.title,i=e.icon,o=function(e){var o=e.isDisabled,l=Z(),s=t.useCallback((function(){if(null!=l&&l.selection){var e=a.isMarkActive(l,n);l.tracking.onToolbarAction(e?"unmark":"mark",{markType:n}),a.toggleMark(l,{key:n}),pe(l)}}),[l]);return l?t.createElement(tn,{title:r,testId:n+"-toolbar-button",onClick:s,isActive:a.isMarkActive(l,n),isDisabled:o},i):null};return o.displayName=n,o},rr=function(e){return function(t,n){var r=n.options.hotkey;return function(n){if(t.selection&&r&&m(r,n)){n.preventDefault();var i=a.isMarkActive(t,e);t.tracking.onShortcutAction(i?"unmark":"mark",{markType:e}),a.toggleMark(t,{key:e})}}}},ir=nr({title:"Bold",mark:o.MARKS.BOLD,icon:t.createElement(L.FormatBoldIcon,null)}),or={bold:l.css({fontWeight:600})};function ar(e){return t.createElement("strong",Object.assign({},e.attributes,{className:or.bold}),e.children)}var lr=nr({title:"Code",mark:o.MARKS.CODE,icon:t.createElement(L.CodeIcon,null)}),sr={code:l.css({fontFamily:"monospace",fontSize:".9em"})};function cr(e){return t.createElement("code",Object.assign({},e.attributes,{className:sr.code}),e.children)}var ur=nr({title:"Italic",mark:o.MARKS.ITALIC,icon:t.createElement(L.FormatItalicIcon,null)}),dr={italic:l.css({fontStyle:"italic"})};function fr(e){return t.createElement("em",Object.assign({},e.attributes,{className:dr.italic}),e.children)}var mr=nr({title:"Underline",mark:o.MARKS.UNDERLINE,icon:t.createElement(L.FormatUnderlinedIcon,null)});function pr(e){return t.createElement("u",Object.assign({},e.attributes),e.children)}var Er,yr,hr=function(e){return o.TEXT_CONTAINERS.includes(e.type)},vr=[{match:p.Text.isText,validNode:function(e,t){var n,r=null==(n=a.getParent(e,t[1]))?void 0:n[0];return!!r&&(hr(r)||fe.includes(r.type)||e.isVoid(r))},transform:function(e,t){return qt(o.BLOCKS.PARAGRAPH)(e,t)}},{match:{type:fe},validNode:function(e,t){var n,r=null==(n=a.getParent(e,t[1]))?void 0:n[0];return!!r&&hr(r)},transform:qt(o.BLOCKS.PARAGRAPH)}],gr=function(e){function t(){return e.apply(this,arguments)||this}return M(t,e),t}(Y(Error)),Lr=function(e){return function(t,n){var r=n[0];return p.Element.isElement(r)&&e.includes(r.type)}},Tr=function(e){var t=e.default;if(!t)throw new gr("A default transformer MUST be provided");return function(n,r){var i=r[0],o=p.Element.isElement(i)?i.type:"default";return(e[o]||t)(n,r)}},Sr=function(e){for(var t,n=vr,r=V(e.plugins);!(t=r()).done;){var i=t.value,o=i.normalizer;if(o)for(var l,s=V(o);!(l=s()).done;){var c=H({},l.value);if(!c.match&&!i.isElement)throw new gr("rule.match MUST be defined in a non-element plugin");if(c.match||(c.match={type:a.getPluginType(e,i.key)}),k(c.transform)){if("validNode"in c)throw new gr("conditional transformations are not supported in validNode rules");c.transform=Tr(H({default:Gt},c.transform))}c.transform||(c.transform=Gt),"validChildren"in c&&Array.isArray(c.validChildren)&&(c.validChildren=Lr(c.validChildren)),n.push(c)}}var u=function(t,n){p.Editor.withoutNormalizing(e,(function(){t(e,n)}))},d=e.normalizeNode;return e.normalizeNode=function(t){for(var r,i=t[0],o=function(e,t){var n=t[1];return p.Text.isText(t[0])?[]:Array.from(p.Node.children(e,n))}(e,t),l=V(n);!(r=l()).done;){var s=r.value;if(a.match(i,s.match)){if("validNode"in s&&!s.validNode(e,t))return void u(s.transform,t);if("validChildren"in s){var c=function(){var t=s.validChildren,n=o.find((function(n){return!t(e,n)}));if(n)return u(s.transform,n),{v:void 0}}();if("object"==typeof c)return c.v}}}return d(t)},e},Nr=((yr={})[o.BLOCKS.PARAGRAPH]=l.css(Er||(Er=q(["\n line-height: ",";\n margin-bottom: 1.5em;\n "])),T.lineHeightDefault),yr);function br(e){return t.createElement("div",Object.assign({},e.attributes,{className:Nr[o.BLOCKS.PARAGRAPH]}),e.children)}var Cr=function(e,t){var n=t.options.hotkey;return function(t){e.selection&&n&&m(n,t)&&Ee(e,{activeType:o.BLOCKS.PARAGRAPH,inactiveType:o.BLOCKS.PARAGRAPH})}},Ir=[function(e){return e.querySelectorAll("style").forEach((function(e){e.remove()})),e},function(e){if(!["google-sheets-html-origin",'meta[content="Excel.Sheet"]','meta[content*="Microsoft Excel"]'].some((function(t){return!!e.querySelector(t)})))return e;for(var t=function(e){var t;return""===(null!=(t=e.textContent)?t:"").trim()},n=Array.from(e.querySelectorAll("table")),r=function(){var e=o[i];e.querySelectorAll("tr").forEach((function(e){t(e)&&e.remove()}));for(var n=Array.from(e.querySelectorAll("tr")),r=1;;){var a=n.map((function(e){return e.querySelector("th:nth-of-type("+r+"), td:nth-of-type("+r+")")})).filter((function(e){return!!e}));if(0===a.length)break;a.every((function(e){return t(e)}))?a.forEach((function(e){return e.remove()})):r+=1}},i=0,o=n;i<o.length;i++)r();return e}],kr=function(e){return Ir.reduce((function(e,t){return t(e)}),(new DOMParser).parseFromString(e,"text/html")).body.innerHTML.replace(/>\s+</g,"><").replace(/(.*)<div.*>(<table.*<\/table>)<\/div>(.*)/g,"$1$2$3")},Ar=/data-slate-fragment="(.+?)"/m,Or=l.css({margin:"0 0 1.3125rem",borderLeft:"6px solid "+T.gray200,paddingLeft:"0.875rem",fontStyle:"normal"});function Dr(e){return t.createElement("blockquote",Object.assign({},e.attributes,{className:Or}),e.children)}var Br=function(e){var t=a.getAbove(e,{match:{type:o.TEXT_CONTAINERS},mode:"lowest"});if(!t)return!1;if(!a.isAncestorEmpty(e,t[0]))return!1;var n=a.getBlockAbove(e,{match:{type:o.BLOCKS.QUOTE},mode:"lowest"});return!!n&&!(!a.hasSingleChild(n[0])||!a.isLastChild(n,t[1]))};function Rr(e,t){if(e.selection){var n=re(e,o.BLOCKS.QUOTE);null==t||t(n?"remove":"insert",{nodeType:o.BLOCKS.QUOTE}),p.Editor.withoutNormalizing(e,(function(){e.selection&&(p.Transforms.unwrapNodes(e,{match:function(e){return p.Element.isElement(e)&&e.type===o.BLOCKS.QUOTE},split:!0}),n||p.Transforms.wrapNodes(e,{type:o.BLOCKS.QUOTE,data:{},children:[]}))}))}}var xr=function(e,t){return function(n){var r=t.options.hotkey;r&&m(r,n)&&(n.preventDefault(),Rr(e,e.tracking.onShortcutAction))}},wr=function(e){var t=e.insertFragment;return e.insertFragment=function(n){var r=n.length&&n[0],i=p.Element.isElement(r)&&r.type===o.BLOCKS.QUOTE,l=a.getAbove(e,{match:{type:o.TEXT_CONTAINERS}}),s=l&&""!==p.Node.string(l[0]);if(i&&s){var c=e.selection;(function(e){return!!e&&0!==p.Point.compare(e.anchor,e.focus)})(c)&&p.Transforms.delete(e,{at:c});var u=a.getAbove(e,{match:{type:o.TEXT_CONTAINERS}});if(u&&""!==p.Node.string(u[0]))return void p.Transforms.insertNodes(e,n)}t(n)},e};function Kr(){var e;return{key:o.BLOCKS.QUOTE,type:o.BLOCKS.QUOTE,isElement:!0,component:Dr,options:{hotkey:"mod+shift+1"},handlers:{onKeyDown:xr},deserializeHtml:{rules:[{validNodeName:"BLOCKQUOTE"}]},resetNode:[{hotkey:"backspace",types:[o.BLOCKS.QUOTE],predicate:Br,onReset:Rr}],normalizer:[{validChildren:o.CONTAINERS[o.BLOCKS.QUOTE],transform:(e={},e[o.BLOCKS.QUOTE]=Yt,e.default=Ut,e)}],withOverrides:wr}}function _r(e){var n=Z();return n?t.createElement(tn,{title:"Blockquote",onClick:function(){n&&(Rr(n,n.tracking.onToolbarAction),pe(n))},testId:"quote-toolbar-button",isDisabled:e.isDisabled,isActive:re(n,o.BLOCKS.QUOTE)},t.createElement(L.QuoteIcon,null)):null}function Pr(e){return e.some((function(e){return e.type===o.BLOCKS.TABLE}))}var Hr=function(e){return e.type===o.BLOCKS.TABLE_HEADER_CELL},Mr=function(e,t){if(a.someNode(e,{match:{type:a.getPluginType(e,D.ELEMENT_TABLE)}})){var n=a.getAbove(e,{match:{type:a.getPluginType(e,D.ELEMENT_TR)}});if(n){var r=n[0],i=t(n[1]);a.insertNodes(e,D.getEmptyRowNode(e,{header:!1,colCount:r.children.length}),{at:i,select:!0}),p.Transforms.select(e,p.Editor.start(e,i))}}},Fr=function(e){Mr(e,(function(e){return p.Path.next(e)}))},zr=function(e){Mr(e,(function(e){return e}))},Gr=function(e,t,n){var r=t.header;if(a.someNode(e,{match:{type:a.getPluginType(e,D.ELEMENT_TABLE)}})){var i=a.getAbove(e,{match:{type:[a.getPluginType(e,D.ELEMENT_TD),a.getPluginType(e,D.ELEMENT_TH)]}}),o=a.getAbove(e,{match:{type:a.getPluginType(e,D.ELEMENT_TABLE)}});if(i&&o){var l=n(i[1]).slice(),s=l.length-2;o[0].children.forEach((function(t,n){l[s]=n,a.insertNodes(e,D.getEmptyCellNode(e,{header:r&&0===n}),{at:l,select:0===n})}))}}},jr=function(e,t){Gr(e,t,(function(e){return p.Path.next(e)}))},Yr=function(e,t){Gr(e,t,(function(e){return e}))};function qr(e){D.insertTable(e,{header:!0}),function(e){var t=function(e){if(e.selection)return p.Path.levels(e.selection.focus.path).find((function(e){return 1===e.length}))}(e);if(t&&!a.isFirstChild(t)){var n=p.Path.previous(t);if(n){var r=p.Editor.nodes(e,{at:n,match:function(e){return e.type===o.BLOCKS.PARAGRAPH}})[0];r&&a.isAncestorEmpty(e,r[0])&&(p.Transforms.moveNodes(e,{at:t,to:n}),p.Transforms.removeNodes(e,{at:t}))}}}(e)}var Ur,Vr,Wr,Qr,Xr,$r,Zr,Jr=function(e,t){var n=t[1],r=a.getParent(e,n);if(!r)throw new Error("table rows must be wrapped in a table node");return Math.max.apply(Math,Array.from(p.Node.children(e,r[1])).map((function(t){return Array.from(p.Node.children(e,t[1])).length})))-Array.from(p.Node.children(e,n)).length},ei=function(e,t){return 0!==Array.from(p.Node.children(e,t[1])).length},ti=function(e){return p.Element.isElement(e)&&e.type===o.BLOCKS.TABLE},ni={topRight:l.css({position:"absolute",top:"6px",right:"5px"})},ri=function(){var e=Z(),t=E.useReadOnly(),r=n.useState(!1),i=r[0],l=r[1],s=n.useState(!1),c=s[0],u=s[1],d=n.useCallback((function(){l(!1)}),[]);n.useEffect((function(){u(Boolean(e&&function(e){var t=a.getAbove(e,{match:{type:o.BLOCKS.TABLE}});if(!t)return!1;var n=a.getChildren(t)[0];return!!n&&a.getChildren(n).every((function(e){return e[0].type===o.BLOCKS.TABLE_HEADER_CELL}))}(e)))}),[e]);var f=n.useMemo((function(){return!!e&&!a.getAbove(e,{match:{type:o.BLOCKS.TABLE_HEADER_CELL}})}),[e]),m=n.useCallback((function(){if(d(),e){var t=!c;u(t),function(e,t){var n=a.getAbove(e,{match:{type:o.BLOCKS.TABLE}});if(n){var r=a.getChildren(n)[0];r&&a.getChildren(r).forEach((function(n){a.setNodes(e,{type:t?o.BLOCKS.TABLE_HEADER_CELL:o.BLOCKS.TABLE_CELL},{at:n[1]})}))}}(e,t)}}),[e,d,c]),y=n.useCallback((function(t,n,r){return function(){if(null!=e&&e.selection){d();var i=function(e){var t=oe(e,o.BLOCKS.TABLE)[0];return t?function(e){var t,n=e.children.length;return n?{numRows:n,numColumns:null==(t=e.children[0].children)?void 0:t.length}:null}(t):null}(e);p.Editor.withoutNormalizing(e,(function(){t(e,{header:c})})),e.tracking.onViewportAction(n+"Table"+("Table"===r?"":r),{tableSize:i})}}}),[e,c,d]);return t?null:n.createElement(h.Menu,{placement:"left",isOpen:i,onOpen:function(){l(!0)},onClose:d},n.createElement(h.Menu.Trigger,null,n.createElement(h.IconButton,{size:"small",variant:"transparent",tabIndex:-1,className:ni.topRight,icon:n.createElement(L.ChevronDownIcon,null),"aria-label":"Open table menu",testId:"cf-table-actions-button"})),n.createElement(h.Menu.List,null,n.createElement(h.Menu.Item,{onClick:y(zr,"insert","Row"),disabled:!f},"Add row above"),n.createElement(h.Menu.Item,{onClick:y(Fr,"insert","Row")},"Add row below"),n.createElement(h.Menu.Item,{onClick:y(Yr,"insert","Column")},"Add column left"),n.createElement(h.Menu.Item,{onClick:y(jr,"insert","Column")},"Add column right"),n.createElement(h.Menu.Divider,null),n.createElement(h.Menu.Item,{onClick:m},c?"Disable table header":"Enable table header"),n.createElement(h.Menu.Divider,null),n.createElement(h.Menu.Item,{onClick:y(D.deleteRow,"remove","Row")},"Delete row"),n.createElement(h.Menu.Item,{onClick:y(D.deleteColumn,"remove","Column")},"Delete column"),n.createElement(h.Menu.Item,{onClick:y(D.deleteTable,"remove","Table")},"Delete table")))},ii=l.css(Ur||(Ur=q(["\n border: 1px solid ",";\n border-collapse: collapse;\n padding: 10px 12px;\n min-width: 48px;\n position: relative;\n vertical-align: top;\n\n div:last-child {\n margin-bottom: 0;\n }\n"])),T.gray400),oi=function(e){var n=E.useSelected();return t.createElement("td",Object.assign({},e.attributes,e.element.data,{className:ii}),n&&t.createElement(ri,null),e.children)},ai=l.css(Vr||(Vr=q(["\n background-color: ",";\n border: 1px solid ",";\n border-collapse: collapse;\n padding: 10px 12px;\n font-weight: ",";\n text-align: left;\n min-width: 48px;\n position: relative;\n\n div:last-child {\n margin-bottom: 0;\n }\n"])),T.gray200,T.gray400,T.fontWeightMedium),li=function(e){var n=E.useSelected();return t.createElement("th",Object.assign({},e.attributes,e.element.data,{className:ai}),n&&t.createElement(ri,null),e.children)},si=l.css(Wr||(Wr=q(["\n border: 1px solid ",";\n border-collapse: collapse;\n\n &:hover td {\n background-color: transparent !important;\n }\n"])),T.gray400),ci=function(e){return t.createElement("tr",Object.assign({},e.attributes,{className:si}),e.children)},ui=l.css(Qr||(Qr=q(["\n margin-bottom: 1.5em;\n border-collapse: collapse;\n border-radius: 5px;\n border-style: hidden;\n box-shadow: 0 0 0 1px ",";\n width: 100%;\n table-layout: fixed;\n overflow: hidden;\n"])),T.gray400),di=function(e){return t.createElement("table",Object.assign({},e.attributes,{className:ui}),t.createElement("tbody",null,e.children))},fi=function(e,t){var n=D.onKeyDownTable(e,t);return function(t){if("Backspace"===t.key&&function(e){var t,n=oe(e,[o.BLOCKS.TABLE_CELL,o.BLOCKS.TABLE_HEADER_CELL]);return!(!n[0]||a.getText(e,n[1])&&0!==(null==(t=e.selection)?void 0:t.focus.offset))}(e)||"Delete"===t.key&&function(e){var t=function(e){if(!e.selection)return null;for(var t=p.Node.descendants(e,{from:e.selection.focus.path});;){var n=t.next(),r=n.value;if(n.done)return null;var i=r[0];if(!p.Path.isCommon(r[1],e.selection.focus.path))return i}}(e);return!!t&&o.TABLE_BLOCKS.includes(t.type)&&function(e){var t,n;return(null==(t=e.selection)?void 0:t.focus.offset)===a.getText(e,null==(n=e.selection)?void 0:n.focus.path).length}(e)}(e))return t.preventDefault(),void t.stopPropagation();n(t)}},mi=function(){var e;return D.createTablePlugin({type:o.BLOCKS.TABLE,handlers:{onKeyDown:fi},withOverrides:function(e){!function(e){var t=e.insertData;e.insertData=function(n){if(n.getData("text/html")){var r=e.children;t(n);var i=e.children;setTimeout((function(){var t;Pr(r)||Pr(i)&&e.tracking.onViewportAction("paste",{tablePasted:!0,hasHeadersOutsideFirstRow:(t=i,t.filter((function(e){return e.type===o.BLOCKS.TABLE})).flatMap((function(e){return e.children.slice(1)})).some((function(e){return e.children.some(Hr)})))})}),1)}else t(n)}}(e);var t=e.insertFragment;return e.insertFragment=function(n){var r,i=n.some((function(e){return ti(e)})),o=0===n.findIndex((function(e){return ti(e)})),l=""!==a.getText(e,null==(r=e.selection)?void 0:r.focus.path);i&&o&&l&&se(e),t(n)},e},overrideByKey:(e={},e[D.ELEMENT_TABLE]={type:o.BLOCKS.TABLE,component:di,normalizer:[{validNode:ei},{validNode:function(e,t){var n=t[1],r=!!a.getBlockAbove(e,{at:n,match:{type:[o.BLOCKS.TABLE_CELL,o.BLOCKS.TABLE_HEADER_CELL]}});return ie(n)||r},transform:Ut},{validChildren:o.CONTAINERS[o.BLOCKS.TABLE]}]},e[D.ELEMENT_TR]={type:o.BLOCKS.TABLE_ROW,component:ci,normalizer:[{validChildren:o.CONTAINERS[o.BLOCKS.TABLE_ROW],transform:qt(o.BLOCKS.TABLE_CELL)},{validNode:ei},{validNode:function(e,t){var n,r=null==(n=a.getParent(e,t[1]))?void 0:n[0];return r&&r.type===o.BLOCKS.TABLE},transform:qt(o.BLOCKS.TABLE)},{validNode:function(e,t){return 0===Jr(e,t)},transform:function(e,t){var n,r=Jr(e,t),i=p.Path.next(a.getLastChildPath(t));p.Transforms.insertNodes(e,(n={type:o.BLOCKS.TABLE_CELL,data:{},children:[{type:o.BLOCKS.PARAGRAPH,data:{},children:[{text:""}]}]},new Array(r).fill(n)),{at:i})}}]},e[D.ELEMENT_TH]={type:o.BLOCKS.TABLE_HEADER_CELL,component:li,normalizer:[{validChildren:o.CONTAINERS[o.BLOCKS.TABLE_HEADER_CELL],transform:jt}]},e[D.ELEMENT_TD]={type:o.BLOCKS.TABLE_CELL,component:oi,normalizer:[{validChildren:o.CONTAINERS[o.BLOCKS.TABLE_CELL],transform:jt}]},e)})};function pi(e){var n=Z(),r=n&&function(e){return[D.ELEMENT_TABLE,D.ELEMENT_TH,D.ELEMENT_TR,D.ELEMENT_TD].some((function(t){return re(e,t)}))}(n);function i(){return(i=P(xe.mark((function e(){return xe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}return e.abrupt("return");case 2:n.tracking.onToolbarAction("insertTable"),qr(n),pe(n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return n?t.createElement(tn,{title:"Table",testId:"table-toolbar-button",onClick:function(){return i.apply(this,arguments)},isActive:r,isDisabled:e.isDisabled},t.createElement(L.TableIcon,null)):null}function Ei(e,t,n){var r=a.getAbove(t,{match:{type:o.TEXT_CONTAINERS}});if(r){var i=r[1],l=a.isAncestorEmpty(t,r[0]),s=t.children.length>1;l&&1===i.length&&a.isFirstChild(i)&&s?p.Transforms.removeNodes(t,{at:i}):n(e)}else n(e)}var yi=Object.values(o.INLINES).map((function(e){return{type:e}})),hi={document:{nodes:[{types:o.TOP_LEVEL_BLOCKS.map((function(e){return{type:e}}))}]},blocks:H((Xr={},Xr[o.BLOCKS.PARAGRAPH]={nodes:[{match:[].concat(yi,[{object:"text"}])}]},Xr[o.BLOCKS.HEADING_1]={nodes:[{match:[].concat(yi,[{object:"text"}])}]},Xr[o.BLOCKS.HEADING_2]={nodes:[{match:[].concat(yi,[{object:"text"}])}]},Xr[o.BLOCKS.HEADING_3]={nodes:[{match:[].concat(yi,[{object:"text"}])}]},Xr[o.BLOCKS.HEADING_4]={nodes:[{match:[].concat(yi,[{object:"text"}])}]},Xr[o.BLOCKS.HEADING_5]={nodes:[{match:[].concat(yi,[{object:"text"}])}]},Xr[o.BLOCKS.HEADING_6]={nodes:[{match:[].concat(yi,[{object:"text"}])}]},Xr),o.VOID_BLOCKS.reduce((function(e,t){var n;return H({},e,((n={})[t]={isVoid:!0},n))}),{}),($r={},$r[o.BLOCKS.QUOTE]={nodes:[{match:[o.CONTAINERS[o.BLOCKS.QUOTE].map((function(e){return{type:e}}))],min:1}],normalize:function(e,t){if("child_type_invalid"===t.code)return e.unwrapBlockByKey(t.node.key,o.BLOCKS.QUOTE)}},$r)),inlines:(Zr={},Zr[o.INLINES.HYPERLINK]={nodes:[{match:[{object:"text"}]}]},Zr[o.INLINES.ENTRY_HYPERLINK]={nodes:[{match:[{object:"text"}]}]},Zr[o.INLINES.ASSET_HYPERLINK]={nodes:[{match:[{object:"text"}]}]},Zr[o.INLINES.EMBEDDED_ENTRY]={isVoid:!0},Zr)};function vi(e){var t=B.toContentfulDocument({document:e.children,schema:hi});return R.documentToPlainTextString(t).length}var gi=function(e){var t={onViewportAction:function(t,n){return void 0===n&&(n={}),e(t,H({origin:"viewport-interaction"},n))},onShortcutAction:function(t,n){return void 0===n&&(n={}),e(t,H({origin:"shortcut"},n))},onToolbarAction:function(t,n){return void 0===n&&(n={}),e(t,H({origin:"toolbar-icon"},n))},onCommandPaletteAction:function(t,n){return void 0===n&&(n={}),e(t,H({origin:"command-palette"},n))}};return{key:"TrackingPlugin",withOverrides:function(e){var n=e.insertData;return e.tracking=t,e.insertData=function(r){if(0!==r.types.length){var i,o=null==(i=window.getSelection())?void 0:i.toString().length,a=vi(e);setTimeout((function(){var n=vi(e);t.onShortcutAction("paste",{characterCountAfter:n,characterCountBefore:a,characterCountSelection:o})}))}n(r)},e}}},Li={deserializeAst:!0,deserializeHtml:!0,eventEditor:!0},Ti=function(e){return!!e&&e.content.length>0},Si=function(e){return B.toSlatejsDocument({document:Ti(e)?e:o.EMPTY_DOCUMENT,schema:hi})},Ni="1px solid "+T.gray400,bi={root:l.css({position:"relative"}),editor:l.css({borderRadius:"0 0 "+T.borderRadiusMedium+" "+T.borderRadiusMedium,border:Ni,borderTop:0,padding:"20px",fontSize:T.spacingM,fontFamily:T.fontStackPrimary,minHeight:"400px",background:T.colorWhite,outline:"none",whiteSpace:"pre-wrap",overflowWrap:"break-word",webkitUserModify:"read-write-plaintext-only",a:{span:{cursor:"not-allowed","&:hover":{cursor:"not-allowed"}}},"ul > li > div":{margin:0}}),hiddenToolbar:l.css({borderTop:Ni}),enabled:l.css({background:T.colorWhite,a:{span:{cursor:"pointer","&:hover":{cursor:"pointer"}}}}),disabled:l.css({background:T.gray100})};function Ci(e){var n=e.children,r=e.isDisabled;return t.createElement(h.Menu,{placement:"bottom-end",isOpen:e.isOpen,onClose:e.onClose,onOpen:e.onToggle},t.createElement(h.Menu.Trigger,null,t.createElement(h.Button,{endIcon:t.createElement(L.ChevronDownIcon,null),testId:"toolbar-entity-dropdown-toggle",variant:"secondary",size:"small",startIcon:t.createElement(L.PlusIcon,null),isDisabled:r},"Embed")),t.createElement(h.Menu.List,{className:"toolbar-entity-dropdown-list"},n))}var Ii,ki=function(e){var r=e.isDisabled,i=e.canInsertBlocks,a=Le(),l=Z(),s=t.useState(!1),c=s[0],u=s[1],d=function(){return u(!1)},f=t.useState(!1),m=f[0],p=f[1];n.useEffect((function(){var e=!0;return a.access.can("read","Asset").then((function(t){e&&p(t)})),function(){e=!1}}),[a]);var E=gt(a.field,o.INLINES.EMBEDDED_ENTRY),y=gt(a.field,o.BLOCKS.EMBEDDED_ENTRY)&&i,h=m&>(a.field,o.BLOCKS.EMBEDDED_ASSET)&&i,v=[E,y,h].filter(Boolean).length>1||r;n.useEffect((function(){v||u(!1)}),[v]);var g=n.createElement(n.Fragment,null,y&&n.createElement(je,{isDisabled:!!r,nodeType:o.BLOCKS.EMBEDDED_ENTRY,onClose:d,isButton:!v}),E&&n.createElement(it,{isDisabled:!!r||ue(l),onClose:d,isButton:!v}),h&&n.createElement(je,{isDisabled:!!r,nodeType:o.BLOCKS.EMBEDDED_ASSET,onClose:d,isButton:!v}));return v?n.createElement(Ci,{isDisabled:r,onClose:d,onToggle:function(){return u(!c)},isOpen:c},g):g},Ai={toolbar:l.css({border:"1px solid "+T.gray400,backgroundColor:T.gray100,padding:T.spacingXs,borderRadius:T.borderRadiusMedium+" "+T.borderRadiusMedium+" 0 0"}),divider:l.css({display:"inline-block",height:"21px",width:"1px",background:T.gray300,margin:"0 "+T.spacing2Xs}),embedActionsWrapper:l.css({display:["-webkit-box","-ms-flexbox","flex"],webkitAlignSelf:"flex-start",alignSelf:"flex-start",msFlexItemAlign:"start",marginLeft:"auto"}),formattingOptionsWrapper:l.css({display:["-webkit-box","-ms-flexbox","flex"],msFlexAlign:"center",webkitBoxAlign:"center",alignItems:"center",msFlexWrap:"wrap",flexWrap:"wrap",marginRight:"20px"})},Oi=function(e){var t=e.isDisabled,r=Le(),i=Z(),a=!ae(i,o.BLOCKS.TABLE),l=n.useMemo((function(){return e=r.field,{isAnyMarkEnabled:(t=function(t,n){return t.some((function(t){return n(e,t)}))})(Object.values(o.MARKS),Lt),isAnyHyperlinkEnabled:t([o.INLINES.HYPERLINK,o.INLINES.ASSET_HYPERLINK,o.INLINES.ENTRY_HYPERLINK],gt),isAnyBlockFormattingEnabled:t([o.BLOCKS.UL_LIST,o.BLOCKS.OL_LIST,o.BLOCKS.QUOTE,o.BLOCKS.HR],gt)};var e,t}),[r.field]),s=ae(i,o.BLOCKS.UL_LIST)||ae(i,o.BLOCKS.OL_LIST),c=ae(i,o.BLOCKS.QUOTE),u=t||!a||s||c;return n.createElement(h.Flex,{testId:"toolbar",className:Ai.toolbar,alignItems:"center"},n.createElement("div",{className:Ai.formattingOptionsWrapper},n.createElement(Nt,{isDisabled:t||!a}),l.isAnyMarkEnabled&&n.createElement("span",{className:Ai.divider}),Lt(r.field,o.MARKS.BOLD)&&n.createElement(ir,{isDisabled:t}),Lt(r.field,o.MARKS.ITALIC)&&n.createElement(ur,{isDisabled:t}),Lt(r.field,o.MARKS.UNDERLINE)&&n.createElement(mr,{isDisabled:t}),Lt(r.field,o.MARKS.CODE)&&n.createElement(lr,{isDisabled:t}),l.isAnyHyperlinkEnabled&&n.createElement(n.Fragment,null,n.createElement("span",{className:Ai.divider}),n.createElement(yn,{isDisabled:t})),l.isAnyBlockFormattingEnabled&&n.createElement("span",{className:Ai.divider}),n.createElement(tr,{isDisabled:t||!a}),gt(r.field,o.BLOCKS.QUOTE)&&n.createElement(_r,{isDisabled:t||!a}),gt(r.field,o.BLOCKS.HR)&&n.createElement(on,{isDisabled:t||!a}),gt(r.field,o.BLOCKS.TABLE)&&n.createElement(pi,{isDisabled:u})),n.createElement("div",{className:Ai.embedActionsWrapper},n.createElement(ki,{isDisabled:t,canInsertBlocks:a})))},Di={nativeSticky:l.css(Ii||(Ii=q(["\n position: -webkit-sticky;\n position: sticky;\n top: -1px;\n z-index: 2;\n "])))},Bi=function(e){return n.createElement("div",{className:e.isDisabled?"":Di.nativeSticky},e.children)},Ri=function(e){return"set_selection"!==e.type},xi=["sdk","isInitiallyDisabled","onAction"],wi=function(e){var r,i,s,m,E,y,h=W(e.sdk),v=n.useMemo((function(){var t,n,r,i,l,s,m,E,y;return n=e.sdk,r=null!=(t=e.onAction)?t:c,[a.createDeserializeHtmlPlugin(),a.createDeserializeAstPlugin(),u.createDeserializeDocxPlugin(),gi(r),(E=[o.BLOCKS.EMBEDDED_ENTRY,o.BLOCKS.EMBEDDED_ASSET,o.BLOCKS.HR,o.INLINES.EMBEDDED_ENTRY],y={TABLE:[o.INLINES.EMBEDDED_ENTRY]},{key:"DragAndDropPlugin",handlers:{onDrop:function(e){return function(t){var n=Array.from(a.getNodes(e,{match:function(e){return E.includes(null==e?void 0:e.type)}}))[0];if(!n)return!1;var r=n[0];if(!t.nativeEvent.target)return!1;var i=function(e){var t=[];for(t.push(e);e.parentNode;)t.unshift(e.parentNode),e=e.parentNode;return t}(t.nativeEvent.target).some((function(e){var t;return!(!y[e.nodeName]||null!=(t=y[e.nodeName])&&t.includes(r.type))}));return i||e.history.undos.push([]),i}}}}),(m={type:o.BLOCKS.PARAGRAPH,component:br,options:{hotkey:["mod+opt+0"]},handlers:{onKeyDown:Cr},softBreak:[{hotkey:"shift+enter",query:{allow:o.BLOCKS.PARAGRAPH}}],deserializeHtml:{rules:[{validNodeName:["P","DIV"]}],query:function(e){return!(""===e.textContent||(t=e,t.hasAttribute("data-embedded-entity-inline-id")||t.hasAttribute("data-entity-type")));var t}},normalizer:[{validChildren:function(e,t){return me(t[0])},transform:(s={},s[o.BLOCKS.PARAGRAPH]=Yt,s.default=Ut,s)}]},A.createParagraphPlugin(m)),b.createListPlugin({normalizer:[{match:{type:[o.BLOCKS.UL_LIST,o.BLOCKS.OL_LIST]},validChildren:[o.BLOCKS.LIST_ITEM],transform:qt(o.BLOCKS.LIST_ITEM)}],overrideByKey:(l={},l[b.ELEMENT_UL]={type:o.BLOCKS.UL_LIST,component:Kn,handlers:{onKeyDown:jn},withOverrides:er},l[b.ELEMENT_OL]={type:o.BLOCKS.OL_LIST,component:_n,handlers:{onKeyDown:jn}},l[b.ELEMENT_LIC]={type:o.BLOCKS.PARAGRAPH},l[b.ELEMENT_LI]={type:o.BLOCKS.LIST_ITEM,component:Hn,normalizer:[{validNode:qn,transform:Un},{validNode:Vn,transform:Qn},{validChildren:o.LIST_ITEM_BLOCKS,transform:jt},{validNode:Wn,transform:Xn}]},l)}),{key:o.BLOCKS.HR,type:o.BLOCKS.HR,isVoid:!0,isElement:!0,component:an,handlers:{onKeyDown:rn},deserializeHtml:{rules:[{validNodeName:["HR"]},{validAttribute:{"data-void-element":o.BLOCKS.HR}}],withoutChildren:!0}},Jt(),Kr(),mi(),Ve(n),We(n),Dn(n),ot(n),{key:"Marks",plugins:[I.createBoldPlugin({type:o.MARKS.BOLD,component:ar,options:{hotkey:["mod+b"]},handlers:{onKeyDown:rr(o.MARKS.BOLD)},deserializeHtml:{rules:[{validNodeName:["STRONG","B"]},{validStyle:{fontWeight:["600","700","bold"]}}],query:function(e){return!function(e){return e.id.startsWith("docs-internal-guid")&&"B"===e.nodeName}(e)&&!a.someHtmlElement(e,(function(e){return"normal"===e.style.fontWeight}))}}}),I.createCodePlugin({type:o.MARKS.CODE,component:cr,options:{hotkey:["mod+/"]},handlers:{onKeyDown:rr(o.MARKS.CODE)},deserializeHtml:{rules:[{validNodeName:["CODE","PRE"]},{validStyle:{fontFamily:["Consolas","monospace"]}}]}}),I.createItalicPlugin({type:o.MARKS.ITALIC,component:fr,options:{hotkey:["mod+i"]},handlers:{onKeyDown:rr(o.MARKS.ITALIC)},deserializeHtml:{rules:[{validNodeName:["I","EM"]},{validStyle:{fontStyle:"italic"}}],query:function(e){return!a.someHtmlElement(e,(function(e){return"normal"===e.style.fontStyle}))}}}),I.createUnderlinePlugin({type:o.MARKS.UNDERLINE,component:pr,options:{hotkey:["mod+u"]},handlers:{onKeyDown:rr(o.MARKS.UNDERLINE)},deserializeHtml:{rules:[{validNodeName:["U"]},{validStyle:{textDecoration:["underline"]}}],query:function(e){return!a.someHtmlElement(e,(function(e){return"none"===e.style.textDecoration}))}}})]},x.createTrailingBlockPlugin({options:{type:o.BLOCKS.PARAGRAPH,level:0}}),{key:"TextPlugin",handlers:{onMouseUp:function(e){return function(){e.selection&&p.Transforms.setSelection(e,p.Editor.unhangRange(e,e.selection))}}},withOverrides:function(e){var t=e.insertText;e.insertText=function(n){var r=e.selection;if(r&&p.Range.isCollapsed(r)){var i,o=null==(i=p.Editor.above(e,{match:function(t){return p.Editor.isInline(e,t)},mode:"highest"}))?void 0:i[1];if(o&&p.Editor.isEnd(e,r.anchor,o)){var a=p.Editor.after(e,o);p.Transforms.setSelection(e,{anchor:a,focus:a})}}return t(n)};var n=e.deleteForward,r=e.deleteBackward;return e.deleteBackward=function(t){Ei(t,e,r)},e.deleteForward=function(t){Ei(t,e,n)},e}},{key:"VoidsPlugin",exitBreak:[{hotkey:"enter",before:!0,query:{filter:function(e){var t=e[0],n=e[1];return ie(n)&&a.isFirstChild(n)&&!!t.isVoid}}},{hotkey:"enter",level:-2,query:{filter:function(e){var t=e[0],n=e[1];return!(ie(n)&&a.isFirstChild(n)||!t.isVoid)}}}]},O.createSelectOnBackspacePlugin({options:{query:{allow:[o.BLOCKS.EMBEDDED_ASSET,o.BLOCKS.EMBEDDED_ENTRY,o.BLOCKS.HR,o.INLINES.EMBEDDED_ENTRY]}}}),{key:"PasteHTMLPlugin",withOverrides:function(e){var t=e.insertData;return e.insertData=function(e){return t(function(e){if(!e.getData("application/x-slate-fragment")){var t=function(e){return(e.getData("text/html").match(Ar)||[])[1]}(e);if(t){var n=new DataTransfer;return e.types.forEach((function(t){n.setData(t,e.getData(t))})),n.setData("application/x-slate-fragment",t),n}}return e}(e))},e},inject:{pluginsByKey:(i={},i[a.KEY_DESERIALIZE_HTML]={editor:{insertData:{format:"text/html",transformData:kr}}},i)}},d.createSoftBreakPlugin({then:function(e){return{options:{rules:e.plugins.flatMap((function(e){return e.softBreak||[]}))}}}}),d.createExitBreakPlugin({options:{rules:[]},then:function(e){return{options:{rules:e.plugins.flatMap((function(e){return e.exitBreak||[]}))}}}}),f.createResetNodePlugin({options:{rules:[]},then:function(e){for(var t,n=e.plugins.flatMap((function(e){return e.resetNode||[]})),r=V(n);!(t=r()).done;){var i=t.value;i.defaultType||(i.defaultType=o.BLOCKS.PARAGRAPH)}return{options:{rules:n}}}}),{key:"NormalizerPlugin",withOverrides:Sr}]}),[e.sdk,e.onAction]),g=t.useState(!0),L=g[0],T=g[1],S=t.useState(!1),N=S[1],C=(i=(r={editorId:h,handler:e.onChange,skip:S[0]||L,onSkip:function(){return N(!1)}}).editorId,m=r.skip,E=r.onSkip,y=t.useMemo((function(){return w((function(e){null==s||s(B.toContentfulDocument({document:e,schema:hi}))}),500)}),[s=r.handler]),t.useCallback((function(e){var t=a.getPlateSelectors(i).editor();if(!t)throw new Error("Editor change callback called but editor not defined. Editor id: "+i);if((null==t?void 0:t.operations.filter(Ri)).length>0){if(m)return void(null==E||E());y(e)}}),[i,y,m,E]));t.useEffect((function(){T(!1);var t=a.getPlateSelectors(h).editor();t&&(N(!0),function(e,t){p.Editor.withoutNormalizing(e,(function(){[].concat(e.children).forEach((function(t){return e.apply({type:"remove_node",path:[0],node:t})})),t&&(p.Node.isNode(t)?[t]:t).forEach((function(t,n){return e.apply({type:"insert_node",path:[n],node:t})}));var n=p.Editor.end(e,[]);n&&p.Transforms.select(e,n)}))}(t,Si(e.value)))}),[e.value,h]);var k=l.cx(bi.editor,void 0!==e.minHeight?l.css({minHeight:e.minHeight}):void 0,e.isDisabled?bi.disabled:bi.enabled,e.isToolbarHidden&&bi.hiddenToolbar);return t.useEffect((function(){var t,n;L&&a.getPlateActions(h).value((t=Si(e.value),(n=a.createPlateEditor({plugins:v,disableCorePlugins:Li})).children=t,p.Editor.normalize(n,{force:!0}),n.children))}),[L,v,h,e.value]),n.createElement(ge,{sdk:e.sdk},n.createElement(X,{value:h},n.createElement("div",{className:bi.root,"data-test-id":"rich-text-editor"},n.createElement(a.Plate,{id:h,plugins:v,disableCorePlugins:Li,editableProps:{className:k,readOnly:e.isDisabled},onChange:C},!e.isToolbarHidden&&n.createElement(Bi,{isDisabled:e.isDisabled},n.createElement(Oi,{isDisabled:e.isDisabled}))))))};function Ki(e){var t=e.sys;return{sys:{id:t.id,type:"Link",linkType:t.type}}}var _i=function(e){function t(t){var n,r;(r=e.call(this,t)||this).handleSubmit=function(e){e.preventDefault(),r.props.onClose(r.getValue())},r.selectEntry=P(xe.mark((function e(){var t,n,i;return xe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(t=r.props.entitySelectorConfigs.Entry).locale,i=t.contentTypes,e.next=3,r.props.sdk.dialogs.selectSingleEntry({locale:n,contentTypes:i});case 3:r.setTargetEntity("Entry",e.sent);case 5:case"end":return e.stop()}}),e)}))),r.selectAsset=P(xe.mark((function e(){var t;return xe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.props.entitySelectorConfigs.Asset.locale,e.next=3,r.props.sdk.dialogs.selectSingleAsset({locale:t});case 3:r.setTargetEntity("Asset",e.sent);case 5:case"end":return e.stop()}}),e)})));var i=t.value,o=i.text,a=i.type,l=i.uri,s=i.target,c=Boolean(s),u=((n={}).Entry=null,n.Asset=null,n),d=a;return c?u[d=s.sys.linkType]=s:d=t.allowedHyperlinkTypes.includes("uri")?"uri":t.allowedHyperlinkTypes[0],r.state={text:o,uri:l,entityLinks:u,type:d},r}M(t,e);var i=t.prototype;return i.setTargetEntity=function(e,t){this.setState((function(n){var r;return{entityLinks:H({},n.entityLinks,(r={},r[e]=t?Ki(t):void 0,r))}}))},i.getValue=function(){var e=this.state,t=e.text,n=e.type,r=e.uri,i={type:n};return t&&(i.text=t),"uri"===n?i.uri=r:i.target=this.state.entityLinks[n],i},i.isLinkComplete=function(){var e=this.getValue();return!(!this.props.hideText&&!e.text)&&("uri"===e.type&&e.uri||e.target)},i.render=function(){var e=this,t=this.props.labels;return n.createElement(r.EntityProvider,{sdk:this.props.sdk},n.createElement(n.Fragment,null,n.createElement(h.ModalContent,null,this.renderFields()),n.createElement(h.ModalControls,null,n.createElement(h.Button,{type:"button",onClick:function(){return e.props.onClose(null)},variant:"secondary",testId:"cancel-cta",size:"small"},"Cancel"),n.createElement(h.Button,{type:"submit",variant:"positive",onClick:this.handleSubmit,isDisabled:!this.isLinkComplete(),testId:"confirm-cta",size:"small"},t.confirm))))},i.renderFields=function(){var e=this,t=this.props,r=t.hideText,i=t.allowedHyperlinkTypes,o=t.entitySelectorConfigs,a=this.state,l=a.uri,s=a.text,c=a.type,u="uri"===c&&(r||!!s);return n.createElement(h.Form,null,r?null:n.createElement(h.FormControl,{id:"link-text",isRequired:!0},n.createElement(h.FormControl.Label,null,"Link text"),n.createElement(h.TextInput,{testId:"link-text-input",name:"link-text",value:s||"",onChange:function(t){return e.setState({text:t.target.value})},autoFocus:!u})),function(e){return void 0===e&&(e={}),!!e.Entry||!!e.Asset}(o)&&n.createElement(h.FormControl,{id:"link-type",name:"link-type"},n.createElement(h.FormControl.Label,null,"Link type"),n.createElement(h.Select,{value:c,onChange:function(t){return e.setState({type:t.target.value})},testId:"link-type-select"},i.includes("uri")||"uri"===c?n.createElement(h.Select.Option,{value:"uri"},"URL"):null,i.includes("Entry")||"Entry"===c?n.createElement(h.Select.Option,{value:"Entry"},"Entry"):null,i.includes("Asset")||"Asset"===c?n.createElement(h.Select.Option,{value:"Asset"},"Asset"):null)),"uri"===c?n.createElement(h.FormControl,{id:"link-uri",isRequired:!0},n.createElement(h.FormControl.Label,null,"Link target"),n.createElement(h.TextInput,{testId:"link-target-input",name:"link-uri",value:l||"",placeholder:"https://",onChange:function(t){return e.setState({uri:t.target.value})},autoFocus:u}),n.createElement(h.FormControl.HelpText,null,"A protocol may be required, e.g. https://")):this.renderEntityField())},i.renderEntityField=function(){var e=this,t=this.state,r=t.type,i=t.entityLinks[r],o=!i;return n.createElement("div",null,n.createElement(h.FormLabel,{required:!0,htmlFor:""},"Link target"),!o&&n.createElement(h.TextLink,{as:"button",className:l.css({marginLeft:T.spacingS}),onClick:function(){return e.setTargetEntity(r,null)}},"Remove selection"),i&&n.createElement("div",null,"Entry"===r&&n.createElement(Oe,{sdk:this.props.sdk,locale:this.props.entitySelectorConfigs.Entry.locale,entryId:i.sys.id,isDisabled:!0,isSelected:!1}),"Asset"==r&&n.createElement(Ie,{sdk:this.props.sdk,locale:this.props.entitySelectorConfigs.Asset.locale,assetId:i.sys.id,isDisabled:!0,isSelected:!1})),o&&this.renderEntitySelector(r,o))},i.renderEntitySelector=function(e){return n.createElement("div",{className:l.css({marginTop:T.spacingS})},"Entry"===e&&n.createElement(h.TextLink,{as:"button",onClick:this.selectEntry},"Select entry"),"Asset"===e&&n.createElement(h.TextLink,{as:"button",onClick:this.selectAsset},"Select asset"))},t}(n.Component);_i.propTypes={sdk:K.object.isRequired,labels:K.shape({title:K.string,confirm:K.string}),value:K.shape({text:K.string,uri:K.string,target:K.object,type:K.oneOf(["uri","Entry","Asset"])}),entitySelectorConfigs:K.object,allowedHyperlinkTypes:K.arrayOf(K.oneOf(["Entry","Asset","uri"])),hideText:K.bool,onClose:K.func.isRequired},_i.defaultProps={labels:{title:"Insert link",confirm:"Insert link"},value:{},hideText:!1,entitySelectorConfigs:{},allowedHyperlinkTypes:["Entry","Asset","uri"]},exports.ConnectedRichTextEditor=wi,exports.RichTextEditor=function(e){var a=e.sdk,l=e.isInitiallyDisabled,c=e.onAction,u=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(i[n]=e[n]);return i}(e,xi),d=t.useCallback((function(e){return!e||s(e,o.EMPTY_DOCUMENT)}),[]),f=W(e.sdk);return n.createElement(r.EntityProvider,{sdk:a},n.createElement(i.FieldConnector,{throttle:0,field:a.field,isInitiallyDisabled:l,isEmptyValue:d,isEqualValues:s},(function(e){return n.createElement(wi,Object.assign({},u,{key:"rich-text-editor-"+f,value:e.lastRemoteValue,sdk:a,onAction:c,isDisabled:e.disabled,onChange:e.setValue}))})))},exports.openRichTextDialog=function(e){return function(t){var r;return"rich-text-hyperlink-dialog"===(null==(r=t.parameters)?void 0:r.type)?i.ModalDialogLauncher.openDialog(t,(function(r){return n.createElement(_i,Object.assign({},t.parameters,{onClose:r.onClose,sdk:e}))})):Promise.reject()}},exports.renderRichTextDialog=function(e){var t=e.parameters.invocation;return"rich-text-hyperlink-dialog"===(null==t?void 0:t.type)?(e.window.startAutoResizer(),n.createElement(_i,Object.assign({},e.parameters.invocation,{onClose:e.close,sdk:e}))):n.createElement("div",null)};
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),r=require("@contentful/field-editor-reference"),i=require("@contentful/field-editor-shared"),o=require("@contentful/rich-text-types"),a=require("@udecode/plate-core"),l=require("emotion"),s=e(require("fast-deep-equal")),c=e(require("lodash/noop")),u=require("@udecode/plate-serializer-docx"),d=require("@udecode/plate-break"),f=require("@udecode/plate-reset-node"),m=e(require("is-hotkey")),p=require("slate"),E=require("slate-react"),y=e(require("constate")),h=require("@contentful/f36-components"),v=e(require("@contentful/mimetype")),g=e(require("lodash/get")),L=require("@contentful/f36-icons"),T=e(require("@contentful/f36-tokens")),S=e(require("lodash/find")),b=e(require("lodash/flow")),N=require("@udecode/plate-list"),C=e(require("lodash/castArray")),I=require("@udecode/plate-basic-marks"),k=e(require("is-plain-obj")),A=require("@udecode/plate-paragraph"),O=require("@udecode/plate-select"),D=require("@udecode/plate-table"),B=require("@contentful/contentful-slatejs-adapter"),R=require("@contentful/rich-text-plain-text-renderer"),w=require("@udecode/plate-trailing-block"),x=e(require("lodash/debounce")),K=e(require("prop-types"));function _(e,t,n,r,i,o,a){try{var l=e[o](a),s=l.value}catch(e){return void n(e)}l.done?t(s):Promise.resolve(s).then(r,i)}function P(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){_(o,r,i,a,l,"next",e)}function l(e){_(o,r,i,a,l,"throw",e)}a(void 0)}))}}function H(){return(H=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function M(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,z(e,t)}function F(e){return(F=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function z(e,t){return(z=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function G(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function j(e,t,n){return(j=G()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&z(i,n.prototype),i}).apply(null,arguments)}function Y(e){var t="function"==typeof Map?new Map:void 0;return(Y=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return j(e,arguments,F(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),z(n,e)})(e)}function q(e,t){return t||(t=e.slice(0)),e.raw=t,e}function U(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function V(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return U(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?U(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function W(e){var t=e.field;return"rich-text-editor-"+e.entry.getSys().id+"-"+t.id+"-"+t.locale}var Q=t.createContext(""),X=Q.Provider;function $(e){var n=t.useContext(Q);if(e)return e;if(!n)throw new Error("could not find editor id. Please ensure the component is wrapped in <ContentfulEditorIdProvider> ");return n}function Z(e){var t=$(e);return a.usePlateEditorState(t)}var J="undefined"!=typeof navigator&&/Edge?\/(?:[0-6][0-9]|[0-7][0-8])/i.test(navigator.userAgent),ee=!("undefined"!=typeof navigator&&/Chrome?\/(?:[0-7][0-5]|[0-6][0-9])/i.test(navigator.userAgent))&&!J&&"undefined"!=typeof globalThis&&globalThis.InputEvent&&"function"==typeof globalThis.InputEvent.prototype.getTargetRanges,te="undefined"!=typeof navigator&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),ne=[o.INLINES.HYPERLINK,o.INLINES.ENTRY_HYPERLINK,o.INLINES.ASSET_HYPERLINK];function re(e,t){return!!Array.from(p.Editor.nodes(e,{match:function(e){return p.Element.isElement(e)&&e.type===t}}))[0]}function ie(e){return 1===e.length}function oe(e,t,n){var r,i;if(!(n=null!=(r=n)?r:null==(i=e.selection)?void 0:i.focus.path))return[];for(var o=Array.isArray(t)?t:[t],a=0;a<n.length;a++){var l=p.Editor.node(e,n.slice(0,a+1));if(o.includes(l[0].type))return l}return[]}function ae(e,t){return!!e&&!!oe(e,t)[0]}function le(e){p.Transforms.move(e,{distance:1,unit:"character"})}function se(e,t){p.Transforms.insertNodes(e,{type:o.BLOCKS.PARAGRAPH,children:[{text:""}],data:{},isVoid:!1},t)}function ce(e,t){e.selection&&function(e,t){var n=t.text,r=t.url,i=t.target,o=t.type,a=t.path;ue(e)&&!a&&de(e);var l=e.selection,s=l&&p.Range.isCollapsed(l),c={type:o,data:{},children:s?[{text:n}]:[]};r&&(c.data={uri:r}),i&&(c.data={target:i}),a?(p.Transforms.setNodes(e,c,{at:a}),p.Transforms.insertText(e,n,{at:a}),p.Transforms.select(e,a)):s?p.Transforms.insertNodes(e,c):(p.Transforms.wrapNodes(e,c,{split:!0}),p.Transforms.delete(e),p.Transforms.insertText(e,n),p.Transforms.collapse(e,{edge:"end"}))}(e,t)}function ue(e){return!!e&&!!Array.from(p.Editor.nodes(e,{match:function(e){return!p.Editor.isEditor(e)&&p.Element.isElement(e)&&ne.includes(e.type)}}))[0]}function de(e){p.Transforms.unwrapNodes(e,{match:function(e){return!p.Editor.isEditor(e)&&p.Element.isElement(e)&&ne.includes(e.type)}})}var fe=Object.values(o.INLINES),me=function(e){return p.Text.isText(e)||p.Element.isElement(e)&&fe.includes(e.type)},pe=function(e){var t=window.scrollX,n=window.scrollY;E.ReactEditor.focus(e),te&&setTimeout((function(){window.scrollTo(t,n)}),0)};function Ee(e,t,n){a.toggleNodeType(e,t,n),p.Transforms.setNodes(e,{data:{}})}function ye(e){return function(t){var r,i=(r=$(void 0),a.usePlateEditorRef(r)),o=n.useCallback((function(){return i.tracking.onViewportAction("linkRendered")}),[i]);return n.createElement(e,Object.assign({},t,{onEntityFetchComplete:o}))}}function he(e){var n=e.sdk;return t.useMemo((function(){return n}),[])}var ve=y(he),ge=ve[0],Le=ve[1],Te={scheduleIcon:l.css({marginRight:T.spacing2Xs})};function Se(e){var n=e.entity,i=e.entityType,o=r.useEntities();return t.createElement(r.ScheduledIconWithTooltip,{getEntityScheduledActions:o.loadEntityScheduledActions,entityType:i,entityId:n.sys.id},t.createElement(L.ClockIcon,{className:Te.scheduleIcon,size:"small",color:"muted",testId:"schedule-icon"}))}var be={assetCard:l.css({cursor:"pointer"}),cardDropdown:l.css({width:"300px"}),truncated:l.css({overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"})};function Ne(e){var n=e.entityFile,r=g(n,"fileName"),o=g(n,"contentType"),a=g(n,"details.size"),l=g(n,"details.image");return[t.createElement(h.Menu.SectionTitle,{key:"file-section"},"File info"),r&&t.createElement(h.Menu.Item,{key:"file-name"},t.createElement(h.Text,{isTruncated:!0},r)),o&&t.createElement(h.Menu.Item,{key:"file-type"},t.createElement(h.Text,{isTruncated:!0},o)),a&&t.createElement(h.Menu.Item,{key:"file-size"},i.shortenStorageUnit(a,"B")),l&&t.createElement(h.Menu.Item,{key:"file-dimentions"},l.width+" × "+l.height)].filter((function(e){return e}))}function Ce(e){var n=e.entityFile,r=e.isDisabled,i=e.onEdit,o=e.onRemove;return[t.createElement(h.Menu.SectionTitle,{key:"section-title"},"Actions"),i?t.createElement(h.Menu.Item,{key:"edit",disabled:r,onClick:i,testId:"card-action-edit"},"Edit"):null,n?t.createElement(h.Menu.Item,{key:"download",onClick:function(){var e,t;"string"==typeof n.url&&(e=n.url,t=g(n,"fileName"),fetch(e,{method:"GET",headers:{}}).then((function(e){e.arrayBuffer().then((function(e){var n=window.URL.createObjectURL(new Blob([e])),r=document.createElement("a");r.href=n,r.setAttribute("download",t),document.body.appendChild(r),r.click(),document.body.removeChild(r)}))})).catch((function(e){h.Notification.error("Failed to download asset"),console.log(e)})))},testId:"card-action-download"},"Download"):null,o?t.createElement(h.Menu.Item,{key:"remove",disabled:r,onClick:o,testId:"card-action-remove"},"Remove"):null].filter((function(e){return e}))}function Ie(e){var n,o=r.useEntities(),a=o.getOrLoadAsset,l=o.assets[e.assetId],s=e.sdk.locales.default,c=null!=l&&null!=(n=l.fields)&&n.file?l.fields.file[e.locale]||l.fields.file[s]:void 0,u=e.onEntityFetchComplete;if(t.useEffect((function(){a(e.assetId)}),[e.assetId]),t.useEffect((function(){l&&(null==u||u())}),[l,u]),void 0===l)return t.createElement(h.AssetCard,{size:"small",isLoading:!0});if("failed"===l)return t.createElement(r.MissingEntityCard,{entityType:"Asset",isDisabled:e.isDisabled,onRemove:e.onRemove});var d=l?i.entityHelpers.getEntryStatus(l.sys):void 0;if("deleted"===d)return t.createElement(r.MissingEntityCard,{entityType:"Asset",asSquare:!0,isDisabled:e.isDisabled,onRemove:e.onRemove});var f,m,p=i.entityHelpers.getAssetTitle({asset:l,localeCode:e.locale,defaultLocaleCode:s,defaultTitle:"Untitled"});return t.createElement(h.AssetCard,{title:p,isSelected:e.isSelected,size:"small",src:null!=c&&c.url?c.url+"?h=300":"",type:(f={image:"image",video:"video",audio:"audio",richtext:"richtext",presentation:"presentation",spreadsheet:"spreadsheet",pdfdocument:"pdf",archive:"archive",plaintext:"plaintext",code:"code",markup:"markup"},m=f.archive,c&&f[v.getGroupLabel({type:c.contentType,fallbackFileName:c.fileName})]||m),status:d,icon:t.createElement(Se,{entityType:"Asset",entity:l}),className:be.assetCard,actions:[Ce({entityFile:c,isDisabled:e.isDisabled,onEdit:e.onEdit,onRemove:e.onRemove}),c?Ne({entityFile:c}):null].filter((function(e){return e}))})}var ke={entryCard:l.css({cursor:"pointer"})};function Ae(e){var n=e.file;return i.isValidImage(n)?t.createElement(r.AssetThumbnail,{file:n}):null}function Oe(e){var n=r.useEntities(),o=n.getOrLoadEntry,a=n.entries,l=n.getOrLoadAsset,s=t.useState(null),c=s[0],u=s[1],d=a[e.entryId],f=t.useMemo((function(){if(d&&"failed"!==d)return e.sdk.space.getCachedContentTypes().find((function(e){return e.sys.id===d.sys.contentType.sys.id}))}),[e.sdk,d]),m=e.sdk.locales.default,p=e.onEntityFetchComplete;if(t.useEffect((function(){if(d&&"failed"!==d){var t=!0;return i.entityHelpers.getEntryImage({entry:d,contentType:f,localeCode:e.locale,defaultLocaleCode:m},l).catch((function(){return null})).then((function(e){t&&u(e)})),function(){t=!1}}}),[d,f,e.locale,m,e.sdk,c,l]),t.useEffect((function(){o(e.entryId)}),[e.entryId]),t.useEffect((function(){d&&(null==p||p())}),[d,p]),void 0===d)return t.createElement(h.EntryCard,{size:"default",isLoading:!0});if("failed"===d)return t.createElement(r.MissingEntityCard,{entityType:"Entry",isDisabled:e.isDisabled,onRemove:e.onRemove});var E=d?i.entityHelpers.getEntryStatus(d.sys):void 0;if("deleted"===E)return t.createElement(r.MissingEntityCard,{entityType:"Entry",isDisabled:e.isDisabled,onRemove:e.onRemove});var y=i.entityHelpers.getEntryTitle({entry:d,contentType:f,localeCode:e.locale,defaultLocaleCode:m,defaultTitle:"Untitled"}),v=i.entityHelpers.getEntityDescription({entity:d,contentType:f,localeCode:e.locale,defaultLocaleCode:m});return t.createElement(h.EntryCard,{contentType:null==f?void 0:f.name,title:y,description:v,size:"default",isSelected:e.isSelected,status:E,className:ke.entryCard,thumbnailElement:c?t.createElement(Ae,{file:c}):void 0,icon:t.createElement(Se,{entityType:"Entry",entity:d}),withDragHandle:!1,actions:function(){if(e.onEdit&&e.onRemove)return[e.onEdit?t.createElement(h.MenuItem,{key:"edit",disabled:e.isDisabled,testId:"card-action-edit",onClick:function(){e.onEdit&&e.onEdit()}},"Edit"):null,e.onRemove?t.createElement(h.MenuItem,{key:"delete",disabled:e.isDisabled,testId:"card-action-remove",onClick:function(){e.onRemove&&e.onRemove()}},"Remove"):null].filter((function(e){return e}))}()})}var De={root:l.css({marginBottom:"1.25rem !important",display:"block"}),container:l.css({display:"inline-block",verticalAlign:"text-top"})};function Be(e){var t=e.attributes,r=e.children,i=e.element,o=e.onEntityFetchComplete,a=E.useSelected(),l=Z(),s=Le(),c=E.useReadOnly(),u=i.data.target.sys,d=u.id,f=u.linkType,m=function(){return("Asset"===f?s.navigator.openAsset:s.navigator.openEntry)(d,{slideIn:!0})},y=function(){if(l){var e=E.ReactEditor.findPath(l,i);p.Transforms.removeNodes(l,{at:e})}};return n.createElement("div",Object.assign({},t,{className:De.root,"data-entity-type":f,"data-entity-id":d,contentEditable:!!ee&&void 0,draggable:!ee||void 0}),n.createElement("div",{contentEditable:!ee&&void 0,draggable:!!ee||void 0,className:De.container},"Entry"===f&&n.createElement(Oe,{sdk:s,entryId:d,locale:s.field.locale,isDisabled:c,isSelected:a,onRemove:y,onEdit:m,onEntityFetchComplete:o}),"Asset"===f&&n.createElement(Ie,{sdk:s,assetId:d,locale:s.field.locale,isDisabled:c,isSelected:a,onRemove:y,onEdit:m,onEntityFetchComplete:o})),r)}function Re(e,t){return e(t={exports:{}},t.exports),t.exports}var we=Re((function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function s(e,t,n,r){var i=Object.create((t&&t.prototype instanceof d?t:d).prototype),o=new b(r||[]);return i._invoke=function(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var l=L(a,n);if(l){if(l===u)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var s=c(e,t,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===u)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}(e,n,o),i}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var u={};function d(){}function f(){}function m(){}var p={};l(p,i,(function(){return this}));var E=Object.getPrototypeOf,y=E&&E(E(N([])));y&&y!==t&&n.call(y,i)&&(p=y);var h=m.prototype=d.prototype=Object.create(p);function v(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){var r;this._invoke=function(i,o){function a(){return new t((function(r,a){!function r(i,o,a,l){var s=c(e[i],e,o);if("throw"!==s.type){var u=s.arg,d=u.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,a,l)}),(function(e){r("throw",e,a,l)})):t.resolve(d).then((function(e){u.value=e,a(u)}),(function(e){return r("throw",e,a,l)}))}l(s.arg)}(i,o,r,a)}))}return r=r?r.then(a,a):a()}}function L(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,L(e,t),"throw"===t.method))return u;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var r=c(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,u;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,u):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,u)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function b(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function N(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return f.prototype=m,l(h,"constructor",m),l(m,"constructor",f),f.displayName=l(m,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,l(e,a,"GeneratorFunction")),e.prototype=Object.create(h),e},e.awrap=function(e){return{__await:e}},v(g.prototype),l(g.prototype,o,(function(){return this})),e.AsyncIterator=g,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new g(s(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},v(h),l(h,a,"Generator"),l(h,i,(function(){return this})),l(h,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=N,b.prototype={constructor:b,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var l=n.call(o,"catchLoc"),s=n.call(o,"finallyLoc");if(l&&s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,u):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:N(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),u}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}));function xe(e,t){return b((function(e){return S(e,"nodes")}),(function(e){return g(e,["nodes",t])}),(function(e){return S(e,"linkContentType")}),(function(e){return g(e,"linkContentType",[])}))(e.validations)}function Ke(e,t){return{entityType:_e(t),locale:e.locale||null,contentTypes:xe(e,t)}}function _e(e){var t=e.split("-");if(-1!==t.indexOf("entry"))return"Entry";if(-1!==t.indexOf("asset"))return"Asset";throw new Error("RichText node type `"+e+"` has no associated `entityType`")}function Pe(e,t,n,r){return He.apply(this,arguments)}function He(){return(He=P(we.mark((function e(t,n,r,i){var o,a,l,s,c,u;return we.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i("openCreateEmbedDialog",{nodeType:t}),o=n.dialogs,a=Ke(n.field,t),l="Asset"===a.entityType?o.selectSingleAsset:o.selectSingleEntry,s=H({},a,{withCreate:!0}),c=r.selection,e.next=8,l(s);case 8:if(u=e.sent){e.next=12;break}return i("cancelCreateEmbedDialog",{nodeType:t}),e.abrupt("return");case 12:p.Transforms.select(r,c),Fe(r,t,u),Me(r),i("insert",{nodeType:t});case 16:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Me(e){var t=p.Editor.next(e);if(!t)return se(e);var n=p.Editor.above(e,{voids:!1,match:function(e){return!p.Element.isElement(e)||![o.BLOCKS.EMBEDDED_ASSET,o.BLOCKS.EMBEDDED_ENTRY].includes(e.type)}});if(p.Editor.isEditor(n))le(e);else{var r=p.Editor.above(e,{at:t[1],match:function(e){return p.Element.isElement(e)&&o.TEXT_CONTAINERS.includes(e.type)}});if(!r||!n||!p.Path.isChild(r[1],n[1]))return se(e);le(e)}}function Fe(e,t,n){if(null!=e&&e.selection){var r=function(e,t){return{type:e,data:{target:{sys:{id:t.sys.id,type:"Link",linkType:t.sys.type}}},children:[{text:""}],isVoid:!0}}(t,n);e.selection&&a.getText(e,e.selection.focus.path)?p.Transforms.insertNodes(e,r):p.Transforms.setNodes(e,r),pe(e)}}var ze,Ge=l.css({marginRight:"10px"});function je(e){var t=e.isButton,r=e.isDisabled,i=e.nodeType,o=e.onClose,a=Z(),l=Le(),s=function(){var e=P(we.mark((function e(t){return we.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),o(),e.next=4,Pe(i,l,a,a.tracking.onToolbarAction);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),c=function(e){var t=e.toLowerCase().split("-");if(t.includes("entry"))return"Entry";if(t.includes("asset"))return"Asset";throw new Error("Node type `"+e+"` has no associated `entityType`")}(i),u="rich-text__"+i;return t?n.createElement(h.Button,{isDisabled:r,className:u+"-button",size:"small",onClick:s,startIcon:n.createElement("Asset"===c?L.AssetIcon:L.EmbeddedEntryBlockIcon,null),variant:"secondary",testId:"toolbar-toggle-"+i},"Embed "+c.toLowerCase()):n.createElement(h.Menu.Item,{disabled:r,className:u+"-list-item",onClick:s,testId:"toolbar-toggle-"+i},n.createElement(h.Flex,{alignItems:"center",flexDirection:"row"},n.createElement(h.Icon,{as:"Asset"===c?L.AssetIcon:L.EmbeddedEntryBlockIcon,className:"rich-text__embedded-entry-list-icon "+Ge,variant:"secondary"}),n.createElement("span",null,c)))}var Ye=((ze={})[o.BLOCKS.EMBEDDED_ENTRY]="Entry",ze[o.BLOCKS.EMBEDDED_ASSET]="Asset",ze);function qe(e,t){return function(n,r){var i=r.options.hotkey;return function(r){var o=oe(n,e)[1];o?("Delete"===r.key||"Backspace"===r.key)&&(r.preventDefault(),p.Transforms.removeNodes(n,{at:o})):i&&m(i,r)&&Pe(e,t,n,n.tracking.onShortcutAction)}}}var Ue=function(e,t){return function(n){return{key:e,type:e,isElement:!0,isVoid:!0,component:ye(Be),options:{hotkey:t},handlers:{onKeyDown:qe(e,n)},deserializeHtml:{rules:[{validAttribute:{"data-entity-type":Ye[e]}}],withoutChildren:!0,getNode:function(t){return{type:e,children:[{text:""}],isVoid:!0,data:{target:{sys:{id:t.getAttribute("data-entity-id"),linkType:t.getAttribute("data-entity-type"),type:"Link"}}}}}}}}},Ve=Ue(o.BLOCKS.EMBEDDED_ENTRY,"mod+shift+e"),We=Ue(o.BLOCKS.EMBEDDED_ASSET,"mod+shift+a"),Qe=i.entityHelpers.getEntryTitle,Xe=i.entityHelpers.getEntryStatus,$e={scheduledIcon:l.css({verticalAlign:"text-bottom",marginRight:T.spacing2Xs})};function Ze(e){var t=r.useEntities(),i=t.getOrLoadEntry,a=t.loadEntityScheduledActions,l=t.entries,s=n.useMemo((function(){return l[e.entryId]}),[l,e.entryId]),c=e.sdk.space.getCachedContentTypes(),u=e.onEntityFetchComplete,d=n.useMemo((function(){if(s&&"failed"!==s&&c)return c.find((function(e){return e.sys.id===s.sys.contentType.sys.id}))}),[c,s]);n.useEffect((function(){s&&(null==u||u())}),[s,u]);var f=d?d.name:"",m=n.useMemo((function(){return Qe({entry:s,contentType:d,localeCode:e.sdk.field.locale,defaultLocaleCode:e.sdk.locales.default,defaultTitle:"Untitled"})}),[s,d,e.sdk.field.locale,e.sdk.locales.default]);if(n.useEffect((function(){e.entryId&&i(e.entryId)}),[e.entryId]),"failed"===s)return n.createElement(h.InlineEntryCard,{title:"Entry missing or inaccessible",testId:o.INLINES.EMBEDDED_ENTRY,isSelected:e.isSelected});if(void 0===s)return n.createElement(h.InlineEntryCard,{isLoading:!0});var p=Xe(s.sys);return"deleted"===p?n.createElement(h.InlineEntryCard,{title:"Entry missing or inaccessible",testId:o.INLINES.EMBEDDED_ENTRY,isSelected:e.isSelected,actions:[n.createElement(h.MenuItem,{key:"remove",onClick:e.onRemove,testId:"card-action-remove"},"Remove")]}):n.createElement(h.InlineEntryCard,{testId:o.INLINES.EMBEDDED_ENTRY,isSelected:e.isSelected,title:f+": "+m,status:p,actions:[n.createElement(h.MenuItem,{key:"edit",onClick:e.onEdit,disabled:e.isDisabled},"Edit"),n.createElement(h.MenuItem,{key:"remove",onClick:e.onRemove,disabled:e.isDisabled,testId:"card-action-remove"},"Remove")]},n.createElement(r.ScheduledIconWithTooltip,{getEntityScheduledActions:a,entityType:"Entry",entityId:s.sys.id},n.createElement(L.ClockIcon,{className:$e.scheduledIcon,variant:"muted",testId:"scheduled-icon"})),n.createElement(h.Text,null,m))}function Je(e){return{type:o.INLINES.EMBEDDED_ENTRY,children:[{text:""}],data:{target:{sys:{id:e,type:"Link",linkType:"Entry"}}}}}var et={icon:l.css({marginRight:"10px"}),root:l.css({display:"inline-block",margin:"0 "+T.spacing2Xs,fontSize:"inherit",span:{userSelect:"none"}})};function tt(e){var n=Z(),r=Le(),i=E.useSelected(),o=e.element.data.target.sys.id,a=E.useReadOnly();return t.createElement("span",Object.assign({},e.attributes,{className:et.root,"data-embedded-entity-inline-id":o,contentEditable:!!ee&&void 0,draggable:!ee||void 0}),t.createElement("span",{contentEditable:!ee&&void 0,draggable:!!ee||void 0},t.createElement(Ze,{sdk:r,entryId:o,isSelected:i,isDisabled:a,onRemove:function(){if(n){var t=E.ReactEditor.findPath(n,e.element);p.Transforms.removeNodes(n,{at:t})}},onEdit:function(){return r.navigator.openEntry(o,{slideIn:!0})},onEntityFetchComplete:e.onEntityFetchComplete})),e.children)}function nt(e,t,n){return rt.apply(this,arguments)}function rt(){return(rt=P(we.mark((function e(t,n,r){var i,a,l,s;return we.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r("openCreateEmbedDialog",{nodeType:o.INLINES.EMBEDDED_ENTRY}),i=H({},Ke(n.field,o.INLINES.EMBEDDED_ENTRY),{withCreate:!0}),a=t.selection,e.next=5,n.dialogs.selectSingleEntry(i);case 5:if(l=e.sent,pe(t),l){e.next=10;break}return r("cancelCreateEmbedDialog",{nodeType:o.INLINES.EMBEDDED_ENTRY}),e.abrupt("return");case 10:return s=Je(l.sys.id),r("insert",{nodeType:o.INLINES.EMBEDDED_ENTRY}),e.abrupt("return",new Promise((function(e){setTimeout((function(){p.Transforms.setSelection(t,a),p.Transforms.insertNodes(t,s),e()}),0)})));case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function it(e){var n=Z(),r=Le();function i(e){return a.apply(this,arguments)}function a(){return(a=P(we.mark((function t(i){return we.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i.preventDefault(),n){t.next=3;break}return t.abrupt("return");case 3:return e.onClose(),t.next=6,nt(n,r,n.tracking.onToolbarAction);case 6:le(n);case 7:case"end":return t.stop()}}),t)})))).apply(this,arguments)}return e.isButton?t.createElement(h.Button,{isDisabled:e.isDisabled,className:o.INLINES.EMBEDDED_ENTRY+"-button",size:"small",onClick:i,startIcon:t.createElement(L.EmbeddedEntryInlineIcon,null),variant:"secondary",testId:"toolbar-toggle-"+o.INLINES.EMBEDDED_ENTRY},"Embed inline entry"):t.createElement(h.Menu.Item,{disabled:e.isDisabled,className:"rich-text__entry-link-block-button",testId:"toolbar-toggle-"+o.INLINES.EMBEDDED_ENTRY,onClick:i},t.createElement(h.Flex,{alignItems:"center",flexDirection:"row"},t.createElement(L.EmbeddedEntryInlineIcon,{variant:"secondary",className:"rich-text__embedded-entry-list-icon "+et.icon}),t.createElement("span",null,"Inline entry")))}function ot(e){return{key:o.INLINES.EMBEDDED_ENTRY,type:o.INLINES.EMBEDDED_ENTRY,isElement:!0,isInline:!0,isVoid:!0,component:ye(tt),options:{hotkey:"mod+shift+2"},handlers:{onKeyDown:at(e)},deserializeHtml:{rules:[{validAttribute:"data-embedded-entity-inline-id"}],withoutChildren:!0,getNode:function(e){return Je(e.getAttribute("data-embedded-entity-inline-id"))}}}}function at(e){return function(t,n){var r=n.options.hotkey;return function(n){t&&r&&m(r,n)&&nt(t,e,t.tracking.onShortcutAction)}}}var lt,st,ct,ut,dt,ft,mt,pt,Et,yt,ht=[o.BLOCKS.DOCUMENT,o.BLOCKS.PARAGRAPH,"text"],vt=function(e,t,n){var r=function(e,t){return b((function(e){return S(e,t)}),(function(e){return g(e,t)}))(e.validations)}(e,t);return void 0===r||ht.concat(r).includes(n)},gt=function(e,t){return vt(e,"enabledNodeTypes",t)},Lt=function(e,t){return vt(e,"enabledMarks",t)},Tt={dropdown:(Et={root:l.css(lt||(lt=q(["\n font-weight: ",";\n "])),T.fontWeightDemiBold)},Et[o.BLOCKS.PARAGRAPH]=l.css(st||(st=q(["\n font-size: ",";\n "])),T.fontSizeL),Et[o.BLOCKS.HEADING_1]=l.css(ct||(ct=q(["\n font-size: 1.625rem;\n "]))),Et[o.BLOCKS.HEADING_2]=l.css(ut||(ut=q(["\n font-size: 1.4375rem;\n "]))),Et[o.BLOCKS.HEADING_3]=l.css(dt||(dt=q(["\n font-size: 1.25rem;\n "]))),Et[o.BLOCKS.HEADING_4]=l.css(ft||(ft=q(["\n font-size: 1.125rem;\n "]))),Et[o.BLOCKS.HEADING_5]=l.css(mt||(mt=q(["\n font-size: 1rem;\n "]))),Et[o.BLOCKS.HEADING_6]=l.css(pt||(pt=q(["\n font-size: 0.875rem;\n "]))),Et)},St=((yt={})[o.BLOCKS.PARAGRAPH]="Normal text",yt[o.BLOCKS.HEADING_1]="Heading 1",yt[o.BLOCKS.HEADING_2]="Heading 2",yt[o.BLOCKS.HEADING_3]="Heading 3",yt[o.BLOCKS.HEADING_4]="Heading 4",yt[o.BLOCKS.HEADING_5]="Heading 5",yt[o.BLOCKS.HEADING_6]="Heading 6",yt);function bt(e){var n=Le(),r=Z(),i=t.useState(!1),a=i[0],s=i[1],c=t.useState(o.BLOCKS.PARAGRAPH),u=c[0],d=c[1];t.useEffect((function(){if(null!=r&&r.selection){var e=function(e){return e.selection?Array.from(p.Editor.nodes(e,{at:e.selection,match:function(e){return p.Element.isElement(e)}})).flat():[]}(r)[0].type;d(St[e]?e:o.BLOCKS.PARAGRAPH)}}),[null==r?void 0:r.operations,null==r?void 0:r.selection]);var f=t.useMemo((function(){var e=Object.fromEntries(Object.keys(St).map((function(e){return[e,gt(n.field,e)]})));return[e,Object.values(e).filter(Boolean).length>0]}),[n.field]),m=f[0],E=f[1];return r?t.createElement(h.Menu,{isOpen:a,onClose:function(){return s(!1)}},t.createElement(h.Menu.Trigger,null,t.createElement(h.Button,{size:"small",testId:"toolbar-heading-toggle",variant:"transparent",endIcon:t.createElement(L.ChevronDownIcon,null),isDisabled:e.isDisabled,onClick:function(){return E&&s(!a)}},St[u])),t.createElement(h.Menu.List,{testId:"dropdown-heading-list"}," ",Object.keys(St).map((function(n){return m[n]&&t.createElement(h.Menu.Item,{key:n,isInitiallyFocused:u===n,onClick:(i=n,function(e){if(e.preventDefault(),null!=r&&r.selection){d(i),s(!1);var t=r.onChange;r.onChange=function(){pe(r),r.onChange=t,t.apply(void 0,arguments)};var n=re(r,i);r.tracking.onToolbarAction(n?"remove":"insert",{nodeType:i}),Ee(r,{activeType:i,inactiveType:i})}}),testId:"dropdown-option-"+n,disabled:e.isDisabled},t.createElement("span",{className:l.cx(Tt.dropdown.root,Tt.dropdown[n])},St[n]));var i})).filter(Boolean))):null}var Nt,Ct,It,kt,At,Ot,Dt,Bt,Rt,wt,xt,Kt,_t,Pt,Ht,Mt,Ft,zt,Gt=function(e,t){p.Transforms.removeNodes(e,{at:t[1]})},jt=function(e,t){var n=t[1],r=function(e,t){return function(e,t,n){return Array.from(a.getNodes(e,{match:{type:o.TEXT_CONTAINERS},at:t,mode:"lowest"})).map((function(e){return e[0]}))}(e,t).map((function(e){return H({},e,{type:o.BLOCKS.PARAGRAPH})}))}(e,n);Gt(e,t),p.Transforms.insertNodes(e,r,{at:n})},Yt=function(e,t){p.Transforms.unwrapNodes(e,{at:t[1]})},qt=function(e){return function(t,n){p.Transforms.wrapNodes(t,{type:e,data:{},children:[]},{at:n[1]})}},Ut=function(e,t){p.Transforms.liftNodes(e,{at:t[1]})},Vt={dropdown:(Rt={root:l.css(Nt||(Nt=q(["\n font-weight: ",";\n "])),T.fontWeightDemiBold)},Rt[o.BLOCKS.PARAGRAPH]=l.css(Ct||(Ct=q(["\n font-size: ",";\n "])),T.fontSizeL),Rt[o.BLOCKS.HEADING_1]=l.css(It||(It=q(["\n font-size: 1.625rem;\n "]))),Rt[o.BLOCKS.HEADING_2]=l.css(kt||(kt=q(["\n font-size: 1.4375rem;\n "]))),Rt[o.BLOCKS.HEADING_3]=l.css(At||(At=q(["\n font-size: 1.25rem;\n "]))),Rt[o.BLOCKS.HEADING_4]=l.css(Ot||(Ot=q(["\n font-size: 1.125rem;\n "]))),Rt[o.BLOCKS.HEADING_5]=l.css(Dt||(Dt=q(["\n font-size: 1rem;\n "]))),Rt[o.BLOCKS.HEADING_6]=l.css(Bt||(Bt=q(["\n font-size: 0.875rem;\n "]))),Rt),headings:(Ft={root:l.css(wt||(wt=q(["\n font-weight: ",";\n line-height: 1.3;\n margin: 0 0 ",";\n "])),T.fontWeightMedium,T.spacingS)},Ft[o.BLOCKS.HEADING_1]=l.css(xt||(xt=q(["\n font-size: 1.875rem;\n "]))),Ft[o.BLOCKS.HEADING_2]=l.css(Kt||(Kt=q(["\n font-size: 1.5625rem;\n "]))),Ft[o.BLOCKS.HEADING_3]=l.css(_t||(_t=q(["\n font-size: 1.375rem;\n "]))),Ft[o.BLOCKS.HEADING_4]=l.css(Pt||(Pt=q(["\n font-size: 1.25rem;\n "]))),Ft[o.BLOCKS.HEADING_5]=l.css(Ht||(Ht=q(["\n font-size: 1.125rem;\n "]))),Ft[o.BLOCKS.HEADING_6]=l.css(Mt||(Mt=q(["\n font-size: 1rem;\n "]))),Ft)};function Wt(e,n){return function(r){return t.createElement(e,Object.assign({},r.attributes,{className:l.cx(Vt.headings.root,Vt.headings[n])}),r.children)}}var Qt,Xt,$t,Zt=((zt={})[o.BLOCKS.HEADING_1]=t.memo(Wt("h1",o.BLOCKS.HEADING_1)),zt[o.BLOCKS.HEADING_2]=t.memo(Wt("h2",o.BLOCKS.HEADING_2)),zt[o.BLOCKS.HEADING_3]=t.memo(Wt("h3",o.BLOCKS.HEADING_3)),zt[o.BLOCKS.HEADING_4]=t.memo(Wt("h4",o.BLOCKS.HEADING_4)),zt[o.BLOCKS.HEADING_5]=t.memo(Wt("h5",o.BLOCKS.HEADING_5)),zt[o.BLOCKS.HEADING_6]=t.memo(Wt("h6",o.BLOCKS.HEADING_6)),zt),Jt=function(){var e;return{key:"HeadingPlugin",softBreak:[{hotkey:"shift+enter",query:{allow:o.HEADINGS}}],normalizer:[{match:{type:o.HEADINGS},validChildren:function(e,t){return me(t[0])},transform:(e={},e[o.BLOCKS.PARAGRAPH]=Yt,e.default=Ut,e)}],then:function(e){return{exitBreak:[{hotkey:"enter",query:{allow:o.HEADINGS,end:!0,start:!0,filter:function(t){return!a.getAbove(e,{at:t[1],match:{type:o.BLOCKS.LIST_ITEM}})}}}]}},plugins:o.HEADINGS.map((function(e,t){var n,r=t+1;return{key:e,type:e,isElement:!0,component:Zt[e],options:{hotkey:["mod+alt+"+r]},handlers:{onKeyDown:(n=e,function(e,t){var r=t.options.hotkey;return function(t){if(e.selection&&r&&m(r,t)){var i=re(e,n);e.tracking.onShortcutAction(i?"remove":"insert",{nodeType:n}),Ee(e,{activeType:n,inactiveType:o.BLOCKS.PARAGRAPH})}}})},deserializeHtml:{rules:[{validNodeName:("h"+r).toUpperCase()}]}}}))}},en={button:l.css({height:"30px",width:"30px",marginLeft:T.spacing2Xs,marginRight:T.spacing2Xs}),tooltip:l.css({zIndex:Number(T.zIndexTooltip)})};function tn(e){var t=e.title,r=e.testId,i=e.isActive,o=e.children,a=e.isDisabled,s=void 0!==a&&a,c=n.createElement(h.Button,{className:l.cx(en.button,e.className),isDisabled:s,startIcon:o,onClick:function(t){t.preventDefault(),e.onClick()},testId:r,variant:i?"secondary":"transparent",size:"small"});return t?n.createElement(h.Tooltip,{className:en.tooltip,placement:"bottom",content:t},c):c}var nn={container:l.css(Qt||(Qt=q(["\n margin: 0 0 ",";\n "])),T.spacingL),hr:l.css(Xt||(Xt=q(["\n margin: 0;\n height: ",";\n background: transparent;\n position: relative;\n border: 0;\n user-select: none;\n &:hover {\n cursor: pointer;\n }\n &::after {\n content: '';\n position: absolute;\n width: 100%;\n height: 1px;\n background: ",";\n top: 50%;\n }\n "])),T.spacingM,T.gray300),hrSelected:l.css($t||($t=q(["\n &::after {\n background: ",";\n -webkit-box-shadow: 0px 0px 5px ",";\n box-shadow: 0px 0px 5px ",";\n }\n "])),T.colorPrimary,T.colorPrimary,T.colorPrimary)};function rn(e){return function(t){if(e){var n=oe(e,o.BLOCKS.HR)[1];n&&("Backspace"===t.key||"Delete"===t.key)&&(t.preventDefault(),p.Transforms.removeNodes(e,{at:n}))}}}function on(e){var n=Z();return n?t.createElement(tn,{title:"HR",isDisabled:e.isDisabled,onClick:function(){if(null!=n&&n.selection){var e={type:o.BLOCKS.HR,data:{},children:[{text:""}],isVoid:!0};a.getText(n,n.selection.focus.path)?p.Transforms.insertNodes(n,e):a.setNodes(n,e),function(e){p.Transforms.move(e,{distance:1,unit:"line"})}(n),pe(n)}},testId:"hr-toolbar-button",isActive:re(n,o.BLOCKS.HR)},t.createElement(L.HorizontalRuleIcon,null)):null}function an(e){var n=E.useSelected(),r=E.useFocused();return t.createElement("div",Object.assign({},e.attributes,{className:nn.container,"data-void-element":o.BLOCKS.HR}),t.createElement("div",{draggable:!0,contentEditable:!1},t.createElement("hr",{className:l.cx(nn.hr,n&&r?nn.hrSelected:void 0)})),e.children)}var ln,sn,cn,un={removeSelectionLabel:l.css(ln||(ln=q(["\n margin-left: ",";\n "])),T.spacingS)},dn=((sn={})[o.INLINES.ENTRY_HYPERLINK]="Entry",sn[o.INLINES.ASSET_HYPERLINK]="Asset",sn),fn=((cn={})[o.INLINES.HYPERLINK]="URL",cn[o.INLINES.ENTRY_HYPERLINK]="Entry",cn[o.INLINES.ASSET_HYPERLINK]="Asset",cn);function mn(e){var n,i,a,l,s=ne.filter((function(t){return gt(e.sdk.field,t)})),c=s[0],u=t.useState(null!=(n=e.linkText)?n:""),d=u[0],f=u[1],m=t.useState(null!=(i=e.linkType)?i:c),p=m[0],E=m[1],y=t.useState(null!=(a=e.linkTarget)?a:""),v=y[0],g=y[1],L=t.useState(null!=(l=e.linkEntity)?l:null),T=L[0],S=L[1];function b(e){var t=e.sys;return{sys:{id:t.id,type:"Link",linkType:t.type}}}function N(){return(N=P(we.mark((function t(){var n,r;return we.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={locale:e.sdk.field.locale,contentTypes:xe(e.sdk.field,o.INLINES.ENTRY_HYPERLINK)},t.next=3,e.sdk.dialogs.selectSingleEntry(n);case 3:r=t.sent,g(""),S(b(r));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function C(){return(C=P(we.mark((function t(){var n,r;return we.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={locale:e.sdk.field.locale},t.next=3,e.sdk.dialogs.selectSingleAsset(n);case 3:r=t.sent,g(""),S(b(r));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}return t.createElement(r.EntityProvider,{sdk:e.sdk},t.createElement(t.Fragment,null,t.createElement(h.ModalContent,null,t.createElement(h.Form,null,!e.linkType&&t.createElement(h.FormControl,{id:"link-text",isRequired:!0},t.createElement(h.FormControl.Label,null,"Link text"),t.createElement(h.TextInput,{testId:"link-text-input",name:"link-text",value:d,onChange:function(e){return f(e.target.value)}})),s.length>1&&t.createElement(h.FormControl,{id:"link-type"},t.createElement(h.FormControl.Label,null,"Link type"),t.createElement(h.Select,{value:p,onChange:function(e){return E(e.target.value)},testId:"link-type-input"},s.map((function(e){return t.createElement(h.Select.Option,{key:e,value:e},fn[e])})))),p===o.INLINES.HYPERLINK&&t.createElement(h.FormControl,{id:"linkTarget",isRequired:!0},t.createElement(h.FormControl.Label,null,"Link target"),t.createElement(h.TextInput,{name:"linkTarget",value:v,onChange:function(e){S(null),g(e.target.value)},testId:"link-target-input"}),t.createElement(h.FormControl.HelpText,null,"A protocol may be required, e.g. https://")),p!==o.INLINES.HYPERLINK&&t.createElement("div",null,t.createElement(h.FormLabel,{isRequired:!0,htmlFor:""},"Link target"," "),T&&T.sys.linkType===dn[p]?t.createElement(t.Fragment,null,t.createElement(h.TextLink,{testId:"entity-selection-link",onClick:function(e){e.preventDefault(),S(null)},className:un.removeSelectionLabel},"Remove selection"),t.createElement("div",null,p===o.INLINES.ENTRY_HYPERLINK&&t.createElement(Oe,{sdk:e.sdk,locale:e.sdk.field.locale,entryId:T.sys.id,isDisabled:!0,isSelected:!1}),p===o.INLINES.ASSET_HYPERLINK&&t.createElement(Ie,{sdk:e.sdk,locale:e.sdk.field.locale,assetId:T.sys.id,isDisabled:!0,isSelected:!1}))):t.createElement("div",null,p===o.INLINES.ENTRY_HYPERLINK&&t.createElement(h.TextLink,{testId:"entity-selection-link",onClick:function(){return N.apply(this,arguments)}},"Select entry"),p===o.INLINES.ASSET_HYPERLINK&&t.createElement(h.TextLink,{testId:"entity-selection-link",onClick:function(){return C.apply(this,arguments)}},"Select asset"))))),t.createElement(h.ModalControls,null,t.createElement(h.Button,{type:"button",onClick:function(){return e.onClose(null)},variant:"secondary",testId:"cancel-cta",size:"small"},"Cancel"),t.createElement(h.Button,{type:"submit",variant:"positive",size:"small",isDisabled:!(p===o.INLINES.HYPERLINK?d&&v:Object.keys(dn).includes(p)&&d&&T),onClick:function(t){t.preventDefault(),e.onClose({linkText:d,linkType:p,linkTarget:v,linkEntity:T})},testId:"confirm-cta"},e.linkType?"Update":"Insert"))))}function pn(e,t,n,r){return En.apply(this,arguments)}function En(){return(En=P(we.mark((function e(n,r,o,a){var l,s,c,u,d,f,m,E,y,h,v,g,L,T,S,b,N;return we.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=n.selection?H({},n.selection):void 0,a||s){e.next=3;break}return e.abrupt("return");case 3:return m=oe(n,ne,a),y=m[1],(E=m[0])&&y&&(c=E.type,u=p.Editor.string(n,y),d=E.data.uri||"",f=E.data.target),h=null!=a?a:s,v=u||(n.selection?p.Editor.string(n,n.selection):""),g=Boolean(E&&y),o(g?"openEditHyperlinkDialog":"openCreateHyperlinkDialog"),e.next=11,i.ModalDialogLauncher.openDialog({title:g?"Edit hyperlink":"Insert hyperlink",width:"large",shouldCloseOnEscapePress:!0,shouldCloseOnOverlayClick:!0,allowHeightOverflow:!0},(function(e){return t.createElement(mn,{linkTarget:d,linkText:v,linkType:c,linkEntity:f,onClose:e.onClose,sdk:r})}));case 11:if(L=e.sent,p.Transforms.select(n,h),L){e.next=17;break}return pe(n),o(g?"cancelEditHyperlinkDialog":"cancelCreateHyperlinkDialog"),e.abrupt("return");case 17:T=L.linkText,S=L.linkTarget,b=L.linkType,N=L.linkEntity,p.Editor.withoutNormalizing(n,(function(){ce(n,{text:T,url:S,type:b,target:N,path:y})})),o(g?"edit":"insert",{nodeType:b,linkType:null!=(l=null==N?void 0:N.sys.linkType)?l:"uri"}),pe(n);case 21:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function yn(e){var n=Z(),r=!(!n||!ue(n)),i=Le();function o(){return(o=P(we.mark((function e(){return we.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}return e.abrupt("return");case 2:r?(de(n),n.tracking.onToolbarAction("unlinkHyperlinks")):pn(n,i,n.tracking.onToolbarAction);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return n?t.createElement(tn,{title:"Hyperlink",testId:"hyperlink-toolbar-button",onClick:function(){return o.apply(this,arguments)},isActive:r,isDisabled:e.isDisabled},t.createElement(L.LinkIcon,null)):null}var hn=function(e,t){var n=t[0];return!a.isAncestorEmpty(e,n)&&""!==p.Node.string(n).trim()};function vn(){return(vn=P(we.mark((function e(t){var n,r,o,a,l,s,c,u,d,f,m,p,E;return we.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.sdk,r=t.entityId,a=t.localeCode,l=t.defaultLocaleCode,c="Entry"===(o=t.entityType)?n.space.getEntry:n.space.getAsset,e.next=4,c(r);case 4:return(u=e.sent).sys.contentType&&(d=u.sys.contentType.sys.id,s=n.space.getCachedContentTypes().find((function(e){return e.sys.id===d}))),f="Entry"===o?i.entityHelpers.getEntryTitle({entry:u,contentType:s,localeCode:a,defaultLocaleCode:l,defaultTitle:"Untitled"}):i.entityHelpers.getAssetTitle({asset:u,localeCode:a,defaultLocaleCode:l,defaultTitle:"Untitled"}),m=i.entityHelpers.getEntityDescription({entity:u,contentType:s,localeCode:a,defaultLocaleCode:l}),e.next=10,n.space.getEntityScheduledActions(o,r);case 10:return p=e.sent,E=i.entityHelpers.getEntryStatus(u.sys),e.abrupt("return",{jobs:p,entity:u,entityTitle:f,entityDescription:m,entityStatus:E,contentTypeName:s?s.name:""});case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var gn={hyperlinkWrapper:l.css({display:"inline",position:"static",a:{fontSize:"inherit !important"}}),hyperlink:l.css({fontSize:"inherit !important",display:"inline !important","&:hover":{fill:T.gray900},"&:focus":{fill:T.gray900}})};function Ln(e){var n=Z(),i=E.useReadOnly(),o=Le(),a=e.element.data.target,l=function(e){var n,i,o,a,l,s,c,u=(i=(n=e).sdk,o=n.target,a=n.onEntityFetchComplete,s=(l=t.useState({type:"loading"}))[0],c=l[1],t.useEffect((function(){var e,t;o&&function(e){return vn.apply(this,arguments)}({sdk:i,entityId:null==o||null==(e=o.sys)?void 0:e.id,entityType:null==o||null==(t=o.sys)?void 0:t.linkType,localeCode:i.field.locale,defaultLocaleCode:i.locales.default}).then((function(e){c({type:"success",data:e})})).catch((function(e){console.log(e),c({type:"error",error:e})})).finally((function(){null==a||a()}))}),[i,o,a]),s),d=e.target.sys.linkType;return"loading"===u.type?"Loading "+d.toLowerCase()+"...":"error"===u.type?d+" missing or inaccessible":function(e){if(!e)return"";var t,n=e.entityStatus,i=e.jobs;return(e.contentTypeName||"Asset")+' "'+(("string"==typeof(t=e.entityTitle)&&t.length>60?t&&t.substr(0,61).replace(/(\s+\S(?=\S)|\s*)\.?.$/,"…"):t)||"Untitled")+'", '+n+" "+(i.length>0?r.getScheduleTooltipContent({job:i[0],jobsCount:i.length}):"")}(u.data)}({target:a,sdk:o,onEntityFetchComplete:e.onEntityFetchComplete});return a?t.createElement(h.Tooltip,{content:l,targetWrapperClassName:gn.hyperlinkWrapper,placement:"bottom",maxWidth:"auto"},t.createElement(h.TextLink,{as:"a",onClick:function(e){if(e.preventDefault(),e.stopPropagation(),n){var t=E.ReactEditor.toSlatePoint(n,[e.target,0],{exactMatch:!1,suppressThrow:!1});pn(n,o,n.tracking.onViewportAction,t.path)}},isDisabled:i,className:gn.hyperlink,"data-link-type":a.sys.linkType,"data-link-id":a.sys.id},e.children)):null}function Tn(e){var n=Z(),r=E.useReadOnly(),i=Le(),o=e.element.data.uri;return t.createElement(h.Tooltip,{content:o,targetWrapperClassName:gn.hyperlinkWrapper,placement:"bottom",maxWidth:"auto"},t.createElement(h.TextLink,{as:"a",href:o,rel:"noopener noreferrer",onClick:function(e){if(e.preventDefault(),e.stopPropagation(),n){var t=E.ReactEditor.toSlatePoint(n,[e.target,0],{exactMatch:!1,suppressThrow:!1});pn(n,i,n.tracking.onViewportAction,t.path)}},isDisabled:r,className:gn.hyperlink},e.children))}var Sn,bn,Nn,Cn,In=function(e){return"A"===e.nodeName&&"Entry"===e.getAttribute("data-link-type")},kn=function(e){return"A"===e.nodeName&&"Asset"===e.getAttribute("data-link-type")},An=function(e){return function(t,n){var r=n.options.hotkey;return function(n){t.selection&&(r&&!m(r,n)||(ue(t)?(de(t),t.tracking.onShortcutAction("unlinkHyperlinks")):pn(t,e,t.tracking.onShortcutAction)))}}},On=function(e){return function(t,n){return{type:e,children:n.children,data:e===o.INLINES.HYPERLINK?{uri:t.getAttribute("href")}:{target:{sys:{id:t.getAttribute("data-link-id"),linkType:t.getAttribute("data-link-type"),type:"Link"}}}}}},Dn=function(e){var t={isElement:!0,isInline:!0};return{key:"HyperlinkPlugin",options:{hotkey:"mod+k"},handlers:{onKeyDown:An(e)},plugins:[H({},t,{key:o.INLINES.HYPERLINK,type:o.INLINES.HYPERLINK,component:Tn,deserializeHtml:{rules:[{validNodeName:["A"]}],query:function(e){return!("A"!==(t=e).nodeName||!t.getAttribute("href")||"#"===t.getAttribute("href")||In(e)||kn(e));var t},getNode:On(o.INLINES.HYPERLINK)}}),H({},t,{key:o.INLINES.ENTRY_HYPERLINK,type:o.INLINES.ENTRY_HYPERLINK,component:ye(Ln),deserializeHtml:{rules:[{validNodeName:["A"]}],query:function(e){return In(e)},getNode:On(o.INLINES.ENTRY_HYPERLINK)}}),H({},t,{key:o.INLINES.ASSET_HYPERLINK,type:o.INLINES.ASSET_HYPERLINK,component:ye(Ln),deserializeHtml:{rules:[{validNodeName:["A"]}],query:function(e){return kn(e)},getNode:On(o.INLINES.ASSET_HYPERLINK)}})],normalizer:[{match:{type:[o.INLINES.HYPERLINK,o.INLINES.ASSET_HYPERLINK,o.INLINES.ENTRY_HYPERLINK]},validNode:hn,transform:Gt}]}},Bn=l.css(Sn||(Sn=q(["\n padding: 0;\n margin: 0 0 1.25rem 1.25rem;\n\n div:first-child {\n margin: 0;\n line-height: ",";\n }\n"])),T.lineHeightDefault),Rn=((Cn={})[o.BLOCKS.UL_LIST]=l.css(bn||(bn=q(["\n list-style-type: disc;\n ul {\n list-style-type: circle;\n ul {\n list-style-type: square;\n }\n }\n "]))),Cn[o.BLOCKS.OL_LIST]=l.css(Nn||(Nn=q(["\n list-style-type: decimal;\n ol {\n list-style-type: upper-alpha;\n ol {\n list-style-type: lower-roman;\n ol {\n list-style-type: lower-alpha;\n }\n }\n }\n "]))),Cn);function wn(e,n){return function(r){return t.createElement(e,Object.assign({},r.attributes,{className:l.cx(Bn,Rn[n])}),r.children)}}var xn,Kn=wn("ul",o.BLOCKS.UL_LIST),_n=wn("ol",o.BLOCKS.OL_LIST),Pn=l.css(xn||(xn=q(["\n margin: 0;\n list-style: inherit;\n margin-top: ",";\n\n ol,\n ul {\n margin: 0 0 0 ",";\n }\n"])),T.spacingXs,T.spacingL);function Hn(e){return t.createElement("li",Object.assign({},e.attributes,{className:Pn}),e.children)}function Mn(e,t){return p.Editor.nodes(e,{at:t,match:function(e,t){return p.Element.isElement(e)&&e.type===o.BLOCKS.LIST_ITEM&&t.length>=2}}).next().done}var Fn=function(e,t){var n=(void 0===t?{}:t).at;p.Editor.withoutNormalizing(e,(function(){do{p.Transforms.liftNodes(e,{at:n,match:function(e){return p.Element.isElement(e)&&e.type===o.BLOCKS.LIST_ITEM},mode:"lowest"})}while(!Mn(e,n));a.unwrapNodes(e,{at:n,match:{type:o.BLOCKS.LIST_ITEM},split:!1})}))},zn=[o.BLOCKS.UL_LIST,o.BLOCKS.OL_LIST],Gn=function(e,t){var n=t.type;return p.Editor.withoutNormalizing(e,(function(){if(e.selection)if(a.isCollapsed(e.selection)||!a.isRangeAcrossBlocks(e)){var t=N.getListItemEntry(e);if(t)t.list[0].type!==n?a.setNodes(e,{type:n},{at:e.selection,match:function(e){return zn.includes(e.type)},mode:"lowest"}):Fn(e);else{a.wrapNodes(e,{type:n,children:[],data:{}});for(var r,i=[].concat(a.getNodes(e,{match:{type:a.getPluginType(e,a.ELEMENT_DEFAULT)}})),l={type:o.BLOCKS.LIST_ITEM,children:[],data:{}},s=V(i);!(r=s()).done;)a.wrapNodes(e,l,{at:r.value[1]})}}else{var c=p.Range.edges(e.selection),u=p.Node.common(e,c[0].path,c[1].path);if(zn.includes(u[0].type)||u[0].type===o.BLOCKS.LIST_ITEM){var d=u[0].type;if(u[0].type===o.BLOCKS.LIST_ITEM&&(d=p.Editor.parent(e,u[1])[0].type),d!==n){var f=a.findNode(e,{at:p.Range.start(e.selection),match:{type:zn},mode:"lowest"}),m=a.findNode(e,{at:p.Range.end(e.selection),match:{type:zn},mode:"lowest"});if(!f||!m)return;var E=Math.min(f[1].length,m[1].length);a.setNodes(e,{type:n},{at:e.selection,match:function(e,t){return zn.includes(e.type)&&t.length>=E},mode:"all"})}else Fn(e)}else{var y=u[1].length;Array.from(a.getNodes(e,{mode:"all"})).filter((function(e){return e[1].length===y+1})).reverse().forEach((function(t){zn.includes(t[0].type)?a.setNodes(e,{type:n},{at:t[1]}):(a.setNodes(e,{type:a.getPluginType(e,N.ELEMENT_LIC)},{at:t[1]}),a.wrapNodes(e,{type:o.BLOCKS.LIST_ITEM,children:[],data:{}},{at:t[1]}),a.wrapNodes(e,{type:n,children:[],data:{}},{at:t[1]}))}))}}}))},jn=function(e,t){var n=t.type,r=t.options.hotkey;return function(t){if("Tab"===t.key&&e.selection&&a.getAbove(e,{at:e.selection,match:{type:n}}))return t.preventDefault(),void function(e,t){var n,r=void 0===t?{}:t,i=r.increase,o=void 0===i||i,l=r.at,s=void 0===l?null!=(n=e.selection)?n:void 0:l,c=a.getNodes(e,{at:s,match:{type:a.getPluginType(e,N.ELEMENT_LIC)}}),u=Array.from(c);if(u.length){var d=[],f=[];u.forEach((function(t){var n=t[1],r=p.Path.parent(n);d.some((function(e){var t=p.Path.parent(e);return p.Path.isAncestor(t,r)}))||(d.push(n),f.push(p.Editor.pathRef(e,n)))}));var m=o?f:f.reverse();p.Editor.withoutNormalizing(e,(function(){m.forEach((function(t){var n=t.unref();if(n){var r=N.getListItemEntry(e,{at:n});r&&(o?function(e,t){var n,r=t.list[0],i=t.listItem[1];try{n=p.Path.previous(i)}catch(e){return}var o=p.Editor.node(e,n);if(o){var l=Array.from(p.Node.children(e,o[1])).find((function(t){return a.match(t[0],{type:N.getListTypes(e)})})),s=p.Path.next(a.getLastChildPath(null!=l?l:o));p.Editor.withoutNormalizing(e,(function(){l||a.wrapNodes(e,{type:r.type,children:[],data:{}},{at:i}),p.Transforms.moveNodes(e,{at:i,to:s})}))}}(e,r):N.isListNested(e,r.list[1])&&N.moveListItemUp(e,r))}}))}))}}(e,{increase:!t.shiftKey});if(r)for(var i,o=V(C(r));!(i=o()).done;)m(i.value)(t)&&Gn(e,{type:n})}},Yn=function(e){return[o.BLOCKS.OL_LIST,o.BLOCKS.UL_LIST].includes(e.type)},qn=function(e,t){var n=a.getParent(e,t[1])||[];return Yn(n[0])},Un=function(e,t){var n=t[1],r=function(e,t){return a.getAbove(e,{at:t,mode:"lowest",match:Yn})||[]}(e,n)[0];p.Transforms.wrapNodes(e,{type:(null==r?void 0:r.type)||o.BLOCKS.UL_LIST,children:[],data:{}},{at:n})},Vn=function(e,t){return 0!==Array.from(p.Node.children(e,t[1])).length},Wn=function(e,t){var n=t[0];if(1===n.children.length){var r=n.children[0];return!p.Text.isText(r)&&!Yn(r)}return!0},Qn=function(e,t){p.Transforms.insertNodes(e,[{type:o.BLOCKS.PARAGRAPH,data:{},children:[{text:""}]}],{at:t[1].concat([0])})},Xn=function(e,t){var n=t[0],r=t[1];p.Transforms.removeNodes(e,{at:r}),p.Transforms.insertNodes(e,n.children[0].children,{at:r})},$n=function(e,t){var n=e.selection;if(!n)return!1;if(p.Range.isExpanded(n)){var r=p.Range.edges(n);if(p.Node.common(e,r[0].path,r[1].path)[0].type===t)return!0}var i=a.getBlockAbove(e,{match:{type:[o.BLOCKS.OL_LIST,o.BLOCKS.UL_LIST]},mode:"lowest"});return(null==i?void 0:i[0].type)===t},Zn=function(e){return[o.BLOCKS.UL_LIST,o.BLOCKS.OL_LIST].includes(e.type)},Jn=o.LIST_ITEM_BLOCKS,er=function(e){var t=e.deleteBackward,n=e.deleteForward,r=e.deleteFragment;return e.deleteBackward=function(n){(function(e,t){var n=N.getListItemEntry(e,{}),r=!1;if(n){var i=n.list,l=n.listItem;a.isSelectionAtBlockStart(e,{match:function(e){return e.type===o.BLOCKS.LIST_ITEM}})&&p.Editor.withoutNormalizing(e,(function(){if(!(r=N.removeFirstListItem(e,{list:i,listItem:l}))&&!(r=N.removeListItem(e,{list:i,listItem:l}))){if(a.isFirstChild(l[1])&&!N.isListNested(e,i[1]))return f.onKeyDownResetNode(e,a.mockPlugin({options:{rules:[{types:[o.BLOCKS.LIST_ITEM],defaultType:o.BLOCKS.PARAGRAPH,hotkey:"backspace",predicate:function(){return a.isSelectionAtBlockStart(e)},onReset:function(e){return Fn(e)}}]}}))(f.SIMULATE_BACKSPACE),void(r=!0);a.deleteFragment(e,{unit:t,reverse:!0}),r=!0}}))}return r})(e,n)||t(n)},e.deleteForward=function(t){N.deleteForwardList(e)||n(t)},e.deleteFragment=function(){N.deleteFragmentList(e)||r()},e.insertBreak=function(e){var t=e.insertBreak;return function(){(function(e){if(!e.selection)return!1;var t,n=N.getListItemEntry(e,{});if(n){var r=n.list,i=n.listItem,l=i[0].children[0];if(a.isBlockAboveEmpty(e)&&1===i[0].children.length&&o.TEXT_CONTAINERS.includes(l.type)&&(t=N.moveListItemUp(e,{list:r,listItem:i})))return!0}return!!f.onKeyDownResetNode(e,a.mockPlugin({options:{rules:[{types:[a.getPluginType(e,N.ELEMENT_LI)],defaultType:a.getPluginType(e,a.ELEMENT_DEFAULT),predicate:function(){return!t&&a.isBlockAboveEmpty(e)},onReset:function(e){return N.unwrapList(e)}}]}}))(f.SIMULATE_BACKSPACE)||!(t||!function(e){if(!e.selection)return!1;var t=a.getAbove(e,{match:{type:o.TEXT_CONTAINERS}});if(!t)return!1;var n=t[1],r=a.getParent(e,n);if(!r)return!1;var i=r[1];return r[0].type===o.BLOCKS.LIST_ITEM&&(p.Editor.withoutNormalizing(e,(function(){if(e.selection){var t=a.isSelectionAtBlockStart(e),r=a.isSelectionAtBlockEnd(e),l=t&&a.isFirstChild(n),s=!t&&!r;s&&p.Transforms.splitNodes(e);var c=l?i:p.Path.next(i);a.insertNodes(e,function(e,t){void 0===t&&(t=!1);var n=[];if(t){var r=p.Editor.marks(e)||{};n=[{type:o.BLOCKS.PARAGRAPH,data:{},children:[H({text:""},r)]}]}return{type:o.BLOCKS.LIST_ITEM,data:{},children:n}}(e,!s),{at:c});var u=t?n:p.Path.next(n),d=u[u.length-1]||0,f=c.concat([s?0:1]);l||a.moveChildren(e,{at:i,to:f,fromStartIndex:d}),p.Transforms.select(e,c),p.Transforms.collapse(e,{edge:"start"})}})),!0)}(e))})(e)||t()}}(e),e.insertFragment=function(e){var t=e.insertFragment;return function(n){if(e.selection){if(a.findNode(e,{match:{type:o.BLOCKS.LIST_ITEM},mode:"lowest"})){var r=function(e){var t=e[0];return o.TEXT_CONTAINERS.includes(t.type)?[].concat(t.children,e.slice(1)):e}(function(e){if(1!==e.length)return e;var t=e[0];return t.type!==o.BLOCKS.LIST_ITEM||1!==t.children.length?e:t.children}(n.flatMap((function(e){return function(e){if(!Zn(e))return[e];var t=Array.from(p.Node.texts(e)),n=t.reduce((function(t,n){return p.Path.isAncestor(t[1],n[1])?t:p.Node.common(e,n[1],t[1])}),function(e,t){for(var n=p.Path.parent(t[1]);p.Node.get(e,n).type!==o.BLOCKS.LIST_ITEM;)n=p.Path.parent(n);return[p.Node.get(e,n),n]}(e,t[0]));return Zn(n[0])?n[0].children:[n[0]]}(e)})))),i=r.findIndex((function(t){return p.Editor.isBlock(e,t)}));i<0&&(i=r.length);var l=r.slice(0,i),s=r.slice(i);return p.Transforms.insertNodes(e,l,{at:e.selection,select:!0}),p.Transforms.insertNodes(e,s,{at:e.selection,select:!0})}var c=Zn(n[0])?[{text:""}].concat(n):n;return t(c)}}}(e),e.normalizeNode=N.normalizeList(e,{validLiChildrenTypes:Jn}),e};function tr(e){var n=Le(),r=Z();function i(e){return function(){null!=r&&r.selection&&(Gn(r,{type:e}),pe(r))}}return r?t.createElement(t.Fragment,null,gt(n.field,o.BLOCKS.UL_LIST)&&t.createElement(tn,{title:"UL",testId:"ul-toolbar-button",onClick:i(o.BLOCKS.UL_LIST),isActive:$n(r,o.BLOCKS.UL_LIST),isDisabled:e.isDisabled},t.createElement(L.ListBulletedIcon,null)),gt(n.field,o.BLOCKS.OL_LIST)&&t.createElement(tn,{title:"OL",testId:"ol-toolbar-button",onClick:i(o.BLOCKS.OL_LIST),isActive:$n(r,o.BLOCKS.OL_LIST),isDisabled:e.isDisabled},t.createElement(L.ListNumberedIcon,null))):null}var nr=function(e){var n=e.mark,r=e.title,i=e.icon,o=function(e){var o=e.isDisabled,l=Z(),s=t.useCallback((function(){if(null!=l&&l.selection){var e=a.isMarkActive(l,n);l.tracking.onToolbarAction(e?"unmark":"mark",{markType:n}),a.toggleMark(l,{key:n}),pe(l)}}),[l]);return l?t.createElement(tn,{title:r,testId:n+"-toolbar-button",onClick:s,isActive:a.isMarkActive(l,n),isDisabled:o},i):null};return o.displayName=n,o},rr=function(e){return function(t,n){var r=n.options.hotkey;return function(n){if(t.selection&&r&&m(r,n)){n.preventDefault();var i=a.isMarkActive(t,e);t.tracking.onShortcutAction(i?"unmark":"mark",{markType:e}),a.toggleMark(t,{key:e})}}}},ir=nr({title:"Bold",mark:o.MARKS.BOLD,icon:t.createElement(L.FormatBoldIcon,null)}),or={bold:l.css({fontWeight:600})};function ar(e){return t.createElement("strong",Object.assign({},e.attributes,{className:or.bold}),e.children)}var lr=nr({title:"Code",mark:o.MARKS.CODE,icon:t.createElement(L.CodeIcon,null)}),sr={code:l.css({fontFamily:"monospace",fontSize:".9em"})};function cr(e){return t.createElement("code",Object.assign({},e.attributes,{className:sr.code}),e.children)}var ur=nr({title:"Italic",mark:o.MARKS.ITALIC,icon:t.createElement(L.FormatItalicIcon,null)}),dr={italic:l.css({fontStyle:"italic"})};function fr(e){return t.createElement("em",Object.assign({},e.attributes,{className:dr.italic}),e.children)}var mr=nr({title:"Underline",mark:o.MARKS.UNDERLINE,icon:t.createElement(L.FormatUnderlinedIcon,null)});function pr(e){return t.createElement("u",Object.assign({},e.attributes),e.children)}var Er,yr,hr=function(e){return o.TEXT_CONTAINERS.includes(e.type)},vr=[{match:p.Text.isText,validNode:function(e,t){var n,r=null==(n=a.getParent(e,t[1]))?void 0:n[0];return!!r&&(hr(r)||fe.includes(r.type)||e.isVoid(r))},transform:function(e,t){return qt(o.BLOCKS.PARAGRAPH)(e,t)}},{match:{type:fe},validNode:function(e,t){var n,r=null==(n=a.getParent(e,t[1]))?void 0:n[0];return!!r&&hr(r)},transform:qt(o.BLOCKS.PARAGRAPH)}],gr=function(e){function t(){return e.apply(this,arguments)||this}return M(t,e),t}(Y(Error)),Lr=function(e){return function(t,n){var r=n[0];return p.Element.isElement(r)&&e.includes(r.type)}},Tr=function(e){var t=e.default;if(!t)throw new gr("A default transformer MUST be provided");return function(n,r){var i=r[0],o=p.Element.isElement(i)?i.type:"default";return(e[o]||t)(n,r)}},Sr=function(e){for(var t,n=vr,r=V(e.plugins);!(t=r()).done;){var i=t.value,o=i.normalizer;if(o)for(var l,s=V(o);!(l=s()).done;){var c=H({},l.value);if(!c.match&&!i.isElement)throw new gr("rule.match MUST be defined in a non-element plugin");if(c.match||(c.match={type:a.getPluginType(e,i.key)}),k(c.transform)){if("validNode"in c)throw new gr("conditional transformations are not supported in validNode rules");c.transform=Tr(H({default:Gt},c.transform))}c.transform||(c.transform=Gt),"validChildren"in c&&Array.isArray(c.validChildren)&&(c.validChildren=Lr(c.validChildren)),n.push(c)}}var u=function(t,n){p.Editor.withoutNormalizing(e,(function(){t(e,n)}))},d=e.normalizeNode;return e.normalizeNode=function(t){for(var r,i=t[0],o=function(e,t){var n=t[1];return p.Text.isText(t[0])?[]:Array.from(p.Node.children(e,n))}(e,t),l=V(n);!(r=l()).done;){var s=r.value;if(a.match(i,s.match)){if("validNode"in s&&!s.validNode(e,t))return void u(s.transform,t);if("validChildren"in s){var c=function(){var t=s.validChildren,n=o.find((function(n){return!t(e,n)}));if(n)return u(s.transform,n),{v:void 0}}();if("object"==typeof c)return c.v}}}return d(t)},e},br=((yr={})[o.BLOCKS.PARAGRAPH]=l.css(Er||(Er=q(["\n line-height: ",";\n margin-bottom: 1.5em;\n "])),T.lineHeightDefault),yr);function Nr(e){return t.createElement("div",Object.assign({},e.attributes,{className:br[o.BLOCKS.PARAGRAPH]}),e.children)}var Cr=function(e,t){var n=t.options.hotkey;return function(t){e.selection&&n&&m(n,t)&&Ee(e,{activeType:o.BLOCKS.PARAGRAPH,inactiveType:o.BLOCKS.PARAGRAPH})}},Ir=[function(e){return e.querySelectorAll("style").forEach((function(e){e.remove()})),e},function(e){if(!["google-sheets-html-origin",'meta[content="Excel.Sheet"]','meta[content*="Microsoft Excel"]'].some((function(t){return!!e.querySelector(t)})))return e;for(var t=function(e){var t;return""===(null!=(t=e.textContent)?t:"").trim()},n=Array.from(e.querySelectorAll("table")),r=function(){var e=o[i];e.querySelectorAll("tr").forEach((function(e){t(e)&&e.remove()}));for(var n=Array.from(e.querySelectorAll("tr")),r=1;;){var a=n.map((function(e){return e.querySelector("th:nth-of-type("+r+"), td:nth-of-type("+r+")")})).filter((function(e){return!!e}));if(0===a.length)break;a.every((function(e){return t(e)}))?a.forEach((function(e){return e.remove()})):r+=1}},i=0,o=n;i<o.length;i++)r();return e}],kr=function(e){return Ir.reduce((function(e,t){return t(e)}),(new DOMParser).parseFromString(e,"text/html")).body.innerHTML.replace(/>\s+</g,"><").replace(/(.*)<div.*>(<table.*<\/table>)<\/div>(.*)/g,"$1$2$3")},Ar=/data-slate-fragment="(.+?)"/m,Or=l.css({margin:"0 0 1.3125rem",borderLeft:"6px solid "+T.gray200,paddingLeft:"0.875rem",fontStyle:"normal"});function Dr(e){return t.createElement("blockquote",Object.assign({},e.attributes,{className:Or}),e.children)}var Br=function(e){var t=a.getAbove(e,{match:{type:o.TEXT_CONTAINERS},mode:"lowest"});if(!t)return!1;if(!a.isAncestorEmpty(e,t[0]))return!1;var n=a.getBlockAbove(e,{match:{type:o.BLOCKS.QUOTE},mode:"lowest"});return!!n&&!(!a.hasSingleChild(n[0])||!a.isLastChild(n,t[1]))};function Rr(e,t){if(e.selection){var n=re(e,o.BLOCKS.QUOTE);null==t||t(n?"remove":"insert",{nodeType:o.BLOCKS.QUOTE}),p.Editor.withoutNormalizing(e,(function(){e.selection&&(p.Transforms.unwrapNodes(e,{match:function(e){return p.Element.isElement(e)&&e.type===o.BLOCKS.QUOTE},split:!0}),n||p.Transforms.wrapNodes(e,{type:o.BLOCKS.QUOTE,data:{},children:[]}))}))}}var wr=function(e,t){return function(n){var r=t.options.hotkey;r&&m(r,n)&&(n.preventDefault(),Rr(e,e.tracking.onShortcutAction))}},xr=function(e){var t=e.insertFragment;return e.insertFragment=function(n){var r=n.length&&n[0],i=p.Element.isElement(r)&&r.type===o.BLOCKS.QUOTE,l=a.getAbove(e,{match:{type:o.TEXT_CONTAINERS}}),s=l&&""!==p.Node.string(l[0]);if(i&&s){var c=e.selection;(function(e){return!!e&&0!==p.Point.compare(e.anchor,e.focus)})(c)&&p.Transforms.delete(e,{at:c});var u=a.getAbove(e,{match:{type:o.TEXT_CONTAINERS}});if(u&&""!==p.Node.string(u[0]))return void p.Transforms.insertNodes(e,n)}t(n)},e};function Kr(){var e;return{key:o.BLOCKS.QUOTE,type:o.BLOCKS.QUOTE,isElement:!0,component:Dr,options:{hotkey:"mod+shift+1"},handlers:{onKeyDown:wr},deserializeHtml:{rules:[{validNodeName:"BLOCKQUOTE"}]},resetNode:[{hotkey:"backspace",types:[o.BLOCKS.QUOTE],predicate:Br,onReset:Rr}],normalizer:[{validChildren:o.CONTAINERS[o.BLOCKS.QUOTE],transform:(e={},e[o.BLOCKS.QUOTE]=Yt,e.default=Ut,e)}],withOverrides:xr}}function _r(e){var n=Z();return n?t.createElement(tn,{title:"Blockquote",onClick:function(){n&&(Rr(n,n.tracking.onToolbarAction),pe(n))},testId:"quote-toolbar-button",isDisabled:e.isDisabled,isActive:re(n,o.BLOCKS.QUOTE)},t.createElement(L.QuoteIcon,null)):null}function Pr(e){return e.some((function(e){return e.type===o.BLOCKS.TABLE}))}var Hr=function(e){return e.type===o.BLOCKS.TABLE_HEADER_CELL},Mr=function(e,t){if(a.someNode(e,{match:{type:a.getPluginType(e,D.ELEMENT_TABLE)}})){var n=a.getAbove(e,{match:{type:a.getPluginType(e,D.ELEMENT_TR)}});if(n){var r=n[0],i=t(n[1]);a.insertNodes(e,D.getEmptyRowNode(e,{header:!1,colCount:r.children.length}),{at:i,select:!0}),p.Transforms.select(e,p.Editor.start(e,i))}}},Fr=function(e){Mr(e,(function(e){return p.Path.next(e)}))},zr=function(e){Mr(e,(function(e){return e}))},Gr=function(e,t,n){var r=t.header;if(a.someNode(e,{match:{type:a.getPluginType(e,D.ELEMENT_TABLE)}})){var i=a.getAbove(e,{match:{type:[a.getPluginType(e,D.ELEMENT_TD),a.getPluginType(e,D.ELEMENT_TH)]}}),o=a.getAbove(e,{match:{type:a.getPluginType(e,D.ELEMENT_TABLE)}});if(i&&o){var l=n(i[1]).slice(),s=l.length-2;o[0].children.forEach((function(t,n){l[s]=n,a.insertNodes(e,D.getEmptyCellNode(e,{header:r&&0===n}),{at:l,select:0===n})}))}}},jr=function(e,t){Gr(e,t,(function(e){return p.Path.next(e)}))},Yr=function(e,t){Gr(e,t,(function(e){return e}))};function qr(e){D.insertTable(e,{header:!0}),function(e){var t=function(e){if(e.selection)return p.Path.levels(e.selection.focus.path).find((function(e){return 1===e.length}))}(e);if(t&&!a.isFirstChild(t)){var n=p.Path.previous(t);if(n){var r=p.Editor.nodes(e,{at:n,match:function(e){return e.type===o.BLOCKS.PARAGRAPH}})[0];r&&a.isAncestorEmpty(e,r[0])&&(p.Transforms.moveNodes(e,{at:t,to:n}),p.Transforms.removeNodes(e,{at:t}))}}}(e)}var Ur,Vr,Wr,Qr,Xr,$r,Zr,Jr=function(e,t){var n=t[1],r=a.getParent(e,n);if(!r)throw new Error("table rows must be wrapped in a table node");return Math.max.apply(Math,Array.from(p.Node.children(e,r[1])).map((function(t){return Array.from(p.Node.children(e,t[1])).length})))-Array.from(p.Node.children(e,n)).length},ei=function(e,t){return 0!==Array.from(p.Node.children(e,t[1])).length},ti=function(e){return p.Element.isElement(e)&&e.type===o.BLOCKS.TABLE},ni={topRight:l.css({position:"absolute",top:"6px",right:"5px"})},ri=function(){var e=Z(),t=E.useReadOnly(),r=n.useState(!1),i=r[0],l=r[1],s=n.useState(!1),c=s[0],u=s[1],d=n.useCallback((function(){l(!1)}),[]);n.useEffect((function(){u(Boolean(e&&function(e){var t=a.getAbove(e,{match:{type:o.BLOCKS.TABLE}});if(!t)return!1;var n=a.getChildren(t)[0];return!!n&&a.getChildren(n).every((function(e){return e[0].type===o.BLOCKS.TABLE_HEADER_CELL}))}(e)))}),[e]);var f=n.useMemo((function(){return!!e&&!a.getAbove(e,{match:{type:o.BLOCKS.TABLE_HEADER_CELL}})}),[e]),m=n.useCallback((function(){if(d(),e){var t=!c;u(t),function(e,t){var n=a.getAbove(e,{match:{type:o.BLOCKS.TABLE}});if(n){var r=a.getChildren(n)[0];r&&a.getChildren(r).forEach((function(n){a.setNodes(e,{type:t?o.BLOCKS.TABLE_HEADER_CELL:o.BLOCKS.TABLE_CELL},{at:n[1]})}))}}(e,t)}}),[e,d,c]),y=n.useCallback((function(t,n,r){return function(){if(null!=e&&e.selection){d();var i=function(e){var t=oe(e,o.BLOCKS.TABLE)[0];return t?function(e){var t,n=e.children.length;return n?{numRows:n,numColumns:null==(t=e.children[0].children)?void 0:t.length}:null}(t):null}(e);p.Editor.withoutNormalizing(e,(function(){t(e,{header:c})})),e.tracking.onViewportAction(n+"Table"+("Table"===r?"":r),{tableSize:i})}}}),[e,c,d]);return t?null:n.createElement(h.Menu,{placement:"left",isOpen:i,onOpen:function(){l(!0)},onClose:d},n.createElement(h.Menu.Trigger,null,n.createElement(h.IconButton,{size:"small",variant:"transparent",tabIndex:-1,className:ni.topRight,icon:n.createElement(L.ChevronDownIcon,null),"aria-label":"Open table menu",testId:"cf-table-actions-button"})),n.createElement(h.Menu.List,null,n.createElement(h.Menu.Item,{onClick:y(zr,"insert","Row"),disabled:!f},"Add row above"),n.createElement(h.Menu.Item,{onClick:y(Fr,"insert","Row")},"Add row below"),n.createElement(h.Menu.Item,{onClick:y(Yr,"insert","Column")},"Add column left"),n.createElement(h.Menu.Item,{onClick:y(jr,"insert","Column")},"Add column right"),n.createElement(h.Menu.Divider,null),n.createElement(h.Menu.Item,{onClick:m},c?"Disable table header":"Enable table header"),n.createElement(h.Menu.Divider,null),n.createElement(h.Menu.Item,{onClick:y(D.deleteRow,"remove","Row")},"Delete row"),n.createElement(h.Menu.Item,{onClick:y(D.deleteColumn,"remove","Column")},"Delete column"),n.createElement(h.Menu.Item,{onClick:y(D.deleteTable,"remove","Table")},"Delete table")))},ii=l.css(Ur||(Ur=q(["\n border: 1px solid ",";\n border-collapse: collapse;\n padding: 10px 12px;\n min-width: 48px;\n position: relative;\n vertical-align: top;\n\n div:last-child {\n margin-bottom: 0;\n }\n"])),T.gray400),oi=function(e){var n=E.useSelected();return t.createElement("td",Object.assign({},e.attributes,e.element.data,{className:ii}),n&&t.createElement(ri,null),e.children)},ai=l.css(Vr||(Vr=q(["\n background-color: ",";\n border: 1px solid ",";\n border-collapse: collapse;\n padding: 10px 12px;\n font-weight: ",";\n text-align: left;\n min-width: 48px;\n position: relative;\n\n div:last-child {\n margin-bottom: 0;\n }\n"])),T.gray200,T.gray400,T.fontWeightMedium),li=function(e){var n=E.useSelected();return t.createElement("th",Object.assign({},e.attributes,e.element.data,{className:ai}),n&&t.createElement(ri,null),e.children)},si=l.css(Wr||(Wr=q(["\n border: 1px solid ",";\n border-collapse: collapse;\n\n &:hover td {\n background-color: transparent !important;\n }\n"])),T.gray400),ci=function(e){return t.createElement("tr",Object.assign({},e.attributes,{className:si}),e.children)},ui=l.css(Qr||(Qr=q(["\n margin-bottom: 1.5em;\n border-collapse: collapse;\n border-radius: 5px;\n border-style: hidden;\n box-shadow: 0 0 0 1px ",";\n width: 100%;\n table-layout: fixed;\n overflow: hidden;\n"])),T.gray400),di=function(e){return t.createElement("div",{"data-block-type":o.BLOCKS.TABLE},t.createElement("table",Object.assign({className:ui},e.attributes),t.createElement("tbody",null,e.children)))},fi=function(e){if(!p.Element.isElement(e))return[e];if(e.type!==o.BLOCKS.TABLE||1!==e.children.length)return[e];var t=e.children[0];return 1!==t.children.length?[e]:t.children[0].children},mi=function(e,t){var n=D.onKeyDownTable(e,t);return function(t){var r,i,l=window.getSelection();if(l&&(null==(r=l.anchorNode.attributes)||null==(i=r["data-block-type"])?void 0:i.value)===o.BLOCKS.TABLE){if("Enter"===t.key){var s=a.getAbove(e,{match:{type:o.BLOCKS.TABLE}});if(!s)return;se(e,{at:s[1],select:!0})}return t.preventDefault(),void t.stopPropagation()}if("Tab"===t.key&&!t.shiftKey){t.preventDefault();var c=D.getTableCellEntry(e,{});if(c){var u=c.tableElement,d=c.tableRow,f=a.isLastChild(d,c.tableCell[1]);if(a.isLastChild(u,d[1])&&f)return void Fr(e)}}n(t)}},pi=function(){var e;return D.createTablePlugin({type:o.BLOCKS.TABLE,handlers:{onKeyDown:mi},withOverrides:function(e,t){return D.withTable(e,t),function(e){var t=e.insertData;e.insertData=function(n){if(n.getData("text/html")){var r=e.children;t(n);var i=e.children;setTimeout((function(){var t;Pr(r)||Pr(i)&&e.tracking.onViewportAction("paste",{tablePasted:!0,hasHeadersOutsideFirstRow:(t=i,t.filter((function(e){return e.type===o.BLOCKS.TABLE})).flatMap((function(e){return e.children.slice(1)})).some((function(e){return e.children.some(Hr)})))})}),1)}else t(n)}}(e),e.insertFragment=function(e){var t=e.insertFragment;return function(n){var r;if(e.selection){var i=(n=n.flatMap(fi)).some((function(e){return ti(e)})),o=0===n.findIndex((function(e){return ti(e)})),l=""!==a.getText(e,null==(r=e.selection)?void 0:r.focus.path);return i&&o&&l&&se(e),t(n)}}}(e),e},overrideByKey:(e={},e[D.ELEMENT_TABLE]={type:o.BLOCKS.TABLE,component:di,normalizer:[{validNode:ei},{validNode:function(e,t){var n=t[1],r=!!a.getBlockAbove(e,{at:n,match:{type:[o.BLOCKS.TABLE_CELL,o.BLOCKS.TABLE_HEADER_CELL]}});return ie(n)||r},transform:Ut},{validChildren:o.CONTAINERS[o.BLOCKS.TABLE]}]},e[D.ELEMENT_TR]={type:o.BLOCKS.TABLE_ROW,component:ci,normalizer:[{validChildren:o.CONTAINERS[o.BLOCKS.TABLE_ROW],transform:qt(o.BLOCKS.TABLE_CELL)},{validNode:ei},{validNode:function(e,t){var n,r=null==(n=a.getParent(e,t[1]))?void 0:n[0];return r&&r.type===o.BLOCKS.TABLE},transform:qt(o.BLOCKS.TABLE)},{validNode:function(e,t){return 0===Jr(e,t)},transform:function(e,t){var n,r=Jr(e,t),i=p.Path.next(a.getLastChildPath(t));p.Transforms.insertNodes(e,(n={type:o.BLOCKS.TABLE_CELL,data:{},children:[{type:o.BLOCKS.PARAGRAPH,data:{},children:[{text:""}]}]},new Array(r).fill(n)),{at:i})}}]},e[D.ELEMENT_TH]={type:o.BLOCKS.TABLE_HEADER_CELL,component:li,normalizer:[{validChildren:o.CONTAINERS[o.BLOCKS.TABLE_HEADER_CELL],transform:jt}]},e[D.ELEMENT_TD]={type:o.BLOCKS.TABLE_CELL,component:oi,normalizer:[{validChildren:o.CONTAINERS[o.BLOCKS.TABLE_CELL],transform:jt}]},e)})};function Ei(e){var n=Z(),r=n&&function(e){return[D.ELEMENT_TABLE,D.ELEMENT_TH,D.ELEMENT_TR,D.ELEMENT_TD].some((function(t){return re(e,t)}))}(n);function i(){return(i=P(we.mark((function e(){return we.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}return e.abrupt("return");case 2:n.tracking.onToolbarAction("insertTable"),qr(n),pe(n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return n?t.createElement(tn,{title:"Table",testId:"table-toolbar-button",onClick:function(){return i.apply(this,arguments)},isActive:r,isDisabled:e.isDisabled},t.createElement(L.TableIcon,null)):null}function yi(e,t,n){var r=a.getAbove(t,{match:{type:o.TEXT_CONTAINERS}});if(r){var i=r[1],l=a.isAncestorEmpty(t,r[0]),s=t.children.length>1;l&&1===i.length&&a.isFirstChild(i)&&s?p.Transforms.removeNodes(t,{at:i}):n(e)}else n(e)}var hi=Object.values(o.INLINES).map((function(e){return{type:e}})),vi={document:{nodes:[{types:o.TOP_LEVEL_BLOCKS.map((function(e){return{type:e}}))}]},blocks:H((Xr={},Xr[o.BLOCKS.PARAGRAPH]={nodes:[{match:[].concat(hi,[{object:"text"}])}]},Xr[o.BLOCKS.HEADING_1]={nodes:[{match:[].concat(hi,[{object:"text"}])}]},Xr[o.BLOCKS.HEADING_2]={nodes:[{match:[].concat(hi,[{object:"text"}])}]},Xr[o.BLOCKS.HEADING_3]={nodes:[{match:[].concat(hi,[{object:"text"}])}]},Xr[o.BLOCKS.HEADING_4]={nodes:[{match:[].concat(hi,[{object:"text"}])}]},Xr[o.BLOCKS.HEADING_5]={nodes:[{match:[].concat(hi,[{object:"text"}])}]},Xr[o.BLOCKS.HEADING_6]={nodes:[{match:[].concat(hi,[{object:"text"}])}]},Xr),o.VOID_BLOCKS.reduce((function(e,t){var n;return H({},e,((n={})[t]={isVoid:!0},n))}),{}),($r={},$r[o.BLOCKS.QUOTE]={nodes:[{match:[o.CONTAINERS[o.BLOCKS.QUOTE].map((function(e){return{type:e}}))],min:1}],normalize:function(e,t){if("child_type_invalid"===t.code)return e.unwrapBlockByKey(t.node.key,o.BLOCKS.QUOTE)}},$r)),inlines:(Zr={},Zr[o.INLINES.HYPERLINK]={nodes:[{match:[{object:"text"}]}]},Zr[o.INLINES.ENTRY_HYPERLINK]={nodes:[{match:[{object:"text"}]}]},Zr[o.INLINES.ASSET_HYPERLINK]={nodes:[{match:[{object:"text"}]}]},Zr[o.INLINES.EMBEDDED_ENTRY]={isVoid:!0},Zr)};function gi(e){var t=B.toContentfulDocument({document:e.children,schema:vi});return R.documentToPlainTextString(t).length}var Li=function(e){var t={onViewportAction:function(t,n){return void 0===n&&(n={}),e(t,H({origin:"viewport-interaction"},n))},onShortcutAction:function(t,n){return void 0===n&&(n={}),e(t,H({origin:"shortcut"},n))},onToolbarAction:function(t,n){return void 0===n&&(n={}),e(t,H({origin:"toolbar-icon"},n))},onCommandPaletteAction:function(t,n){return void 0===n&&(n={}),e(t,H({origin:"command-palette"},n))}};return{key:"TrackingPlugin",withOverrides:function(e){var n=e.insertData;return e.tracking=t,e.insertData=function(r){if(0!==r.types.length){var i,o=null==(i=window.getSelection())?void 0:i.toString().length,a=gi(e);setTimeout((function(){var n=gi(e);t.onShortcutAction("paste",{characterCountAfter:n,characterCountBefore:a,characterCountSelection:o})}))}n(r)},e}}},Ti={deserializeAst:!0,deserializeHtml:!0,eventEditor:!0},Si=function(e){return!!e&&e.content.length>0},bi=function(e){return B.toSlatejsDocument({document:Si(e)?e:o.EMPTY_DOCUMENT,schema:vi})},Ni="1px solid "+T.gray400,Ci={root:l.css({position:"relative"}),editor:l.css({borderRadius:"0 0 "+T.borderRadiusMedium+" "+T.borderRadiusMedium,border:Ni,borderTop:0,padding:"20px",fontSize:T.spacingM,fontFamily:T.fontStackPrimary,minHeight:"400px",background:T.colorWhite,outline:"none",whiteSpace:"pre-wrap",overflowWrap:"break-word",webkitUserModify:"read-write-plaintext-only",a:{span:{cursor:"not-allowed","&:hover":{cursor:"not-allowed"}}},"ul > li > div":{margin:0}}),hiddenToolbar:l.css({borderTop:Ni}),enabled:l.css({background:T.colorWhite,a:{span:{cursor:"pointer","&:hover":{cursor:"pointer"}}}}),disabled:l.css({background:T.gray100})};function Ii(e){var n=e.children,r=e.isDisabled;return t.createElement(h.Menu,{placement:"bottom-end",isOpen:e.isOpen,onClose:e.onClose,onOpen:e.onToggle},t.createElement(h.Menu.Trigger,null,t.createElement(h.Button,{endIcon:t.createElement(L.ChevronDownIcon,null),testId:"toolbar-entity-dropdown-toggle",variant:"secondary",size:"small",startIcon:t.createElement(L.PlusIcon,null),isDisabled:r},"Embed")),t.createElement(h.Menu.List,{className:"toolbar-entity-dropdown-list"},n))}var ki,Ai=function(e){var r=e.isDisabled,i=e.canInsertBlocks,a=Le(),l=Z(),s=t.useState(!1),c=s[0],u=s[1],d=function(){return u(!1)},f=t.useState(!1),m=f[0],p=f[1];n.useEffect((function(){var e=!0;return a.access.can("read","Asset").then((function(t){e&&p(t)})),function(){e=!1}}),[a]);var E=gt(a.field,o.INLINES.EMBEDDED_ENTRY),y=gt(a.field,o.BLOCKS.EMBEDDED_ENTRY)&&i,h=m&>(a.field,o.BLOCKS.EMBEDDED_ASSET)&&i,v=[E,y,h].filter(Boolean).length>1||r;n.useEffect((function(){v||u(!1)}),[v]);var g=n.createElement(n.Fragment,null,y&&n.createElement(je,{isDisabled:!!r,nodeType:o.BLOCKS.EMBEDDED_ENTRY,onClose:d,isButton:!v}),E&&n.createElement(it,{isDisabled:!!r||ue(l),onClose:d,isButton:!v}),h&&n.createElement(je,{isDisabled:!!r,nodeType:o.BLOCKS.EMBEDDED_ASSET,onClose:d,isButton:!v}));return v?n.createElement(Ii,{isDisabled:r,onClose:d,onToggle:function(){return u(!c)},isOpen:c},g):g},Oi={toolbar:l.css({border:"1px solid "+T.gray400,backgroundColor:T.gray100,padding:T.spacingXs,borderRadius:T.borderRadiusMedium+" "+T.borderRadiusMedium+" 0 0"}),divider:l.css({display:"inline-block",height:"21px",width:"1px",background:T.gray300,margin:"0 "+T.spacing2Xs}),embedActionsWrapper:l.css({display:["-webkit-box","-ms-flexbox","flex"],webkitAlignSelf:"flex-start",alignSelf:"flex-start",msFlexItemAlign:"start",marginLeft:"auto"}),formattingOptionsWrapper:l.css({display:["-webkit-box","-ms-flexbox","flex"],msFlexAlign:"center",webkitBoxAlign:"center",alignItems:"center",msFlexWrap:"wrap",flexWrap:"wrap",marginRight:"20px"})},Di=function(e){var t=e.isDisabled,r=Le(),i=Z(),a=!ae(i,o.BLOCKS.TABLE),l=n.useMemo((function(){return e=r.field,{isAnyMarkEnabled:(t=function(t,n){return t.some((function(t){return n(e,t)}))})(Object.values(o.MARKS),Lt),isAnyHyperlinkEnabled:t([o.INLINES.HYPERLINK,o.INLINES.ASSET_HYPERLINK,o.INLINES.ENTRY_HYPERLINK],gt),isAnyBlockFormattingEnabled:t([o.BLOCKS.UL_LIST,o.BLOCKS.OL_LIST,o.BLOCKS.QUOTE,o.BLOCKS.HR],gt)};var e,t}),[r.field]),s=ae(i,o.BLOCKS.UL_LIST)||ae(i,o.BLOCKS.OL_LIST),c=ae(i,o.BLOCKS.QUOTE),u=t||!a||s||c;return n.createElement(h.Flex,{testId:"toolbar",className:Oi.toolbar,alignItems:"center"},n.createElement("div",{className:Oi.formattingOptionsWrapper},n.createElement(bt,{isDisabled:t||!a}),l.isAnyMarkEnabled&&n.createElement("span",{className:Oi.divider}),Lt(r.field,o.MARKS.BOLD)&&n.createElement(ir,{isDisabled:t}),Lt(r.field,o.MARKS.ITALIC)&&n.createElement(ur,{isDisabled:t}),Lt(r.field,o.MARKS.UNDERLINE)&&n.createElement(mr,{isDisabled:t}),Lt(r.field,o.MARKS.CODE)&&n.createElement(lr,{isDisabled:t}),l.isAnyHyperlinkEnabled&&n.createElement(n.Fragment,null,n.createElement("span",{className:Oi.divider}),n.createElement(yn,{isDisabled:t})),l.isAnyBlockFormattingEnabled&&n.createElement("span",{className:Oi.divider}),n.createElement(tr,{isDisabled:t||!a}),gt(r.field,o.BLOCKS.QUOTE)&&n.createElement(_r,{isDisabled:t||!a}),gt(r.field,o.BLOCKS.HR)&&n.createElement(on,{isDisabled:t||!a}),gt(r.field,o.BLOCKS.TABLE)&&n.createElement(Ei,{isDisabled:u})),n.createElement("div",{className:Oi.embedActionsWrapper},n.createElement(Ai,{isDisabled:t,canInsertBlocks:a})))},Bi={nativeSticky:l.css(ki||(ki=q(["\n position: -webkit-sticky;\n position: sticky;\n top: -1px;\n z-index: 2;\n "])))},Ri=function(e){return n.createElement("div",{className:e.isDisabled?"":Bi.nativeSticky},e.children)},wi=function(e){return"set_selection"!==e.type},xi=["sdk","isInitiallyDisabled","onAction"],Ki=function(e){var r,i,s,m,E,y,h=W(e.sdk),v=n.useMemo((function(){var t,n,r,i,l,s,m,E,y;return n=e.sdk,r=null!=(t=e.onAction)?t:c,[a.createDeserializeHtmlPlugin(),a.createDeserializeAstPlugin(),u.createDeserializeDocxPlugin(),Li(r),(E=[o.BLOCKS.EMBEDDED_ENTRY,o.BLOCKS.EMBEDDED_ASSET,o.BLOCKS.HR,o.INLINES.EMBEDDED_ENTRY],y={TABLE:[o.INLINES.EMBEDDED_ENTRY]},{key:"DragAndDropPlugin",handlers:{onDrop:function(e){return function(t){var n=Array.from(a.getNodes(e,{match:function(e){return E.includes(null==e?void 0:e.type)}}))[0];if(!n)return!1;var r=n[0];if(!t.nativeEvent.target)return!1;var i=function(e){var t=[];for(t.push(e);e.parentNode;)t.unshift(e.parentNode),e=e.parentNode;return t}(t.nativeEvent.target).some((function(e){var t;return!(!y[e.nodeName]||null!=(t=y[e.nodeName])&&t.includes(r.type))}));return i||e.history.undos.push([]),i}}}}),(m={type:o.BLOCKS.PARAGRAPH,component:Nr,options:{hotkey:["mod+opt+0"]},handlers:{onKeyDown:Cr},softBreak:[{hotkey:"shift+enter",query:{allow:o.BLOCKS.PARAGRAPH}}],deserializeHtml:{rules:[{validNodeName:["P","DIV"]}],query:function(e){return!(""===e.textContent||(t=e,t.hasAttribute("data-embedded-entity-inline-id")||t.hasAttribute("data-entity-type")));var t}},normalizer:[{validChildren:function(e,t){return me(t[0])},transform:(s={},s[o.BLOCKS.PARAGRAPH]=Yt,s.default=Ut,s)}]},A.createParagraphPlugin(m)),N.createListPlugin({normalizer:[{match:{type:[o.BLOCKS.UL_LIST,o.BLOCKS.OL_LIST]},validChildren:[o.BLOCKS.LIST_ITEM],transform:qt(o.BLOCKS.LIST_ITEM)}],overrideByKey:(l={},l[N.ELEMENT_UL]={type:o.BLOCKS.UL_LIST,component:Kn,handlers:{onKeyDown:jn},withOverrides:er},l[N.ELEMENT_OL]={type:o.BLOCKS.OL_LIST,component:_n,handlers:{onKeyDown:jn}},l[N.ELEMENT_LIC]={type:o.BLOCKS.PARAGRAPH},l[N.ELEMENT_LI]={type:o.BLOCKS.LIST_ITEM,component:Hn,normalizer:[{validNode:qn,transform:Un},{validNode:Vn,transform:Qn},{validChildren:o.LIST_ITEM_BLOCKS,transform:jt},{validNode:Wn,transform:Xn}]},l)}),{key:o.BLOCKS.HR,type:o.BLOCKS.HR,isVoid:!0,isElement:!0,component:an,handlers:{onKeyDown:rn},deserializeHtml:{rules:[{validNodeName:["HR"]},{validAttribute:{"data-void-element":o.BLOCKS.HR}}],withoutChildren:!0}},Jt(),Kr(),pi(),Ve(n),We(n),Dn(n),ot(n),{key:"Marks",plugins:[I.createBoldPlugin({type:o.MARKS.BOLD,component:ar,options:{hotkey:["mod+b"]},handlers:{onKeyDown:rr(o.MARKS.BOLD)},deserializeHtml:{rules:[{validNodeName:["STRONG","B"]},{validStyle:{fontWeight:["600","700","bold"]}}],query:function(e){return!function(e){return e.id.startsWith("docs-internal-guid")&&"B"===e.nodeName}(e)&&!a.someHtmlElement(e,(function(e){return"normal"===e.style.fontWeight}))}}}),I.createCodePlugin({type:o.MARKS.CODE,component:cr,options:{hotkey:["mod+/"]},handlers:{onKeyDown:rr(o.MARKS.CODE)},deserializeHtml:{rules:[{validNodeName:["CODE","PRE"]},{validStyle:{fontFamily:["Consolas","monospace"]}}]}}),I.createItalicPlugin({type:o.MARKS.ITALIC,component:fr,options:{hotkey:["mod+i"]},handlers:{onKeyDown:rr(o.MARKS.ITALIC)},deserializeHtml:{rules:[{validNodeName:["I","EM"]},{validStyle:{fontStyle:"italic"}}],query:function(e){return!a.someHtmlElement(e,(function(e){return"normal"===e.style.fontStyle}))}}}),I.createUnderlinePlugin({type:o.MARKS.UNDERLINE,component:pr,options:{hotkey:["mod+u"]},handlers:{onKeyDown:rr(o.MARKS.UNDERLINE)},deserializeHtml:{rules:[{validNodeName:["U"]},{validStyle:{textDecoration:["underline"]}}],query:function(e){return!a.someHtmlElement(e,(function(e){return"none"===e.style.textDecoration}))}}})]},w.createTrailingBlockPlugin({options:{type:o.BLOCKS.PARAGRAPH,level:0}}),{key:"TextPlugin",handlers:{onMouseUp:function(e){return function(){e.selection&&p.Transforms.setSelection(e,p.Editor.unhangRange(e,e.selection))}}},withOverrides:function(e){var t=e.insertText;e.insertText=function(n){var r=e.selection;if(r&&p.Range.isCollapsed(r)){var i,o=null==(i=p.Editor.above(e,{match:function(t){return p.Editor.isInline(e,t)},mode:"highest"}))?void 0:i[1];if(o&&p.Editor.isEnd(e,r.anchor,o)){var a=p.Editor.after(e,o);p.Transforms.setSelection(e,{anchor:a,focus:a})}}return t(n)};var n=e.deleteForward,r=e.deleteBackward;return e.deleteBackward=function(t){yi(t,e,r)},e.deleteForward=function(t){yi(t,e,n)},e}},{key:"VoidsPlugin",exitBreak:[{hotkey:"enter",before:!0,query:{filter:function(e){var t=e[0],n=e[1];return ie(n)&&a.isFirstChild(n)&&!!t.isVoid}}},{hotkey:"enter",level:-2,query:{filter:function(e){var t=e[0],n=e[1];return!(ie(n)&&a.isFirstChild(n)||!t.isVoid)}}}]},O.createSelectOnBackspacePlugin({options:{query:{allow:[o.BLOCKS.EMBEDDED_ASSET,o.BLOCKS.EMBEDDED_ENTRY,o.BLOCKS.HR,o.INLINES.EMBEDDED_ENTRY]}}}),{key:"PasteHTMLPlugin",withOverrides:function(e){var t=e.insertData;return e.insertData=function(e){return t(function(e){if(!e.getData("application/x-slate-fragment")){var t=function(e){return(e.getData("text/html").match(Ar)||[])[1]}(e);if(t){var n=new DataTransfer;return e.types.forEach((function(t){n.setData(t,e.getData(t))})),n.setData("application/x-slate-fragment",t),n}}return e}(e))},e},inject:{pluginsByKey:(i={},i[a.KEY_DESERIALIZE_HTML]={editor:{insertData:{format:"text/html",transformData:kr}}},i)}},d.createSoftBreakPlugin({then:function(e){return{options:{rules:e.plugins.flatMap((function(e){return e.softBreak||[]}))}}}}),d.createExitBreakPlugin({options:{rules:[]},then:function(e){return{options:{rules:e.plugins.flatMap((function(e){return e.exitBreak||[]}))}}}}),f.createResetNodePlugin({options:{rules:[]},then:function(e){for(var t,n=e.plugins.flatMap((function(e){return e.resetNode||[]})),r=V(n);!(t=r()).done;){var i=t.value;i.defaultType||(i.defaultType=o.BLOCKS.PARAGRAPH)}return{options:{rules:n}}}}),{key:"NormalizerPlugin",withOverrides:Sr}]}),[e.sdk,e.onAction]),g=t.useState(!0),L=g[0],T=g[1],S=t.useState(!1),b=S[1],C=(i=(r={editorId:h,handler:e.onChange,skip:S[0]||L,onSkip:function(){return b(!1)}}).editorId,m=r.skip,E=r.onSkip,y=t.useMemo((function(){return x((function(e){null==s||s(B.toContentfulDocument({document:e,schema:vi}))}),500)}),[s=r.handler]),t.useCallback((function(e){var t=a.getPlateSelectors(i).editor();if(!t)throw new Error("Editor change callback called but editor not defined. Editor id: "+i);if((null==t?void 0:t.operations.filter(wi)).length>0){if(m)return void(null==E||E());y(e)}}),[i,y,m,E]));t.useEffect((function(){T(!1);var t=a.getPlateSelectors(h).editor();t&&(b(!0),function(e,t){p.Editor.withoutNormalizing(e,(function(){[].concat(e.children).forEach((function(t){return e.apply({type:"remove_node",path:[0],node:t})})),t&&(p.Node.isNode(t)?[t]:t).forEach((function(t,n){return e.apply({type:"insert_node",path:[n],node:t})}));var n=p.Editor.end(e,[]);n&&p.Transforms.select(e,n)}))}(t,bi(e.value)))}),[e.value,h]);var k=l.cx(Ci.editor,void 0!==e.minHeight?l.css({minHeight:e.minHeight}):void 0,e.isDisabled?Ci.disabled:Ci.enabled,e.isToolbarHidden&&Ci.hiddenToolbar);return t.useEffect((function(){var t,n;L&&a.getPlateActions(h).value((t=bi(e.value),(n=a.createPlateEditor({plugins:v,disableCorePlugins:Ti})).children=t,p.Editor.normalize(n,{force:!0}),n.children))}),[L,v,h,e.value]),n.createElement(ge,{sdk:e.sdk},n.createElement(X,{value:h},n.createElement("div",{className:Ci.root,"data-test-id":"rich-text-editor"},n.createElement(a.Plate,{id:h,plugins:v,disableCorePlugins:Ti,editableProps:{className:k,readOnly:e.isDisabled},onChange:C},!e.isToolbarHidden&&n.createElement(Ri,{isDisabled:e.isDisabled},n.createElement(Di,{isDisabled:e.isDisabled}))))))};function _i(e){var t=e.sys;return{sys:{id:t.id,type:"Link",linkType:t.type}}}var Pi=function(e){function t(t){var n,r;(r=e.call(this,t)||this).handleSubmit=function(e){e.preventDefault(),r.props.onClose(r.getValue())},r.selectEntry=P(we.mark((function e(){var t,n,i;return we.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(t=r.props.entitySelectorConfigs.Entry).locale,i=t.contentTypes,e.next=3,r.props.sdk.dialogs.selectSingleEntry({locale:n,contentTypes:i});case 3:r.setTargetEntity("Entry",e.sent);case 5:case"end":return e.stop()}}),e)}))),r.selectAsset=P(we.mark((function e(){var t;return we.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.props.entitySelectorConfigs.Asset.locale,e.next=3,r.props.sdk.dialogs.selectSingleAsset({locale:t});case 3:r.setTargetEntity("Asset",e.sent);case 5:case"end":return e.stop()}}),e)})));var i=t.value,o=i.text,a=i.type,l=i.uri,s=i.target,c=Boolean(s),u=((n={}).Entry=null,n.Asset=null,n),d=a;return c?u[d=s.sys.linkType]=s:d=t.allowedHyperlinkTypes.includes("uri")?"uri":t.allowedHyperlinkTypes[0],r.state={text:o,uri:l,entityLinks:u,type:d},r}M(t,e);var i=t.prototype;return i.setTargetEntity=function(e,t){this.setState((function(n){var r;return{entityLinks:H({},n.entityLinks,(r={},r[e]=t?_i(t):void 0,r))}}))},i.getValue=function(){var e=this.state,t=e.text,n=e.type,r=e.uri,i={type:n};return t&&(i.text=t),"uri"===n?i.uri=r:i.target=this.state.entityLinks[n],i},i.isLinkComplete=function(){var e=this.getValue();return!(!this.props.hideText&&!e.text)&&("uri"===e.type&&e.uri||e.target)},i.render=function(){var e=this,t=this.props.labels;return n.createElement(r.EntityProvider,{sdk:this.props.sdk},n.createElement(n.Fragment,null,n.createElement(h.ModalContent,null,this.renderFields()),n.createElement(h.ModalControls,null,n.createElement(h.Button,{type:"button",onClick:function(){return e.props.onClose(null)},variant:"secondary",testId:"cancel-cta",size:"small"},"Cancel"),n.createElement(h.Button,{type:"submit",variant:"positive",onClick:this.handleSubmit,isDisabled:!this.isLinkComplete(),testId:"confirm-cta",size:"small"},t.confirm))))},i.renderFields=function(){var e=this,t=this.props,r=t.hideText,i=t.allowedHyperlinkTypes,o=t.entitySelectorConfigs,a=this.state,l=a.uri,s=a.text,c=a.type,u="uri"===c&&(r||!!s);return n.createElement(h.Form,null,r?null:n.createElement(h.FormControl,{id:"link-text",isRequired:!0},n.createElement(h.FormControl.Label,null,"Link text"),n.createElement(h.TextInput,{testId:"link-text-input",name:"link-text",value:s||"",onChange:function(t){return e.setState({text:t.target.value})},autoFocus:!u})),function(e){return void 0===e&&(e={}),!!e.Entry||!!e.Asset}(o)&&n.createElement(h.FormControl,{id:"link-type",name:"link-type"},n.createElement(h.FormControl.Label,null,"Link type"),n.createElement(h.Select,{value:c,onChange:function(t){return e.setState({type:t.target.value})},testId:"link-type-select"},i.includes("uri")||"uri"===c?n.createElement(h.Select.Option,{value:"uri"},"URL"):null,i.includes("Entry")||"Entry"===c?n.createElement(h.Select.Option,{value:"Entry"},"Entry"):null,i.includes("Asset")||"Asset"===c?n.createElement(h.Select.Option,{value:"Asset"},"Asset"):null)),"uri"===c?n.createElement(h.FormControl,{id:"link-uri",isRequired:!0},n.createElement(h.FormControl.Label,null,"Link target"),n.createElement(h.TextInput,{testId:"link-target-input",name:"link-uri",value:l||"",placeholder:"https://",onChange:function(t){return e.setState({uri:t.target.value})},autoFocus:u}),n.createElement(h.FormControl.HelpText,null,"A protocol may be required, e.g. https://")):this.renderEntityField())},i.renderEntityField=function(){var e=this,t=this.state,r=t.type,i=t.entityLinks[r],o=!i;return n.createElement("div",null,n.createElement(h.FormLabel,{required:!0,htmlFor:""},"Link target"),!o&&n.createElement(h.TextLink,{as:"button",className:l.css({marginLeft:T.spacingS}),onClick:function(){return e.setTargetEntity(r,null)}},"Remove selection"),i&&n.createElement("div",null,"Entry"===r&&n.createElement(Oe,{sdk:this.props.sdk,locale:this.props.entitySelectorConfigs.Entry.locale,entryId:i.sys.id,isDisabled:!0,isSelected:!1}),"Asset"==r&&n.createElement(Ie,{sdk:this.props.sdk,locale:this.props.entitySelectorConfigs.Asset.locale,assetId:i.sys.id,isDisabled:!0,isSelected:!1})),o&&this.renderEntitySelector(r,o))},i.renderEntitySelector=function(e){return n.createElement("div",{className:l.css({marginTop:T.spacingS})},"Entry"===e&&n.createElement(h.TextLink,{as:"button",onClick:this.selectEntry},"Select entry"),"Asset"===e&&n.createElement(h.TextLink,{as:"button",onClick:this.selectAsset},"Select asset"))},t}(n.Component);Pi.propTypes={sdk:K.object.isRequired,labels:K.shape({title:K.string,confirm:K.string}),value:K.shape({text:K.string,uri:K.string,target:K.object,type:K.oneOf(["uri","Entry","Asset"])}),entitySelectorConfigs:K.object,allowedHyperlinkTypes:K.arrayOf(K.oneOf(["Entry","Asset","uri"])),hideText:K.bool,onClose:K.func.isRequired},Pi.defaultProps={labels:{title:"Insert link",confirm:"Insert link"},value:{},hideText:!1,entitySelectorConfigs:{},allowedHyperlinkTypes:["Entry","Asset","uri"]},exports.ConnectedRichTextEditor=Ki,exports.RichTextEditor=function(e){var a=e.sdk,l=e.isInitiallyDisabled,c=e.onAction,u=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(i[n]=e[n]);return i}(e,xi),d=t.useCallback((function(e){return!e||s(e,o.EMPTY_DOCUMENT)}),[]),f=W(e.sdk);return n.createElement(r.EntityProvider,{sdk:a},n.createElement(i.FieldConnector,{throttle:0,field:a.field,isInitiallyDisabled:l,isEmptyValue:d,isEqualValues:s},(function(e){return n.createElement(Ki,Object.assign({},u,{key:"rich-text-editor-"+f,value:e.lastRemoteValue,sdk:a,onAction:c,isDisabled:e.disabled,onChange:e.setValue}))})))},exports.openRichTextDialog=function(e){return function(t){var r;return"rich-text-hyperlink-dialog"===(null==(r=t.parameters)?void 0:r.type)?i.ModalDialogLauncher.openDialog(t,(function(r){return n.createElement(Pi,Object.assign({},t.parameters,{onClose:r.onClose,sdk:e}))})):Promise.reject()}},exports.renderRichTextDialog=function(e){var t=e.parameters.invocation;return"rich-text-hyperlink-dialog"===(null==t?void 0:t.type)?(e.window.startAutoResizer(),n.createElement(Pi,Object.assign({},e.parameters.invocation,{onClose:e.close,sdk:e}))):n.createElement("div",null)};
|
|
2
2
|
//# sourceMappingURL=field-editor-rich-text.cjs.production.min.js.map
|