polotno-node 0.3.6 → 0.3.7

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.
@@ -201,7 +201,7 @@ var e=require("react");module.exports=function(r,n){const t=e.useRef("loading"),
201
201
  },{"konva":"aTGn"}],"cEy1":[function(require,module,exports) {
202
202
  "use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Highlighter=void 0;const t=e(require("react")),r=require("mobx-react-lite"),i=require("react-konva");exports.Highlighter=(0,r.observer)(({element:e})=>t.default.createElement(i.Rect,{name:"highlighter",x:e.x,y:e.y,rotation:e.rotation,width:e.width,height:e.height,listening:!1,stroke:"rgb(0, 161, 255)",strokeWidth:2,strokeScaleEnabled:!1}));
203
203
  },{"react":"HdMw","mobx-react-lite":"ZfSi","react-konva":"Sgug"}],"Fpgh":[function(require,module,exports) {
204
- "use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TextElement=exports.useFontLoader=void 0;const t=e(require("react")),n=require("mobx-react-lite"),r=require("react-konva"),o=require("react-konva-utils"),a=require("mobx"),i=e(require("konva")),l=require("../utils/loader"),d=require("../utils/fonts"),s=require("../utils/flags"),u=require("./apply-filters"),c=require("./use-fadein"),f=require("./highlighter"),h=document.createElement("style");h.type="text/css",document.head.appendChild(h);const g={border:"none",padding:"0px",overflow:"hidden",background:"none",outline:"none",resize:"none",overflowWrap:"break-word",whiteSpace:"normal",userSelect:"text",wordBreak:"normal"},m=(0,n.observer)(({textNodeRef:e,element:n,onBlur:r,selectAll:a,cursorPosition:i})=>{const[l,d]=t.default.useState(g),s=e.current;t.default.useLayoutEffect(()=>{const e={};e.width=s.width()-2*s.padding()+"px",e.height=s.height()-2*s.padding()+10+"px",e.fontSize=s.fontSize()+"px",e.lineHeight=s.lineHeight()+.01,e.fontFamily='"'+s.fontFamily()+'"',e.textAlign=s.align(),e.color=s.fill(),e.fontWeight=n.fontWeight,e.fontStyle=n.fontStyle;const t=`\n .polotno-input::placeholder {\n color: ${l.color};\n opacity: 0.6;\n }\n `;h.innerHTML="",h.appendChild(document.createTextNode(t)),JSON.stringify(e)!==JSON.stringify(l)&&d(e)});const u=t.default.useRef(null);return t.default.useEffect(()=>{var e;const t=u.current;if(!t)return;null===(e=u.current)||void 0===e||e.focus();const n=i||t.value.length;t.selectionStart=t.selectionEnd=n,a&&(null==t||t.select(),document.execCommand("selectAll",!1,null))},[]),t.default.createElement(o.Html,null,t.default.createElement("textarea",{className:"polotno-input",ref:u,style:Object.assign(Object.assign({},g),l),value:n.text,onChange:e=>{n.set({text:e.target.value})},placeholder:n.placeholder,onBlur:r}))}),p=e=>{const[n,r]=t.default.useState(!1),o=t.default.useRef(!1);return t.default.useEffect(()=>{var t=!0;return setTimeout(()=>{t&&(e._editModeEnabled&&(o.current=!0),r(!0),setTimeout(()=>{o.current=!1},50))},50),()=>{t=!1}},[]),{editorEnabled:n&&e._editModeEnabled,selectAll:o.current}},x=(e,n)=>{const[r,o]=t.default.useState((0,d.isFontLoaded)(n));return t.default.useLayoutEffect(()=>{if((0,d.isFontLoaded)(n))return void o(!0);let t=!0;return(async()=>{r&&o(!1);const a=(0,l.incrementLoader)(`text ${n}`);await e.loadFont(n),i.default.Util.requestAnimFrame(a),t&&o(!0)})(),()=>{t=!1}},[n]),[r]};exports.useFontLoader=x;const y=({fontLoaded:e,fontFamily:n,fontSize:r,lineHeight:o})=>t.default.useMemo(()=>{if("number"==typeof o)return o;const e=document.createElement("div");e.style.fontFamily=n,e.style.fontSize=r+"px",e.style.lineHeight=o,e.innerText="Test text",document.body.appendChild(e);const t=e.offsetHeight;return document.body.removeChild(e),t/r},[e,n,r,o]);function E(e){var t=e.getAbsoluteTransform().copy();t.invert();var n=e.getStage().getPointerPosition();return t.point(n)}function S(e){var t;const n=e.target,r=E(n),o=n.textArr,a=Math.floor(r.y/(n.fontSize()*n.lineHeight())),i=o.slice(0,a).reduce((e,t)=>e+t.text.length,a),l=null!==(t=o[a])&&void 0!==t?t:o[0];let d=0;return"right"===n.align()?d=n.width()-l.width:"center"===n.align()&&(d=n.width()/2-l.width/2),i+Math.round((r.x-d)/l.width*l.text.length)}exports.TextElement=(0,n.observer)(({element:e,store:n})=>{const o=t.default.useRef(null),{editorEnabled:i,selectAll:d}=p(e),[h,g]=t.default.useState(!1),[x,E]=t.default.useState(!1),w=n.selectedElements.indexOf(e)>=0;t.default.useEffect(()=>{if(e.width)return;const t=o.current;t.width(600),e.set({width:1.4*t.getTextWidth()})},[]),t.default.useLayoutEffect(()=>(0,a.autorun)(()=>{const t=o.current;(0,u.applyFilter)(t,e)}));const[v]=(0,exports.useFontLoader)(n,e.fontFamily),b=t.default.useRef(null);t.default.useEffect(()=>{if(!v)return;const t=o.current,n=e.height&&t.height()>e.height,{forceTextFitEnabled:r}=s.flags;n&&r&&!x?(b.current||(b.current=(0,l.incrementLoader)()),e.set({fontSize:e.fontSize-.1})):r&&b.current?(b.current(),b.current=null):e.height!==t.height()&&e.set({height:t.height()})}),t.default.useLayoutEffect(()=>{const t=o.current;t&&(t.width(t.width()+1e-8),t._setTextData(),(0,u.applyFilter)(t,e))},[v]);const T=t.default.useRef(null),F=t.default.useRef(0),k=t=>{n.selectedElements.find(t=>t===e)&&!e.locked&&(F.current=S(t),e.toggleEditMode())},z=!e.text&&e.placeholder,M=e._editModeEnabled?0:z?.6:e.opacity;(0,c.useFadeIn)(o,M);const L=y({fontLoaded:v,fontFamily:e.fontFamily,fontSize:e.fontSize,lineHeight:e.lineHeight}),q=e.selectable||"admin"===n.role;return t.default.createElement(t.default.Fragment,null,t.default.createElement(r.Text,{ref:o,id:e.id,name:"element",hideOnExport:!e.showInExport,x:e.x,y:e.y,rotation:e.rotation,width:e.width,text:e.text||e.placeholder,fill:e.fill,stroke:e.stroke,strokeWidth:e.strokeWidth,fillAfterStrokeEnabled:!0,fontSize:e.fontSize,fontFamily:e.fontFamily,fontStyle:e.fontStyle+" "+e.fontWeight,textDecoration:e.textDecoration,align:e.align,draggable:!e.locked,opacity:M,shadowEnabled:e.shadowEnabled,shadowBlur:e.shadowBlur,lineHeight:L,letterSpacing:e.letterSpacing*e.fontSize,listening:q,onDragStart:()=>{n.history.startTransaction()},onDragMove:t=>{setTimeout(()=>{e.set({x:t.target.x(),y:t.target.y()})})},onDragEnd:t=>{e.set({x:t.target.x(),y:t.target.y()}),n.history.endTransaction()},onMouseEnter:()=>{g(!0)},onMouseLeave:()=>{g(!1)},onClick:k,onTap:k,onTransformStart:()=>{E(!0),n.history.startTransaction()},onTransform:t=>{var n;const r=(null===(n=t.target.getStage())||void 0===n?void 0:n.findOne("Transformer")).getActiveAnchor();if("middle-left"===r||"middle-right"===r){const n=t.target.scaleX(),r=t.target.width()*n,o=e.fontSize;let a=r;r<o&&(a=o,T.current&&t.target.position(T.current)),t.target.width(a),t.target.scaleX(1),e.set({x:t.target.x(),y:t.target.y(),width:t.target.width(),rotation:t.target.rotation()}),(0,u.applyFilter)(t.target,e)}t.target.strokeWidth(e.strokeWidth/t.target.scaleX()),T.current=t.target.position()},onTransformEnd:t=>{E(!1);const r=t.target.scaleX();t.target.scaleX(1),t.target.scaleY(1),t.target.strokeWidth(e.strokeWidth),e.set({fontSize:Math.round(e.fontSize*r),width:Math.ceil(t.target.width()*r),x:t.target.x(),y:t.target.y(),rotation:t.target.rotation()}),n.history.endTransaction()}}),i&&t.default.createElement(r.Group,{x:e.x,y:e.y,rotation:e.rotation},t.default.createElement(m,{textNodeRef:o,element:e,selectAll:d,cursorPosition:F.current,onBlur:()=>{e.toggleEditMode(!1)}})),!x&&(h||w)&&t.default.createElement(f.Highlighter,{element:e}))});
204
+ "use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TextElement=exports.useFontLoader=void 0;const t=e(require("react")),n=require("mobx-react-lite"),r=require("react-konva"),o=require("react-konva-utils"),i=require("mobx"),l=e(require("konva")),a=require("../utils/loader"),d=require("../utils/fonts"),s=require("../utils/flags"),u=require("./apply-filters"),c=require("./use-fadein"),f=require("./highlighter"),h=document.createElement("style");h.type="text/css",document.head.appendChild(h);const g={border:"none",padding:"0px",overflow:"hidden",background:"none",outline:"none",resize:"none",overflowWrap:"break-word",whiteSpace:"normal",userSelect:"text",wordBreak:"normal"},m=(0,n.observer)(({textNodeRef:e,element:n,onBlur:r,selectAll:i,cursorPosition:l})=>{const[a,d]=t.default.useState(g),s=e.current;t.default.useLayoutEffect(()=>{const e={};e.width=s.width()-2*s.padding()+"px",e.height=s.height()-2*s.padding()+10+"px",e.fontSize=s.fontSize()+"px",e.lineHeight=s.lineHeight()+.01,e.fontFamily='"'+s.fontFamily()+'"',e.textAlign=s.align(),e.color=s.fill(),e.fontWeight=n.fontWeight,e.fontStyle=n.fontStyle;const t=`\n .polotno-input::placeholder {\n color: ${a.color};\n opacity: 0.6;\n }\n `;h.innerHTML="",h.appendChild(document.createTextNode(t)),JSON.stringify(e)!==JSON.stringify(a)&&d(e)});const u=t.default.useRef(null);return t.default.useEffect(()=>{var e;const t=u.current;if(!t)return;null===(e=u.current)||void 0===e||e.focus();const n=l||t.value.length;t.selectionStart=t.selectionEnd=n,i&&(null==t||t.select(),document.execCommand("selectAll",!1,null))},[]),t.default.createElement(o.Html,null,t.default.createElement("textarea",{className:"polotno-input",ref:u,style:Object.assign(Object.assign({},g),a),value:n.text,onChange:e=>{n.set({text:e.target.value})},placeholder:n.placeholder,onBlur:r}))}),p=e=>{const[n,r]=t.default.useState(!1),o=t.default.useRef(!1);return t.default.useEffect(()=>{var t=!0;return setTimeout(()=>{t&&(e._editModeEnabled&&(o.current=!0),r(!0),setTimeout(()=>{o.current=!1},50))},50),()=>{t=!1}},[]),{editorEnabled:n&&e._editModeEnabled,selectAll:o.current}},x=(e,n)=>{const[r,o]=t.default.useState((0,d.isFontLoaded)(n));return t.default.useLayoutEffect(()=>{if((0,d.isFontLoaded)(n))return void o(!0);let t=!0;return(async()=>{r&&o(!1);const i=(0,a.incrementLoader)(`text ${n}`);await e.loadFont(n),l.default.Util.requestAnimFrame(i),t&&o(!0)})(),()=>{t=!1}},[n]),[r]};exports.useFontLoader=x;const y=({fontLoaded:e,fontFamily:n,fontSize:r,lineHeight:o})=>t.default.useMemo(()=>{if("number"==typeof o)return o;const e=document.createElement("div");e.style.fontFamily=n,e.style.fontSize=r+"px",e.style.lineHeight=o,e.innerText="Test text",document.body.appendChild(e);const t=e.offsetHeight;return document.body.removeChild(e),t/r},[e,n,r,o]);function E(e){var t=e.getAbsoluteTransform().copy();t.invert();var n=e.getStage().getPointerPosition();return t.point(n)}function S(e){var t;const n=e.target,r=E(n),o=n.textArr,i=Math.floor(r.y/(n.fontSize()*n.lineHeight())),l=o.slice(0,i).reduce((e,t)=>e+t.text.length,i),a=null!==(t=o[i])&&void 0!==t?t:o[0];let d=0;return"right"===n.align()?d=n.width()-a.width:"center"===n.align()&&(d=n.width()/2-a.width/2),l+Math.round((r.x-d)/a.width*a.text.length)}exports.TextElement=(0,n.observer)(({element:e,store:n})=>{const o=t.default.useRef(null),{editorEnabled:l,selectAll:d}=p(e),[h,g]=t.default.useState(!1),[x,E]=t.default.useState(!1),w=n.selectedElements.indexOf(e)>=0;t.default.useEffect(()=>{if(e.width)return;const t=o.current;t.width(600),e.set({width:1.4*t.getTextWidth()})},[]),t.default.useLayoutEffect(()=>(0,i.autorun)(()=>{const t=o.current;(0,u.applyFilter)(t,e)}));const[v]=(0,exports.useFontLoader)(n,e.fontFamily),b=t.default.useRef(null);t.default.useEffect(()=>{if(!v)return;const t=o.current,n=e.height&&t.height()>e.height,r=e.text.split("\n").join(" ").split(" ");let i=t.textArr.map(e=>e.text).join(";");const l=r.find(e=>!i.includes(e)||(i=i.replace(e,""),!1)),d=n||l,{forceTextFitEnabled:u}=s.flags;d&&u&&!x?(b.current||(b.current=(0,a.incrementLoader)()),e.set({fontSize:e.fontSize-.1})):u&&b.current?(b.current(),b.current=null):e.height!==t.height()&&e.set({height:t.height()})}),t.default.useLayoutEffect(()=>{const t=o.current;t&&(t.width(t.width()+1e-8),t._setTextData(),(0,u.applyFilter)(t,e))},[v]);const T=t.default.useRef(null),F=t.default.useRef(0),k=t=>{n.selectedElements.find(t=>t===e)&&!e.locked&&(F.current=S(t),e.toggleEditMode())},z=!e.text&&e.placeholder,M=e._editModeEnabled?0:z?.6:e.opacity;(0,c.useFadeIn)(o,M);const L=y({fontLoaded:v,fontFamily:e.fontFamily,fontSize:e.fontSize,lineHeight:e.lineHeight}),q=e.selectable||"admin"===n.role;return t.default.createElement(t.default.Fragment,null,t.default.createElement(r.Text,{ref:o,id:e.id,name:"element",hideOnExport:!e.showInExport,x:e.x,y:e.y,rotation:e.rotation,width:e.width,text:e.text||e.placeholder,fill:e.fill,stroke:e.stroke,strokeWidth:e.strokeWidth,fillAfterStrokeEnabled:!0,fontSize:e.fontSize,fontFamily:e.fontFamily,fontStyle:e.fontStyle+" "+e.fontWeight,textDecoration:e.textDecoration,align:e.align,draggable:!e.locked,opacity:M,shadowEnabled:e.shadowEnabled,shadowBlur:e.shadowBlur,lineHeight:L,letterSpacing:e.letterSpacing*e.fontSize,listening:q,onDragStart:()=>{n.history.startTransaction()},onDragMove:t=>{setTimeout(()=>{e.set({x:t.target.x(),y:t.target.y()})})},onDragEnd:t=>{e.set({x:t.target.x(),y:t.target.y()}),n.history.endTransaction()},onMouseEnter:()=>{g(!0)},onMouseLeave:()=>{g(!1)},onClick:k,onTap:k,onTransformStart:()=>{E(!0),n.history.startTransaction()},onTransform:t=>{var n;const r=(null===(n=t.target.getStage())||void 0===n?void 0:n.findOne("Transformer")).getActiveAnchor();if("middle-left"===r||"middle-right"===r){const n=t.target.scaleX(),r=t.target.width()*n,o=e.fontSize;let i=r;r<o&&(i=o,T.current&&t.target.position(T.current)),t.target.width(i),t.target.scaleX(1),e.set({x:t.target.x(),y:t.target.y(),width:t.target.width(),rotation:t.target.rotation()}),(0,u.applyFilter)(t.target,e)}t.target.strokeWidth(e.strokeWidth/t.target.scaleX()),T.current=t.target.position()},onTransformEnd:t=>{E(!1);const r=t.target.scaleX();t.target.scaleX(1),t.target.scaleY(1),t.target.strokeWidth(e.strokeWidth),e.set({fontSize:Math.round(e.fontSize*r),width:Math.ceil(t.target.width()*r),x:t.target.x(),y:t.target.y(),rotation:t.target.rotation()}),n.history.endTransaction()}}),l&&t.default.createElement(r.Group,{x:e.x,y:e.y,rotation:e.rotation},t.default.createElement(m,{textNodeRef:o,element:e,selectAll:d,cursorPosition:F.current,onBlur:()=>{e.toggleEditMode(!1)}})),!x&&(h||w)&&t.default.createElement(f.Highlighter,{element:e}))});
205
205
  },{"react":"HdMw","mobx-react-lite":"ZfSi","react-konva":"Sgug","react-konva-utils":"jXQU","mobx":"BzvP","konva":"aTGn","../utils/loader":"bN4e","../utils/fonts":"XXLd","../utils/flags":"IDY9","./apply-filters":"SIWI","./use-fadein":"N3c2","./highlighter":"cEy1"}],"Vshz":[function(require,module,exports) {
206
206
  var t;(t=t||{}).stringify=function(){var t={"visit_linear-gradient":function(i){return t.visit_gradient(i)},"visit_repeating-linear-gradient":function(i){return t.visit_gradient(i)},"visit_radial-gradient":function(i){return t.visit_gradient(i)},"visit_repeating-radial-gradient":function(i){return t.visit_gradient(i)},visit_gradient:function(i){var r=t.visit(i.orientation);return r&&(r+=", "),i.type+"("+r+t.visit(i.colorStops)+")"},visit_shape:function(i){var r=i.value,n=t.visit(i.at),e=t.visit(i.style);return e&&(r+=" "+e),n&&(r+=" at "+n),r},"visit_default-radial":function(i){var r="",n=t.visit(i.at);return n&&(r+=n),r},"visit_extent-keyword":function(i){var r=i.value,n=t.visit(i.at);return n&&(r+=" at "+n),r},"visit_position-keyword":function(t){return t.value},visit_position:function(i){return t.visit(i.value.x)+" "+t.visit(i.value.y)},"visit_%":function(t){return t.value+"%"},visit_em:function(t){return t.value+"em"},visit_px:function(t){return t.value+"px"},visit_literal:function(i){return t.visit_color(i.value,i)},visit_hex:function(i){return t.visit_color("#"+i.value,i)},visit_rgb:function(i){return t.visit_color("rgb("+i.value.join(", ")+")",i)},visit_rgba:function(i){return t.visit_color("rgba("+i.value.join(", ")+")",i)},visit_color:function(i,r){var n=i,e=t.visit(r.length);return e&&(n+=" "+e),n},visit_angular:function(t){return t.value+"deg"},visit_directional:function(t){return"to "+t.value},visit_array:function(i){var r="",n=i.length;return i.forEach(function(i,e){r+=t.visit(i),e<n-1&&(r+=", ")}),r},visit:function(i){if(!i)return"";if(i instanceof Array)return t.visit_array(i,"");if(i.type){var r=t["visit_"+i.type];if(r)return r(i);throw Error("Missing visitor visit_"+i.type)}throw Error("Invalid node.")}};return function(i){return t.visit(i)}}(),(t=t||{}).parse=function(){var t={linearGradient:/^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i,repeatingLinearGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,radialGradient:/^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,repeatingRadialGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},i="";function r(t){var r=new Error(i+": "+t);throw r.source=i,r}function n(){var t=g(e);return i.length>0&&r("Invalid input not EOF"),t}function e(){return a("linear-gradient",t.linearGradient,u)||a("repeating-linear-gradient",t.repeatingLinearGradient,u)||a("radial-gradient",t.radialGradient,s)||a("repeating-radial-gradient",t.repeatingRadialGradient,s)}function a(i,n,e){return o(n,function(n){var a=e();return a&&(h(t.comma)||r("Missing comma before color stops")),{type:i,orientation:a,colorStops:g(d)}})}function o(i,n){var e=h(i);if(e){h(t.startCall)||r("Missing (");var a=n(e);return h(t.endCall)||r("Missing )"),a}}function u(){return y("directional",t.sideOrCorner,1)||y("angular",t.angleValue,1)}function s(){var r,n,e=l();return e&&((r=[]).push(e),n=i,h(t.comma)&&((e=l())?r.push(e):i=n)),r}function l(){var t=function(){var t=y("shape",/^(circle)/i,0);t&&(t.style=_()||v());return t}()||function(){var t=y("shape",/^(ellipse)/i,0);t&&(t.style=m()||v());return t}();if(t)t.at=c();else{var i=v();if(i){t=i;var r=c();r&&(t.at=r)}else{var n=f();n&&(t={type:"default-radial",at:n})}}return t}function v(){return y("extent-keyword",t.extentKeywords,1)}function c(){if(y("position",/^at/,0)){var t=f();return t||r("Missing positioning value"),t}}function f(){var t={x:m(),y:m()};if(t.x||t.y)return{type:"position",value:t}}function g(i){var n=i(),e=[];if(n)for(e.push(n);h(t.comma);)(n=i())?e.push(n):r("One extra comma");return e}function d(){var i=y("hex",t.hexColor,1)||o(t.rgbaColor,function(){return{type:"rgba",value:g(p)}})||o(t.rgbColor,function(){return{type:"rgb",value:g(p)}})||y("literal",t.literalColor,0);return i||r("Expected color definition"),i.length=m(),i}function p(){return h(t.number)[1]}function m(){return y("%",t.percentageValue,1)||y("position-keyword",t.positionKeywords,1)||_()}function _(){return y("px",t.pixelValue,1)||y("em",t.emValue,1)}function y(t,i,r){var n=h(i);if(n)return{type:t,value:n[r]}}function h(t){var r,n;return(n=/^[\n\r\t\s]+/.exec(i))&&b(n[0].length),(r=t.exec(i))&&b(r[0].length),r}function b(t){i=i.substr(t)}return function(t){return i=t.toString(),n()}}(),exports.parse=t.parse,exports.stringify=t.stringify;
207
207
  },{}],"V8he":[function(require,module,exports) {
@@ -283,7 +283,7 @@ var e;!function(t,n){void 0===t&&void 0!==window&&(t=window),"function"==typeof
283
283
  line-height: auto;
284
284
  margin: 0;
285
285
  }
286
- `,x=({html:e,onBlur:t,onChange:r,element:n})=>{const l=i.default.useRef(null);return i.default.useEffect(()=>{if(!l.current)return;const e=new a.default(l.current,{toolbar:!1,keyboard:!1,clipboard:{matchVisual:!1}});return exports.quillRef.editor.instance=e,window.__polotnoQuill=e,e.on("text-change",()=>{var t;e.getSelection()&&(exports.quillRef.currentFormat=e.getFormat()),r(null===(t=l.current)||void 0===t?void 0:t.childNodes[0].innerHTML)}),e.setSelection(0,0,"api"),e.on("selection-change",r=>{r||t(),r&&(exports.quillRef.currentFormat=e.getFormat())}),l.current.childNodes[0].addEventListener("blur",e=>{var r;(null===(r=e.relatedTarget)||void 0===r?void 0:r.classList.contains("ql-clipboard"))||t()}),()=>{exports.quillRef.editor.instance=null,exports.quillRef.currentFormat={},delete window.__polotnoQuill}},[]),i.default.useEffect(()=>{var t;const r=exports.quillRef.editor.instance,i=r.getSelection();if((null===(t=l.current)||void 0===t?void 0:t.childNodes[0].innerHTML)!==n.text){var o=r.clipboard.convert("<div class='ql-editor' style='outline: none;'>"+e+"<p><br></p></div>");r.setContents(o),r.history.clear(),i&&(r.setSelection(i.index,i.length),exports.quillRef.currentFormat=r.getFormat())}},[n.text]),i.default.createElement(y,{ref:l,style:{fontSize:n.fontSize,color:n.fill,width:n.width,fontFamily:n.fontFamily,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,textAlign:n.align}})};function b(e,t,r){return i.default.useMemo(()=>(0,f.detectSize)(e),[e,t.width,r])}exports.HTMLElement=(0,l.observer)(({element:e,store:t})=>{const r=i.default.useRef(null),[n,l]=i.default.useState(),[a,p]=i.default.useState(!1),[w,q]=i.default.useState(!0),[E,S]=i.default.useState(!1),[_,F]=i.default.useState(!1),T=t.selectedElements.indexOf(e)>=0,[M]=(0,c.useFontLoader)(t,e.fontFamily);(0,g.useFadeIn)(r);const $=M?e.fontFamily:"Arial",k=`<div style="width: ${e.width||100}px; color: ${e.fill}; font-size: ${e.fontSize}px; font-family: '${$}'; text-decoration: ${e.textDecoration}; text-align: ${e.align}; line-height: ${e.lineHeight}; letter-spacing: ${e.letterSpacing}; font-style: ${e.fontStyle}; font-weight: ${e.fontWeight}; -webkit-text-stroke: ${e.strokeWidth}px ${e.stroke}" contentEditable>${e.text}</div>`,{width:L,height:R}=b(k,e,M);i.default.useEffect(()=>{e.set({height:R})},[R]),i.default.useLayoutEffect(()=>{if(a||E)return;const t=(0,v.incrementLoader)(`text ${e.id}`);q(!0),async function(){await new Promise(e=>setTimeout(e));const r=await(0,f.htmlToCanvas)({html:k,width:e.width||1,height:R||1,fontFamily:$});l(r),q(!1),u.default.Util.requestAnimFrame(t)}()},[k,a,R,E,$]);const H=a||w;return i.default.useLayoutEffect(()=>s.autorun(()=>{const t=r.current;(0,d.applyFilter)(t,e)}),[n,H]),i.default.createElement(i.default.Fragment,null,i.default.createElement(o.Image,{ref:r,name:"element",image:n,x:e.x,y:e.y,rotation:e.rotation,width:e.width,height:e.height,visible:!H,draggable:!e.locked,opacity:E?0:e.opacity,shadowEnabled:e.shadowEnabled,shadowBlur:e.shadowBlur,onMouseEnter:()=>{F(!0)},onMouseLeave:()=>{F(!1)},onDragStart:()=>{t.history.startTransaction()},onDragMove:t=>{setTimeout(()=>{e.set({x:t.target.x(),y:t.target.y()})})},onDragEnd:r=>{e.set({x:r.target.x(),y:r.target.y()}),t.history.endTransaction()},id:e.id,onDblClick:()=>{e.locked||S(!0)},onDblTap:()=>{e.locked||S(!0)},onTransformStart:e=>{var t;const r=(null===(t=e.target.getStage())||void 0===t?void 0:t.findOne("Transformer")).getActiveAnchor();("middle-left"===r||"middle-right"===r)&&p(!0)},onTransform:t=>{var r;const n=(null===(r=t.target.getStage())||void 0===r?void 0:r.findOne("Transformer")).getActiveAnchor();if("middle-left"===n||"middle-right"===n){const r=t.target.scaleX(),n=Math.max(t.target.width()*r,e.fontSize);t.target.width(n),t.target.scaleX(1),e.set({width:n})}e.set({x:t.target.x(),y:t.target.y(),rotation:t.target.rotation()})},onTransformEnd:t=>{p(!1),q(!0);const r=t.target.scaleX();t.target.scaleX(1),t.target.scaleY(1),e.set({fontSize:e.fontSize*r,width:t.target.width()*r,x:t.target.x(),y:t.target.y(),rotation:t.target.rotation()})}}),H&&i.default.createElement(o.Group,{x:e.x,y:e.y,rotation:e.rotation},i.default.createElement(m.Html,{divProps:{style:{pointerEvents:"none"}}},i.default.createElement(y,{dangerouslySetInnerHTML:{__html:k},style:{pointerEvents:"none",display:"inline-block"}}))),E&&i.default.createElement(o.Group,{x:e.x,y:e.y,rotation:e.rotation},i.default.createElement(m.Html,null,i.default.createElement(x,{html:k,element:e,onChange:t=>{e.set({text:t})},onBlur:e=>{S(!1)}}))),(T||_)&&i.default.createElement(h.Highlighter,{element:e}))});
286
+ `,x=({html:e,onBlur:t,onChange:r,element:n})=>{const l=i.default.useRef(null);return i.default.useEffect(()=>{if(!l.current)return;const e=new a.default(l.current,{toolbar:!1,keyboard:!1,clipboard:{matchVisual:!1}});return exports.quillRef.editor.instance=e,window.__polotnoQuill=e,e.on("text-change",()=>{var t;e.getSelection()&&(exports.quillRef.currentFormat=e.getFormat()),r(null===(t=l.current)||void 0===t?void 0:t.childNodes[0].innerHTML)}),e.setSelection(0,0,"api"),e.on("selection-change",r=>{r||t(),r&&(exports.quillRef.currentFormat=e.getFormat())}),l.current.childNodes[0].addEventListener("blur",e=>{var r;(null===(r=e.relatedTarget)||void 0===r?void 0:r.classList.contains("ql-clipboard"))||t()}),()=>{exports.quillRef.editor.instance=null,exports.quillRef.currentFormat={},delete window.__polotnoQuill}},[]),i.default.useEffect(()=>{var t;const r=exports.quillRef.editor.instance,i=r.getSelection();if((null===(t=l.current)||void 0===t?void 0:t.childNodes[0].innerHTML)!==n.text){var o=r.clipboard.convert("<div class='ql-editor' style='outline: none;'>"+e+"<p><br></p></div>");r.setContents(o),r.history.clear(),i&&(r.setSelection(i.index,i.length),exports.quillRef.currentFormat=r.getFormat())}},[n.text]),i.default.createElement(y,{ref:l,style:{fontSize:n.fontSize,color:n.fill,width:n.width,fontFamily:n.fontFamily,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing,textAlign:n.align}})};function b(e,t,r){return i.default.useMemo(()=>(0,f.detectSize)(e),[e,t.width,r])}const w=10;exports.HTMLElement=(0,l.observer)(({element:e,store:t})=>{const r=i.default.useRef(null),[n,l]=i.default.useState(),[a,p]=i.default.useState(!1),[w,q]=i.default.useState(!0),[E,S]=i.default.useState(!1),[_,F]=i.default.useState(!1),T=t.selectedElements.indexOf(e)>=0,[M]=(0,c.useFontLoader)(t,e.fontFamily);(0,g.useFadeIn)(r);const $=M?e.fontFamily:"Arial",k=`<div style="width: ${e.width||100}px; color: ${e.fill}; font-size: ${e.fontSize}px; font-family: '${$}'; text-decoration: ${e.textDecoration}; text-align: ${e.align}; line-height: ${e.lineHeight}; letter-spacing: ${e.letterSpacing}; font-style: ${e.fontStyle}; font-weight: ${e.fontWeight}; -webkit-text-stroke: ${e.strokeWidth}px ${e.stroke};" contentEditable>${e.text}</div>`,{width:L,height:R}=b(k,e,M);i.default.useEffect(()=>{e.set({height:R})},[R]),i.default.useLayoutEffect(()=>{if(a||E)return;const t=(0,v.incrementLoader)(`text ${e.id}`);q(!0),async function(){await new Promise(e=>setTimeout(e));const r=await(0,f.htmlToCanvas)({html:k,width:e.width||1,height:R||1,fontFamily:$});l(r),q(!1),u.default.Util.requestAnimFrame(t)}()},[k,a,R,E,$]);const H=a||w;return i.default.useLayoutEffect(()=>s.autorun(()=>{const t=r.current;(0,d.applyFilter)(t,e)}),[n,H]),i.default.createElement(i.default.Fragment,null,i.default.createElement(o.Image,{ref:r,name:"element",image:n,x:e.x,y:e.y,rotation:e.rotation,width:e.width,height:e.height,visible:!H,draggable:!e.locked,opacity:E?0:e.opacity,shadowEnabled:e.shadowEnabled,shadowBlur:e.shadowBlur,onMouseEnter:()=>{F(!0)},onMouseLeave:()=>{F(!1)},onDragStart:()=>{t.history.startTransaction()},onDragMove:t=>{setTimeout(()=>{e.set({x:t.target.x(),y:t.target.y()})})},onDragEnd:r=>{e.set({x:r.target.x(),y:r.target.y()}),t.history.endTransaction()},id:e.id,onDblClick:()=>{e.locked||S(!0)},onDblTap:()=>{e.locked||S(!0)},onTransformStart:e=>{var t;const r=(null===(t=e.target.getStage())||void 0===t?void 0:t.findOne("Transformer")).getActiveAnchor();("middle-left"===r||"middle-right"===r)&&p(!0)},onTransform:t=>{var r;const n=(null===(r=t.target.getStage())||void 0===r?void 0:r.findOne("Transformer")).getActiveAnchor();if("middle-left"===n||"middle-right"===n){const r=t.target.scaleX(),n=Math.max(t.target.width()*r,e.fontSize);t.target.width(n),t.target.scaleX(1),e.set({width:n})}e.set({x:t.target.x(),y:t.target.y(),rotation:t.target.rotation()})},onTransformEnd:t=>{p(!1),q(!0);const r=t.target.scaleX();t.target.scaleX(1),t.target.scaleY(1),e.set({fontSize:e.fontSize*r,width:t.target.width()*r,x:t.target.x(),y:t.target.y(),rotation:t.target.rotation()})}}),H&&i.default.createElement(o.Group,{x:e.x,y:e.y,rotation:e.rotation},i.default.createElement(m.Html,{divProps:{style:{pointerEvents:"none"}}},i.default.createElement(y,{dangerouslySetInnerHTML:{__html:k},style:{pointerEvents:"none",display:"inline-block"}}))),E&&i.default.createElement(o.Group,{x:e.x,y:e.y,rotation:e.rotation},i.default.createElement(m.Html,null,i.default.createElement(x,{html:k,element:e,onChange:t=>{e.set({text:t})},onBlur:e=>{S(!1)}}))),(T||_)&&i.default.createElement(h.Highlighter,{element:e}))});
287
287
  },{"react":"HdMw","mobx-react-lite":"ZfSi","react-konva":"Sgug","quill/dist/quill":"qREC","konva":"aTGn","mobx":"BzvP","./apply-filters":"SIWI","./text-element":"Fpgh","../utils/html2canvas":"vcNA","./use-fadein":"N3c2","./highlighter":"cEy1","react-konva-utils":"jXQU","../utils/styled":"PsiH","../utils/loader":"bN4e"}],"XEPK":[function(require,module,exports) {
288
288
  "use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.registerShapeComponent=void 0;const t=e(require("react")),r=require("mobx-react-lite"),n=require("./text-element"),l=require("./image-element"),o=require("./html-element"),i=require("../utils/flags"),m={text:n.TextElement,image:l.ImageElement,svg:l.ImageElement};function s(e,t){m[e]=t}exports.registerShapeComponent=s,exports.default=(0,r.observer)(e=>{let r=m[e.element.type];return"text"===e.element.type&&i.flags.htmlRenderEnabled&&(r=o.HTMLElement),e.element.visible?r?t.default.createElement(r,Object.assign({},e)):(console.error("Can not find component for "+e.element.type),null):null});
289
289
  },{"react":"HdMw","mobx-react-lite":"ZfSi","./text-element":"Fpgh","./image-element":"VbEp","./html-element":"BLZX","../utils/flags":"IDY9"}],"RXmf":[function(require,module,exports) {
@@ -833,11 +833,11 @@ var e="undefined"!=typeof Element,r="function"==typeof Map,t="function"==typeof
833
833
  },{"@popperjs/core":"S1OH"}],"mZnF":[function(require,module,exports) {
834
834
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ContextMenu2",{enumerable:!0,get:function(){return t.ContextMenu2}}),Object.defineProperty(exports,"PlacementOptions",{enumerable:!0,get:function(){return n.PlacementOptions}}),Object.defineProperty(exports,"Popover2",{enumerable:!0,get:function(){return o.Popover2}}),Object.defineProperty(exports,"Popover2InteractionKind",{enumerable:!0,get:function(){return o.Popover2InteractionKind}}),Object.defineProperty(exports,"ResizeSensor2",{enumerable:!0,get:function(){return u.ResizeSensor2}}),Object.defineProperty(exports,"Tooltip2",{enumerable:!0,get:function(){return i.Tooltip2}}),exports.Errors=exports.Classes=void 0;var e=s(require("./classes"));exports.Classes=e;var r=s(require("./errors"));exports.Errors=r;var t=require("./contextMenu2"),n=require("./popover2SharedProps"),o=require("./popover2"),u=require("./resizeSensor2"),i=require("./tooltip2");function p(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap,t=new WeakMap;return(p=function(e){return e?t:r})(e)}function s(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=p(r);if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=o?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u]}return n.default=e,t&&t.set(e,n),n}
835
835
  },{"./classes":"e4eA","./errors":"gQJg","./contextMenu2":"mDEr","./popover2SharedProps":"r11X","./popover2":"r9m3","./resizeSensor2":"HAyF","./tooltip2":"d4OQ"}],"FlVj":[function(require,module,exports) {
836
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.t=exports.getTranslations=exports.setTranslations=void 0;const e=require("mobx"),o=(0,e.observable)({toolbar:{opacity:"Opacity",effects:"Effects",blur:"Blur",brightness:"Brightness",sepia:"Sepia",grayscale:"Grayscale",textStroke:"Text Stroke",shadow:"Shadow",border:"Border",cornerRadius:"Corner Radius",position:"Position",layering:"Layering",toForward:"To forward",up:"Up",down:"Down",toBottom:"To bottom",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignTop:"Align top",alignMiddle:"Align middle",alignBottom:"Align bottom",flip:"Flip",flipHorizontally:"Flip horizontally",flipVertically:"Flip vertically",fitToBackground:"Fit to page",removeBackground:"Remove background",cancelRemoveBackground:"Cancel",confirmRemoveBackground:"Confirm",crop:"Crop",cropDone:"Done",cropCancel:"Cancel",removeClip:"Remove clip",removeMask:"Remove mask",transparency:"Transparency",lockedDescription:"Object is locked. Unlock it to allow changes from canvas.",unlockedDescription:"Object is unlocked. Lock it to prevent changes from canvas.",removeElements:"Remove elements",duplicateElements:"Duplicate elements",download:"Download",saveAsImage:"Save as image",saveAsPDF:"Save as PDF",selectable:"Selectable",alwaysOnTop:"Always on top",showInExport:"Show in export"},workspace:{noPages:"There are no pages yet...",addPage:"Add page",removePage:"Remove page",duplicatePage:"Duplicate page",moveUp:"Move up",moveDown:"Move down"},scale:{reset:"Reset"},error:{removeBackground:"Ops! Something went wrong. Background can not be removed."},sidePanel:{templates:"Templates",searchTemplatesWithSameSize:"Show templates with the same size",searchPlaceholder:"Search...",otherFormats:"Other formats",noResults:"No results",error:"Loading is failed...",text:"Text",uploadFont:"Upload font",myFonts:"My fonts",photos:"Photos",elements:"Elements",upload:"Upload",uploadImage:"Upload Image",uploadTip:"Do you want to upload your own images?",background:"Background",resize:"Resize",useMagicResize:"Use magic resize",width:"Width",height:"Height",magicResizeDescription:"Magic resize will automatically resize and move all elements on the canvas",headerText:"Header",createHeader:"Create header",subHeaderText:"Sub Header",createSubHeader:"Create sub header",bodyText:"Body text",createBody:"Create body text"}});function t(e,o){var t,a=o.split("."),r=e;for(t=0;t<a.length;++t){if(null==r[a[t]])return;r=r[a[t]]}return r}const a=e=>e&&"object"==typeof e;function r(e,o){Object.keys(o).forEach(t=>{const n=e[t],s=o[t];a(s)&&a(n)?r(n,s):e[t]=s})}exports.setTranslations=(0,e.action)(e=>{r(o,e)});const n=()=>(0,e.toJS)(o);exports.getTranslations=n;const s={},i=e=>{const a=t(o,e);if(void 0!==a)return a;s[e]||(s[e]=!0,console.warn(`Missing translation '${e}'`));const r=e.split(".");return r[r.length-1]};exports.t=i;
836
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.t=exports.getTranslations=exports.setTranslations=void 0;const e=require("mobx"),o=(0,e.observable)({toolbar:{opacity:"Opacity",effects:"Effects",blur:"Blur",brightness:"Brightness",sepia:"Sepia",grayscale:"Grayscale",textStroke:"Text Stroke",shadow:"Shadow",border:"Border",cornerRadius:"Corner Radius",position:"Position",layering:"Layering",toForward:"To forward",up:"Up",down:"Down",toBottom:"To bottom",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignTop:"Align top",alignMiddle:"Align middle",alignBottom:"Align bottom",flip:"Flip",flipHorizontally:"Flip horizontally",flipVertically:"Flip vertically",fitToBackground:"Fit to page",removeBackground:"Remove background",cancelRemoveBackground:"Cancel",confirmRemoveBackground:"Confirm",crop:"Crop",cropDone:"Done",cropCancel:"Cancel",removeClip:"Remove clip",removeMask:"Remove mask",transparency:"Transparency",lockedDescription:"Object is locked. Unlock it to allow changes from canvas.",unlockedDescription:"Object is unlocked. Lock it to prevent changes from canvas.",removeElements:"Remove elements",duplicateElements:"Duplicate elements",download:"Download",saveAsImage:"Save as image",saveAsPDF:"Save as PDF",selectable:"Selectable",alwaysOnTop:"Always on top",showInExport:"Show in export"},workspace:{noPages:"There are no pages yet...",addPage:"Add page",removePage:"Remove page",duplicatePage:"Duplicate page",moveUp:"Move up",moveDown:"Move down"},scale:{reset:"Reset"},error:{removeBackground:"Ops! Something went wrong. Background can not be removed."},sidePanel:{templates:"Templates",searchTemplatesWithSameSize:"Show templates with the same size",searchPlaceholder:"Search...",otherFormats:"Other formats",noResults:"No results",error:"Loading is failed...",text:"Text",uploadFont:"Upload font",myFonts:"My fonts",photos:"Photos",elements:"Elements",upload:"Upload",uploadImage:"Upload Image",uploadTip:"Do you want to upload your own images?",background:"Background",resize:"Resize",layers:"Layers",layersTip:"Elements on your active page:",noLayers:"No elements on the page...",useMagicResize:"Use magic resize",width:"Width",height:"Height",magicResizeDescription:"Magic resize will automatically resize and move all elements on the canvas",headerText:"Header",createHeader:"Create header",subHeaderText:"Sub Header",createSubHeader:"Create sub header",bodyText:"Body text",createBody:"Create body text"}});function t(e,o){var t,a=o.split("."),r=e;for(t=0;t<a.length;++t){if(null==r[a[t]])return;r=r[a[t]]}return r}const a=e=>e&&"object"==typeof e;function r(e,o){Object.keys(o).forEach(t=>{const n=e[t],s=o[t];a(s)&&a(n)?r(n,s):e[t]=s})}exports.setTranslations=(0,e.action)(e=>{r(o,e)});const n=()=>(0,e.toJS)(o);exports.getTranslations=n;const s={},i=e=>{const a=t(o,e);if(void 0!==a)return a;s[e]||(s[e]=!0,console.warn(`Missing translation '${e}'`));const r=e.split(".");return r[r.length-1]};exports.t=i;
837
837
  },{"mobx":"BzvP"}],"smDv":[function(require,module,exports) {
838
838
  "use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageControls=void 0;const t=e(require("react")),n=require("mobx-react-lite"),o=require("@blueprintjs/core"),a=require("@blueprintjs/popover2"),l=require("../utils/l10n");exports.PageControls=(0,n.observer)(({store:e,page:n,xPadding:i,yPadding:r})=>{const d=e.pages.length>1,c=e.pages.indexOf(n);return t.default.createElement("div",{style:{position:"absolute",top:r-40+"px",right:i+"px"}},d&&t.default.createElement(a.Tooltip2,{content:(0,l.t)("workspace.moveUp"),disabled:0===c},t.default.createElement(o.Button,{icon:"chevron-up",minimal:!0,disabled:0===c,onClick:()=>{n.setZIndex(c-1)}})),d&&t.default.createElement(a.Tooltip2,{content:(0,l.t)("workspace.moveDown"),disabled:c===e.pages.length-1},t.default.createElement(o.Button,{icon:"chevron-down",minimal:!0,disabled:c===e.pages.length-1,onClick:()=>{const t=e.pages.indexOf(n);n.setZIndex(t+1)}})),t.default.createElement(a.Tooltip2,{content:(0,l.t)("workspace.duplicatePage")},t.default.createElement(o.Button,{icon:"duplicate",minimal:!0,onClick:()=>{n.clone()}})),d&&t.default.createElement(a.Tooltip2,{content:(0,l.t)("workspace.removePage")},t.default.createElement(o.Button,{icon:"trash",minimal:!0,onClick:()=>{e.deletePages([n.id])}})),t.default.createElement(a.Tooltip2,{content:(0,l.t)("workspace.addPage")},t.default.createElement(o.Button,{icon:"insert",minimal:!0,onClick:()=>{var t;const o=e.addPage({bleed:(null===(t=e.activePage)||void 0===t?void 0:t.bleed)||0}),a=e.pages.indexOf(n);o.setZIndex(a+1)}})))});
839
839
  },{"react":"HdMw","mobx-react-lite":"ZfSi","@blueprintjs/core":"Ydrz","@blueprintjs/popover2":"mZnF","../utils/l10n":"FlVj"}],"Ic0q":[function(require,module,exports) {
840
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setAPI=exports.iconscoutDownload=exports.iconscoutList=exports.unsplashDownload=exports.unsplashList=exports.textTemplateList=exports.templateList=exports.removeBackground=exports.polotnoShapesList=exports.getGoogleFontImage=exports.getGoogleFontsListAPI=exports.URLS=exports.URL=exports.API=void 0;const e=require("./validate-key");exports.API="https://api.polotno.dev/api",exports.URL="https://api.polotno.dev";const o={},t=(e,t)=>{o[e]||(o[e]=!0,console.error(t))},s=(e,o,t)=>e.replace(new RegExp(o,"g"),t),p="API for iconscout is provided as a demonstration.\nFor production usage you have to use your own API endpoint.\nhttps://iconscout.com/developers, https://iconscout.com/legal/api-license-development-agreement\nhttps://polotno.dev/docs/server-api";exports.URLS={unsplashList:({query:o,page:t=1})=>`${exports.API}/get-unsplash?query=${o}&per_page=20&page=${t}&KEY=${(0,e.getKey)()}`,unsplashDownload:o=>`${exports.API}/download-unsplash?id=${o}&KEY=${(0,e.getKey)()}`,iconscoutList:({query:o,page:s=1})=>(t("iconscout",p),`${exports.API}/get-iconscout?query=${o}&page=${s}&KEY=${(0,e.getKey)()}`),iconscoutDownload:o=>(t("iconscout",p),`${exports.API}/download-iconscout?uuid=${o}&KEY=${(0,e.getKey)()}`),templateList:({query:o,page:t=1,sizeQuery:s})=>`${exports.API}/get-templates?${s}&query=${o}&per_page=30&page=${t}&KEY=${(0,e.getKey)()}`};const r=()=>`${exports.API}/get-google-fonts?KEY=${(0,e.getKey)()}`;exports.getGoogleFontsListAPI=r;const n=e=>{return`${exports.URL}/google-fonts-previews/black/${o=e," ","-",o.replace(new RegExp(" ","g"),"-")}.png`;var o};exports.getGoogleFontImage=n;const a=()=>`${exports.API}/get-basic-shapes?KEY=${(0,e.getKey)()}`;exports.polotnoShapesList=a;const c=()=>`${exports.API}/remove-image-background?KEY=${(0,e.getKey)()}`;exports.removeBackground=c;const i=e=>exports.URLS.templateList(e);exports.templateList=i;const l=()=>`${exports.API}/get-text-templates?KEY=${(0,e.getKey)()}`;exports.textTemplateList=l;const x=e=>exports.URLS.unsplashList(e);exports.unsplashList=x;const g=e=>exports.URLS.unsplashDownload(e);exports.unsplashDownload=g;const u=e=>exports.URLS.iconscoutList(e);exports.iconscoutList=u;const d=e=>exports.URLS.iconscoutDownload(e);exports.iconscoutDownload=d;const L=(e,o)=>{exports.URLS[e]=o};exports.setAPI=L;
840
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setAPI=exports.iconscoutDownload=exports.iconscoutList=exports.svgapiDownload=exports.svgapiList=exports.unsplashDownload=exports.unsplashList=exports.textTemplateList=exports.templateList=exports.removeBackground=exports.polotnoShapesList=exports.getGoogleFontImage=exports.getGoogleFontsListAPI=exports.URLS=exports.URL=exports.API=void 0;const e=require("./validate-key");exports.API="https://api.polotno.dev/api",exports.URL="https://api.polotno.dev";const o={},t=(e,t)=>{o[e]||(o[e]=!0,console.error(t))},s=(e,o,t)=>e.replace(new RegExp(o,"g"),t),p="API for iconscout is provided as a demonstration.\nFor production usage you have to use your own API endpoint.\nhttps://iconscout.com/developers, https://iconscout.com/legal/api-license-development-agreement\nhttps://polotno.dev/docs/server-api";exports.URLS={unsplashList:({query:o,page:t=1})=>`${exports.API}/get-unsplash?query=${o}&per_page=20&page=${t}&KEY=${(0,e.getKey)()}`,unsplashDownload:o=>`${exports.API}/download-unsplash?id=${o}&KEY=${(0,e.getKey)()}`,svgapiList:({query:o,page:t=0})=>`${exports.API}/get-svgapi?query=${o}&page=${t}&per_page=20&KEY=${(0,e.getKey)()}`,svgapiDownload:o=>`${exports.API}/download-svgapi?path=${o}&KEY=${(0,e.getKey)()}`,iconscoutList:({query:o,page:s=1})=>(t("iconscout",p),`${exports.API}/get-iconscout?query=${o}&page=${s}&KEY=${(0,e.getKey)()}`),iconscoutDownload:o=>(t("iconscout",p),`${exports.API}/download-iconscout?uuid=${o}&KEY=${(0,e.getKey)()}`),templateList:({query:o,page:t=1,sizeQuery:s})=>`${exports.API}/get-templates?${s}&query=${o}&per_page=30&page=${t}&KEY=${(0,e.getKey)()}`};const r=()=>`${exports.API}/get-google-fonts?KEY=${(0,e.getKey)()}`;exports.getGoogleFontsListAPI=r;const n=e=>{return`${exports.URL}/google-fonts-previews/black/${o=e," ","-",o.replace(new RegExp(" ","g"),"-")}.png`;var o};exports.getGoogleFontImage=n;const a=()=>`${exports.API}/get-basic-shapes?KEY=${(0,e.getKey)()}`;exports.polotnoShapesList=a;const i=()=>`${exports.API}/remove-image-background?KEY=${(0,e.getKey)()}`;exports.removeBackground=i;const g=e=>exports.URLS.templateList(e);exports.templateList=g;const c=()=>`${exports.API}/get-text-templates?KEY=${(0,e.getKey)()}`;exports.textTemplateList=c;const x=e=>exports.URLS.unsplashList(e);exports.unsplashList=x;const l=e=>exports.URLS.unsplashDownload(e);exports.unsplashDownload=l;const u=e=>exports.URLS.svgapiList(e);exports.svgapiList=u;const d=e=>exports.URLS.svgapiDownload(e);exports.svgapiDownload=d;const $=e=>exports.URLS.iconscoutList(e);exports.iconscoutList=$;const L=e=>exports.URLS.iconscoutDownload(e);exports.iconscoutDownload=L;const v=(e,o)=>{exports.URLS[e]=o};exports.setAPI=v;
841
841
  },{"./validate-key":"zree"}],"zree":[function(require,module,exports) {
842
842
  "use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,o,n){void 0===n&&(n=o),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[o]}})}:function(e,t,o,n){void 0===n&&(n=o),e[n]=t[o]}),t=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(o){if(o&&o.__esModule)return o;var n={};if(null!=o)for(var i in o)"default"!==i&&Object.prototype.hasOwnProperty.call(o,i)&&e(n,o,i);return t(n,o),n};Object.defineProperty(exports,"__esModule",{value:!0}),exports.validateKey=exports.isKeyPaid=exports.getKey=exports.shouldShowCredit=void 0;const n=o(require("mobx")),i=require("./api"),a=require("./flags");exports.shouldShowCredit=n.observable({value:!1});const r=n.action(()=>{exports.shouldShowCredit.value=!0});let s="";const l=()=>s||"";exports.getKey=l;const d=5,c=3e3,u="Polotno API is initialized without API key. It may lead to unexpected behavior and stop working. Please create API key here: https://polotno.dev/cabinet",p="Polotno API key is not valid. Please get new API key here: https://polotno.dev/cabinet",h="Can not validate Polotno API key. Please report to anton@polotno.dev immediately.",v="%cPolotno Free Version. Development or non-commercial usage only. https://polotno.dev/";let f=window.location.origin;const g=navigator.userAgent.indexOf("Headless")>-1,y=navigator.userAgent.indexOf("Electron")>-1;"file://"===f&&g&&(f="headless"),"file://"===f&&y&&(f="electron");const P=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${f}" here: https://polotno.dev/cabinet`;async function b(e){for(let t=0;t<5;t++)try{const t=await fetch(i.API+"/validate-key",{method:"POST",body:JSON.stringify({key:e,site:location.host+location.pathname})});if(!e)return console.warn(u),!1;if(200!==t.status){await new Promise(e=>setTimeout(e,3e3));continue}const o=await t.json();return o.is_valid||console.warn(p),o.is_paid||console.log(v,"background: rgb(0, 161, 255); color: white; padding: 5px; margin: 5px;"),o.is_domain_valid||console.log(P,"background: rgba(247, 101, 68, 1); color: white; padding: 5px; margin: 5px;"),(0,a.useRemoveBackground)(o.remove_background_enabled),o.is_paid||!1}catch(e){await new Promise(e=>setTimeout(e,3e3))}return console.error(h),!0}async function m(e,t){s=e,await b(e)&&!t||r()}exports.isKeyPaid=b,exports.validateKey=m;
843
843
  },{"mobx":"BzvP","./api":"Ic0q","./flags":"IDY9"}],"Co9b":[function(require,module,exports) {
@@ -845,7 +845,7 @@ var e="undefined"!=typeof Element,r="function"==typeof Map,t="function"==typeof
845
845
  },{"react":"HdMw","mobx-react-lite":"ZfSi","mobx":"BzvP","react-konva":"Sgug","use-image":"MJM3","konva":"aTGn","./element":"XEPK","./use-transformer-snap":"F86d","./image-element":"VbEp","../utils/crop":"hfHf","./page-controls":"smDv","../utils/validate-key":"zree","../utils/math":"RXmf"}],"NI5R":[function(require,module,exports) {
846
846
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.handleHotkey=void 0;let e=[];function t(t,o){var l,d,n,r;if("INPUT"===(null===(l=document.activeElement)||void 0===l?void 0:l.tagName)||"TEXTAREA"===(null===(d=document.activeElement)||void 0===d?void 0:d.tagName)||"true"===(null===(n=document.activeElement)||void 0===n?void 0:n.contentEditable))return;46!==t.keyCode&&8!==t.keyCode||o.deleteElements(o.selectedElementsIds);const c=t.ctrlKey||t.metaKey,s=t.shiftKey;if(c&&"KeyZ"===t.code&&(t.preventDefault(),o.history.undo()),c&&s&&"KeyZ"===t.code&&(t.preventDefault(),o.history.redo()),c&&"KeyA"===t.code&&(t.preventDefault(),o.selectElements((null===(r=o.activePage)||void 0===r?void 0:r.children.map(e=>e.id))||[])),c&&"KeyC"===t.code&&(t.preventDefault(),e=o.selectedElements.map(e=>e.toJSON())),c&&"KeyX"===t.code&&(t.preventDefault(),e=o.selectedElements.map(e=>e.toJSON()),o.deleteElements(o.selectedElementsIds)),c&&"KeyV"===t.code){t.preventDefault();const l=o.width/20;o.history.transaction(()=>{e.forEach(e=>{var t;delete e.id,e.x+=l,e.y+=l,null===(t=o.activePage)||void 0===t||t.addElement(e)})}),o.history.redo()}"ArrowDown"===t.code&&(t.preventDefault(),o.selectedElements.forEach(e=>{e.set({y:e.y+1})})),"ArrowUp"===t.code&&(t.preventDefault(),o.selectedElements.forEach(e=>{e.set({y:e.y-1})})),"ArrowLeft"===t.code&&(t.preventDefault(),o.selectedElements.forEach(e=>{e.set({x:e.x-1})})),"ArrowRight"===t.code&&(t.preventDefault(),o.selectedElements.forEach(e=>{e.set({x:e.x+1})}))}exports.handleHotkey=t;
847
847
  },{}],"twsc":[function(require,module,exports) {
848
- "use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Workspace=void 0;const t=e(require("react")),r=require("mobx-react-lite"),o=e(require("./page")),a=require("./hotkeys"),n=require("../utils/l10n"),l="Polotno warning: <Workspace /> component can not automatically detect its size.\nWidth or height of parent elements is equal 0.\nPlease make sure it has non-zero size. You may need to adjust it with your styles. <Workspace /> will automatically fit into parent container.\nFor simpler debugging here is the log of the parent element:",s=(e,r,o,a,n)=>{const l=t.default.useRef({width:r,height:o}),s=t.default.useRef({top:0,left:0});t.default.useEffect(()=>{const t=e.current,r=()=>{s.current={top:t.scrollTop,left:t.scrollLeft}};return t.addEventListener("scroll",r),()=>{t.removeEventListener("scroll",r)}},[]),t.default.useLayoutEffect(()=>{if(!e.current)return;const t=e.current,a=(s.current.left+t.offsetWidth/2)/l.current.width,n=(s.current.top+t.offsetHeight/2)/l.current.height;t.scrollLeft=a*r-t.offsetWidth/2,t.scrollTop=n*o-t.offsetHeight/2,l.current={width:r,height:o}},[a,r,o])},c=(e,r,o)=>{const a=t.default.useRef(!1),n=t.default.useRef(null);t.default.useEffect(()=>{const t=e.current,r=()=>{a.current=!0,clearTimeout(n.current),n.current=setTimeout(()=>{a.current=!1},300)};return t.addEventListener("scroll",r),()=>{t.removeEventListener("scroll",r)}},[]);const l=o.pages.indexOf(o.activePage);t.default.useLayoutEffect(()=>{if(!o.activePage)return;if(!e.current)return;if(a.current)return;const t=e.current,n=o.pages.indexOf(o.activePage)*r;Math.abs(n-t.scrollTop)>.9*r&&(t.scrollTop=n)},[o.activePage,l])};exports.Workspace=(0,r.observer)(({store:e,pageControlsEnabled:r,backgroundColor:i,pageBorderColor:u,activePageBorderColor:d,components:f})=>{const[h,g]=t.default.useState({width:100,height:100}),p=t.default.useRef(h),m=t.default.useRef(null),w=t.default.useRef(null),v=e._bleedVisible?Math.max(0,...e.pages.map(e=>e.bleed)):0,b=Math.max(...e.pages.map(e=>e.computedWidth)),x=Math.max(...e.pages.map(e=>e.computedHeight)),E=b+2*v,k=x+2*v,y=()=>{if(null===m.current)return;const t=m.current.getBoundingClientRect();0!==t.width&&0!==t.height||(console.warn(l),console.log(m.current));const r=w.current.clientWidth||t.width,o={width:r,height:t.height};(p.current.width!==o.width||p.current.height!==o.height)&&(g(o),p.current=o);const a=(r-16)/E,n=(t.height-90)/k,s=Math.max(Math.min(a,n),.01);e.scaleToFit!==s&&(e.setScale(s),e._setScaleToFit(s))};t.default.useEffect(y,[E,k]),t.default.useEffect(()=>{const e=m.current;if(window.ResizeObserver){const t=new ResizeObserver(y);return t.observe(e),()=>t.unobserve(e)}{const e=setInterval(y,100);return()=>clearInterval(e)}},[E,k]);const P=Math.max(8,(h.width-E*e.scale)/2),M=k*e.scale*e.pages.length,C=Math.max(45,(h.height-M)/e.pages.length/2);t.default.useEffect(()=>{const t=t=>{(0,a.handleHotkey)(t,e)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[]),s(w,E*e.scale+2*P,k*e.scale+2*C,e.scale),c(w,k*e.scale+2*C,e);const T=h.width>=E*e.scale+2*P,L=i||"#e8e8e8",R=e.pages.indexOf(e.activePage);return t.default.createElement("div",{ref:m,style:{width:"100%",height:"100%",position:"relative",outline:"none",flex:1,backgroundColor:L},tabIndex:0,className:"polotno-workspace-container"},t.default.createElement("div",{ref:w,onScroll:t=>{const r=t.currentTarget.childNodes[0].offsetHeight,o=t.currentTarget.scrollTop,a=Math.floor((o+h.height/2)/r),n=e.pages[a];n&&n.select()},style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"auto",overflowX:T?"hidden":"auto"},className:"polotno-workspace-inner"},e.pages.map((a,n)=>Math.abs(n-R)<=1||a._exporting?t.default.createElement(o.default,{key:a.id,page:a,xPadding:P,yPadding:C,width:E*e.scale+2*P,height:k*e.scale+2*C,store:e,pageControlsEnabled:r,backColor:L,pageBorderColor:u||"lightgrey",activePageBorderColor:d||"rgb(0, 161, 255)",components:f}):t.default.createElement("div",{key:a.id,style:{width:E*e.scale+2*P+"px",height:k*e.scale+2*C+"px"}})),0===e.pages.length&&t.default.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center"}},t.default.createElement("p",null,(0,n.t)("workspace.noPages")),t.default.createElement("button",{onClick:()=>{e.addPage()}},(0,n.t)("workspace.addPage")))))}),exports.default=exports.Workspace;
848
+ "use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Workspace=void 0;const t=e(require("react")),r=require("mobx-react-lite"),o=e(require("./page")),a=require("./hotkeys"),n=require("../utils/l10n"),l="Polotno warning: <Workspace /> component can not automatically detect its size.\nWidth or height of parent elements is equal 0.\nPlease make sure it has non-zero size. You may need to adjust it with your styles. <Workspace /> will automatically fit into parent container.\nFor simpler debugging here is the log of the parent element:",s=(e,r,o,a,n)=>{const l=t.default.useRef({width:r,height:o}),s=t.default.useRef({top:0,left:0});t.default.useEffect(()=>{const t=e.current,r=()=>{s.current={top:t.scrollTop,left:t.scrollLeft}};return t.addEventListener("scroll",r),()=>{t.removeEventListener("scroll",r)}},[]),t.default.useLayoutEffect(()=>{if(!e.current)return;const t=e.current,a=(s.current.left+t.offsetWidth/2)/l.current.width,n=(s.current.top+t.offsetHeight/2)/l.current.height;t.scrollLeft=a*r-t.offsetWidth/2,t.scrollTop=n*o-t.offsetHeight/2,l.current={width:r,height:o}},[a,r,o])},c=(e,r,o)=>{const a=t.default.useRef(!1),n=t.default.useRef(null);t.default.useEffect(()=>{const t=e.current,r=()=>{a.current=!0,clearTimeout(n.current),n.current=setTimeout(()=>{a.current=!1},300)};return t.addEventListener("scroll",r),()=>{t.removeEventListener("scroll",r)}},[]);const l=o.pages.indexOf(o.activePage);t.default.useLayoutEffect(()=>{if(!o.activePage)return;if(!e.current)return;if(a.current)return;const t=e.current,n=o.pages.indexOf(o.activePage)*r;Math.abs(n-t.scrollTop)>.9*r&&(t.scrollTop=n)},[o.activePage,l])},i=({store:e})=>t.default.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center"}},t.default.createElement("p",null,(0,n.t)("workspace.noPages")),t.default.createElement("button",{onClick:()=>{e.addPage()}},(0,n.t)("workspace.addPage")));exports.Workspace=(0,r.observer)(({store:e,pageControlsEnabled:r,backgroundColor:n,pageBorderColor:u,activePageBorderColor:d,components:f})=>{const[h,g]=t.default.useState({width:100,height:100}),p=t.default.useRef(h),m=t.default.useRef(null),v=t.default.useRef(null),w=e._bleedVisible?Math.max(0,...e.pages.map(e=>e.bleed)):0,b=Math.max(...e.pages.map(e=>e.computedWidth)),E=Math.max(...e.pages.map(e=>e.computedHeight)),x=b+2*w,k=E+2*w,y=()=>{if(null===m.current)return;const t=m.current.getBoundingClientRect();0!==t.width&&0!==t.height||(console.warn(l),console.log(m.current));const r=v.current.clientWidth||t.width,o={width:r,height:t.height};(p.current.width!==o.width||p.current.height!==o.height)&&(g(o),p.current=o);const a=(r-16)/x,n=(t.height-90)/k,s=Math.max(Math.min(a,n),.01);e.scaleToFit!==s&&(e.setScale(s),e._setScaleToFit(s))};t.default.useEffect(y,[x,k]),t.default.useEffect(()=>{const e=m.current;if(window.ResizeObserver){const t=new ResizeObserver(y);return t.observe(e),()=>t.unobserve(e)}{const e=setInterval(y,100);return()=>clearInterval(e)}},[x,k]);const P=Math.max(8,(h.width-x*e.scale)/2),M=k*e.scale*e.pages.length,C=Math.max(45,(h.height-M)/e.pages.length/2);t.default.useEffect(()=>{const t=t=>{(0,a.handleHotkey)(t,e)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[]),s(v,x*e.scale+2*P,k*e.scale+2*C,e.scale),c(v,k*e.scale+2*C,e);const T=h.width>=x*e.scale+2*P,L=n||"#e8e8e8",R=e.pages.indexOf(e.activePage),W=(null==f?void 0:f.NoPages)||i;return t.default.createElement("div",{ref:m,style:{width:"100%",height:"100%",position:"relative",outline:"none",flex:1,backgroundColor:L},tabIndex:0,className:"polotno-workspace-container"},t.default.createElement("div",{ref:v,onScroll:t=>{const r=t.currentTarget.childNodes[0].offsetHeight,o=t.currentTarget.scrollTop,a=Math.floor((o+h.height/2)/r),n=e.pages[a];n&&n.select()},style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"auto",overflowX:T?"hidden":"auto"},className:"polotno-workspace-inner"},e.pages.map((a,n)=>Math.abs(n-R)<=1||a._exporting?t.default.createElement(o.default,{key:a.id,page:a,xPadding:P,yPadding:C,width:x*e.scale+2*P,height:k*e.scale+2*C,store:e,pageControlsEnabled:r,backColor:L,pageBorderColor:u||"lightgrey",activePageBorderColor:d||"rgb(0, 161, 255)",components:f}):t.default.createElement("div",{key:a.id,style:{width:x*e.scale+2*P+"px",height:k*e.scale+2*C+"px"}})),0===e.pages.length&&t.default.createElement(W,{store:e})))}),exports.default=exports.Workspace;
849
849
  },{"react":"HdMw","mobx-react-lite":"ZfSi","./page":"Co9b","./hotkeys":"NI5R","../utils/l10n":"FlVj"}],"pk4v":[function(require,module,exports) {
850
850
  var process = require("process");
851
851
  var e=require("process");Object.defineProperty(exports,"__esModule",{value:!0}),exports.addDisposer=G,exports.addMiddleware=Ve,exports.applyAction=Pe,exports.applyPatch=m,exports.applySnapshot=_,exports.cast=q,exports.castFlowReturn=Zt,exports.castToReferenceSnapshot=Q,exports.castToSnapshot=K,exports.clone=L,exports.createActionTrackingMiddleware=de,exports.createActionTrackingMiddleware2=ve,exports.decorate=Ne,exports.destroy=$,exports.detach=U,exports.escapeJsonPath=rr,exports.flow=Jt,exports.getChildType=y,exports.getEnv=Y,exports.getIdentifier=R,exports.getLivelinessChecking=o,exports.getMembers=B,exports.getNodeId=X,exports.getParent=I,exports.getParentOfType=T,exports.getPath=E,exports.getPathParts=V,exports.getPropertyMembers=Z,exports.getRelativePath=H,exports.getRoot=C,exports.getRunningActionContext=Re,exports.getSnapshot=S,exports.getType=d,exports.hasParent=A,exports.hasParentOfType=x,exports.isActionContextChildOf=Fe,exports.isActionContextThisOrChildOf=Me,exports.isAlive=W,exports.isArrayType=Or,exports.isFrozenType=dn,exports.isIdentifierType=Cn,exports.isLateType=pn,exports.isLiteralType=Gr,exports.isMapType=yr,exports.isModelType=Er,exports.isOptionalType=nn,exports.isPrimitiveType=Ur,exports.isProtected=j,exports.isReferenceType=jn,exports.isRefinementType=Zr,exports.isRoot=N,exports.isStateTreeNode=nt,exports.isType=fe,exports.isUnionType=Qr,exports.isValidReference=F,exports.joinJsonPath=ir,exports.onAction=_e,exports.onPatch=v,exports.onSnapshot=g,exports.process=ht,exports.protect=P,exports.recordActions=je,exports.recordPatches=w,exports.resolveIdentifier=k,exports.resolvePath=D,exports.setLivelinessChecking=i,exports.setLivelynessChecking=a,exports.splitJsonPath=or,exports.toGenerator=qt,exports.toGeneratorFunction=Bt,exports.tryReference=z,exports.tryResolve=M,exports.typecheck=Be,exports.unescapeJsonPath=nr,exports.unprotect=O,exports.walk=J,exports.types=void 0;var t,r=require("mobx"),n="warn";function i(e){n=e}function o(){return n}function a(e){i(e)}!function(e){e.afterCreate="afterCreate",e.afterAttach="afterAttach",e.afterCreationFinalization="afterCreationFinalization",e.beforeDetach="beforeDetach",e.beforeDestroy="beforeDestroy"}(t||(t={}));var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)};function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var s=function(){return(s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function c(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}function p(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(u){o=[6,u],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}function f(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function b(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(u){i={error:u}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function h(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(b(arguments[t]));return e}function d(e){return it(e,1),ot(e).type}function y(e,t){return it(e,1),ot(e).getChildType(t)}function v(e,t){return it(e,1),$t(t,2),ot(e).onPatch(t)}function g(e,t){return it(e,1),$t(t,2),ot(e).onSnapshot(t)}function m(e,t){it(e,1),Ut(t,function(e){return"object"==typeof e},"object or array",2),ot(e).applyPatches(jt(t))}function w(e,t){it(e,1);var r,n={patches:[],reversedInversePatches:[]},i={},o={get recording(){return!!r},get patches(){return i.patches||(i.patches=n.patches.slice()),i.patches},get reversedInversePatches(){return i.reversedInversePatches||(i.reversedInversePatches=n.reversedInversePatches.slice()),i.reversedInversePatches},get inversePatches(){return i.inversePatches||(i.inversePatches=n.reversedInversePatches.slice().reverse()),i.inversePatches},stop:function(){r&&(r(),r=void 0)},resume:function(){r||(r=v(e,function(e,r){t&&!t(e,r,Re())||(n.patches.push(e),n.reversedInversePatches.unshift(r),i.patches=void 0,i.inversePatches=void 0,i.reversedInversePatches=void 0)}))},replay:function(t){m(t||e,n.patches)},undo:function(t){m(t||e,n.reversedInversePatches)}};return o.resume(),o}function P(e){it(e,1);var t=ot(e);if(!t.isRoot)throw mt("`protect` can only be invoked on root nodes");t.isProtectionEnabled=!0}function O(e){it(e,1);var t=ot(e);if(!t.isRoot)throw mt("`unprotect` can only be invoked on root nodes");t.isProtectionEnabled=!1}function j(e){return ot(e).isProtected}function _(e,t){return it(e,1),ot(e).applySnapshot(t)}function S(e,t){void 0===t&&(t=!0),it(e,1);var r=ot(e);return t?r.snapshot:xt(r.type.getSnapshot(r,!1))}function A(e,t){void 0===t&&(t=1),it(e,1),Wt(t,2,0);for(var r=ot(e).parent;r;){if(0==--t)return!0;r=r.parent}return!1}function I(e,t){void 0===t&&(t=1),it(e,1),Wt(t,2,0);for(var r=t,n=ot(e).parent;n;){if(0==--r)return n.storedValue;n=n.parent}throw mt("Failed to find the parent of "+ot(e)+" at depth "+t)}function x(e,t){it(e,1),be(t,2);for(var r=ot(e).parent;r;){if(t.is(r.storedValue))return!0;r=r.parent}return!1}function T(e,t){it(e,1),be(t,2);for(var r=ot(e).parent;r;){if(t.is(r.storedValue))return r.storedValue;r=r.parent}throw mt("Failed to find the parent of "+ot(e)+" of a given type")}function C(e){return it(e,1),ot(e).root.storedValue}function E(e){return it(e,1),ot(e).path}function V(e){return it(e,1),or(ot(e).path)}function N(e){return it(e,1),ot(e).isRoot}function D(e,t){it(e,1),Gt(t,2);var r=ct(ot(e),t);return r?r.value:void 0}function k(e,t,r){be(e,1),it(t,2),Nn(r,3);var n=ot(t).root.identifierCache.resolve(e,En(r));return null==n?void 0:n.value}function R(e){return it(e,1),ot(e).identifier}function z(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return;if(nt(r))return t?W(r)?r:void 0:r;throw mt("The reference to be checked is not one of node, null or undefined")}catch(n){if(n instanceof gn)return;throw n}}function F(e,t){void 0===t&&(t=!0);try{var r=e();if(null==r)return!1;if(nt(r))return!t||W(r);throw mt("The reference to be checked is not one of node, null or undefined")}catch(n){if(n instanceof gn)return!1;throw n}}function M(e,t){it(e,1),Gt(t,2);var r=ct(ot(e),t,!1);if(void 0!==r)try{return r.value}catch(n){return}}function H(e,t){return it(e,1),it(t,2),st(ot(e),ot(t))}function L(e,t){void 0===t&&(t=!0),it(e,1);var r=ot(e);return r.type.create(r.snapshot,!0===t?r.root.environment:!1===t?void 0:t)}function U(e){return it(e,1),ot(e).detach(),e}function $(e){it(e,1);var t=ot(e);t.isRoot?t.die():t.parent.removeChild(t.subpath)}function W(e){return it(e,1),ot(e).observableIsAlive}function G(e,t){return it(e,1),$t(t,2),ot(e).addDisposer(t),t}function Y(e){it(e,1);var t=ot(e).root.environment;return t||vt}function J(e,t){it(e,1),$t(t,2);var r=ot(e);r.getChildren().forEach(function(e){nt(e.storedValue)&&J(e.storedValue,t)}),t(r.storedValue)}function Z(e){var t;return Ut(t=nt(e)?d(e):e,function(e){return Er(e)},"model type or model instance",1),{name:t.name,properties:s({},t.properties)}}function B(e){var t=ot(e).type,n=s(s({},Z(t)),{actions:[],volatile:[],views:[]});return Object.getOwnPropertyNames(e).forEach(function(t){if(!(t in n.properties)){var i=Object.getOwnPropertyDescriptor(e,t);i.get?(0,r.isComputedProp)(e,t)?n.views.push(t):n.volatile.push(t):!0===i.value._isMSTAction?n.actions.push(t):(0,r.isObservableProp)(e,t)?n.volatile.push(t):n.views.push(t)}}),n}function q(e){return e}function K(e){return e}function Q(e){return e}function X(e){return it(e,1),ot(e).nodeId}var ee=function(){function e(e,t,r,n){Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"environment",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_escapedSubpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storedValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"aliveAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:Ke.INITIALIZING}),Object.defineProperty(this,"_hookSubscribers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pathAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.environment=n,this.baseSetParent(t,r)}return Object.defineProperty(e.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},set:function(e){var t=this.isAlive;this._state=e;var r=this.isAlive;this.aliveAtom&&t!==r&&this.aliveAtom.reportChanged()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fireInternalHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hookSubscribers&&this._hookSubscribers.emit(e,this,e)}}),Object.defineProperty(e.prototype,"registerHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._hookSubscribers||(this._hookSubscribers=new kt),this._hookSubscribers.register(e,t)}}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getReconciliationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type}}),Object.defineProperty(e.prototype,"baseSetParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._parent=e,this._subpath=t,this._escapedSubpath=void 0,this.pathAtom&&this.pathAtom.reportChanged()}}),Object.defineProperty(e.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getEscapedPath",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e&&(this.pathAtom||(this.pathAtom=(0,r.createAtom)("path")),this.pathAtom.reportObserved()),this.parent?(void 0===this._escapedSubpath&&(this._escapedSubpath=this._subpath?rr(this._subpath):""),this.parent.getEscapedPath(e)+"/"+this._escapedSubpath):""}}),Object.defineProperty(e.prototype,"isRoot",{get:function(){return null===this.parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAlive",{get:function(){return this.state!==Ke.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDetaching",{get:function(){return this.state===Ke.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=(0,r.createAtom)("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseFinalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(Lt()&&!this.isAlive)throw fail("assertion failed: cannot finalize the creation of a node that is already dead");if(this.state===Ke.CREATED){if(this.parent){if(this.parent.state!==Ke.FINALIZED)return;this.fireHook(t.afterAttach)}this.state=Ke.FINALIZED,e&&e()}}}),Object.defineProperty(e.prototype,"baseFinalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=Ke.DEAD}}),Object.defineProperty(e.prototype,"baseAboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.fireHook(t.beforeDestroy)}}),e}(),te=function(e){function t(t,r,n,i,o){var a=e.call(this,t,r,n,i)||this;try{a.storedValue=t.createNewInstance(o)}catch(u){throw a.state=Ke.DEAD,u}return a.state=Ke.CREATED,a.finalizeCreation(),a}return l(t,e),Object.defineProperty(t.prototype,"root",{get:function(){if(!this.parent)throw mt("This scalar node is not part of a tree");return this.parent.root},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.parent!==e,n=this.subpath!==t;if(r||n){if(Lt()){if(!t)throw mt("assertion failed: subpath expected");if(!e)throw mt("assertion failed: parent expected");if(r)throw mt("assertion failed: scalar nodes cannot change their parent")}this.environment=void 0,this.baseSetParent(this.parent,t)}}}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return xt(this.getSnapshot())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(t.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return this.type.name+"@"+e+(this.isAlive?"":" [dead]")}}),Object.defineProperty(t.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==Ke.DETACHING&&(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(t.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeCreation()}}),Object.defineProperty(t.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseAboutToDie()}}),Object.defineProperty(t.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeDeath()}}),Object.defineProperty(t.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.fireInternalHook(e)}}),t}(ee);te.prototype.die=(0,r.action)(te.prototype.die);var re,ne,ie=1,oe={onError:function(e){throw e}},ae=function(e){function n(t,n,i,o,a){var u=e.call(this,t,n,i,o)||this;if(Object.defineProperty(u,"nodeId",{enumerable:!0,configurable:!0,writable:!0,value:++ie}),Object.defineProperty(u,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"unnormalizedIdentifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifierCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"isProtectionEnabled",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_applyPatches",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_applySnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_autoUnbox",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"_isRunningAction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_hasSnapshotReaction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_observableInstanceState",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(u,"_childNodes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_initialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshotCreated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_snapshotComputed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_snapshotUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_internalEvents",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),u._snapshotComputed=(0,r.computed)(function(){return xt(u.getSnapshot())}),u.unbox=u.unbox.bind(u),u._initialSnapshot=xt(a),u.identifierAttribute=t.identifierAttribute,n||(u.identifierCache=new Xe),u._childNodes=t.initializeChildNodes(u,u._initialSnapshot),u.identifier=null,u.unnormalizedIdentifier=null,u.identifierAttribute&&u._initialSnapshot){var l=u._initialSnapshot[u.identifierAttribute];if(void 0===l){var s=u._childNodes[u.identifierAttribute];s&&(l=s.value)}if("string"!=typeof l&&"number"!=typeof l)throw mt("Instance identifier '"+u.identifierAttribute+"' for type '"+u.type.name+"' must be a string or a number");u.identifier=En(l),u.unnormalizedIdentifier=l}return n?n.root.identifierCache.addNodeToCache(u):u.identifierCache.addNodeToCache(u),u}return l(n,e),Object.defineProperty(n.prototype,"applyPatches",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applyPatches(e)}}),Object.defineProperty(n.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applySnapshot(e)}}),Object.defineProperty(n.prototype,"createObservableInstanceIfNeeded",{enumerable:!1,configurable:!0,writable:!0,value:function(){0===this._observableInstanceState&&this.createObservableInstance()}}),Object.defineProperty(n.prototype,"createObservableInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,r;if(Lt()&&this.state!==Ke.INITIALIZING)throw mt("assertion failed: the creation of the observable instance must be done on the initializing phase");this._observableInstanceState=1;for(var n=[],i=this.parent;i&&0===i._observableInstanceState;)n.unshift(i),i=i.parent;try{for(var o=f(n),a=o.next();!a.done;a=o.next()){a.value.createObservableInstanceIfNeeded()}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}var u=this.type;try{this.storedValue=u.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,u.finalizeNewInstance(this,this.storedValue)}catch(s){throw this.state=Ke.DEAD,s}finally{this._isRunningAction=!1}this._observableInstanceState=2,this._snapshotComputed.trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=vt,this.state=Ke.CREATED,this.fireHook(t.afterCreate),this.finalizeCreation()}}),Object.defineProperty(n.prototype,"root",{get:function(){var e=this.parent;return e?e.root:this},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"clearParent",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.parent){this.fireHook(t.beforeDetach);var e=this.state;this.state=Ke.DETACHING;var r=this.root,n=r.environment,i=r.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=n,this.identifierCache=i}finally{this.state=e}}}}),Object.defineProperty(n.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=e!==this.parent,i=r!==this.subpath;if(n||i){if(Lt()){if(!r)throw mt("assertion failed: subpath expected");if(!e)throw mt("assertion failed: new parent expected");if(this.parent&&n)throw mt("A node cannot exists twice in the state tree. Failed to add "+this+" to path '"+e.path+"/"+r+"'.");if(!this.parent&&e.root===this)throw mt("A state tree is not allowed to contain itself. Cannot assign "+this+" to path '"+e.path+"/"+r+"'");if(!this.parent&&this.environment&&this.environment!==e.root.environment)throw mt("A state tree cannot be made part of another state tree as long as their environments are different.")}n?(this.environment=void 0,e.root.identifierCache.mergeCache(this),this.baseSetParent(e,r),this.fireHook(t.afterAttach)):i&&this.baseSetParent(this.parent,r)}}}),Object.defineProperty(n.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this.fireInternalHook(e);var n=this.storedValue&&"object"==typeof this.storedValue&&this.storedValue[e];"function"==typeof n&&(r._allowStateChangesInsideComputed?(0,r._allowStateChangesInsideComputed)(function(){n.apply(t.storedValue)}):n.apply(this.storedValue))}}),Object.defineProperty(n.prototype,"snapshot",{get:function(){return this._snapshotComputed.get()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.isAlive?2===this._observableInstanceState?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath}}),Object.defineProperty(n.prototype,"_getActualSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(n.prototype,"_getCachedInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this._cachedInitialSnapshotCreated){var e=this.type,t=this._childNodes,r=this._initialSnapshot;this._cachedInitialSnapshot=e.processInitialSnapshot(t,r),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot}}),Object.defineProperty(n.prototype,"isRunningAction",{enumerable:!1,configurable:!0,writable:!0,value:function(){return!!this._isRunningAction||!this.isRoot&&this.parent.isRunningAction()}}),Object.defineProperty(n.prototype,"assertAlive",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=o();if(!this.isAlive&&"ignore"!==t){var r=this._getAssertAliveError(e);switch(t){case"error":throw mt(r);case"warn":Mt(r)}}}}),Object.defineProperty(n.prototype,"_getAssertAliveError",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getEscapedPath(!1)||this.pathUponDeath||"",r=e.subpath&&rr(e.subpath)||"",n=e.actionContext||Ie();n&&"action"!==n.type&&n.parentActionEvent&&(n=n.parentActionEvent);var i="";n&&null!=n.name&&(i=(n&&n.context&&E(n.context)||t)+"."+n.name+"()");return"You are trying to read or write to an object that is no longer part of a state tree. (Object type: '"+this.type.name+"', Path upon death: '"+t+"', Subpath: '"+r+"', Action: '"+i+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree."}}),Object.defineProperty(n.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.assertAlive({subpath:e}),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildNode(this,e):this._childNodes[e]}finally{this._autoUnbox=!0}}}),Object.defineProperty(n.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.assertAlive(vt),this._autoUnbox=!1;try{return 2===this._observableInstanceState?this.type.getChildren(this):ft(this._childNodes)}finally{this._autoUnbox=!0}}}),Object.defineProperty(n.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.type.getChildType(e)}}),Object.defineProperty(n.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"assertWritable",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.assertAlive(e),!this.isRunningAction()&&this.isProtected)throw mt("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")}}),Object.defineProperty(n.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.type.removeChild(this,e)}}),Object.defineProperty(n.prototype,"unbox",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e?(this.assertAlive({subpath:e.subpath||e.subpathUponDeath}),this._autoUnbox?e.value:e):e}}),Object.defineProperty(n.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=(this.isAlive?this.path:this.pathUponDeath)||"<root>",t=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+e+t+(this.isAlive?"":" [dead]")}}),Object.defineProperty(n.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this.baseFinalizeCreation(function(){var r,n;try{for(var i=f(e.getChildren()),o=i.next();!o.done;o=i.next()){o.value.finalizeCreation()}}catch(a){r={error:a}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}e.fireInternalHook(t.afterCreationFinalization)})}}),Object.defineProperty(n.prototype,"detach",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this.isAlive)throw mt("Error while detaching, node is not alive.");this.clearParent()}}),Object.defineProperty(n.prototype,"preboot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._applyPatches=Ee(this.storedValue,"@APPLY_PATCHES",function(t){t.forEach(function(t){if(t.path){var r=or(t.path);pt(e,r.slice(0,-1)).applyPatchLocally(r[r.length-1],t)}else e.type.applySnapshot(e,t.value)})}),this._applySnapshot=Ee(this.storedValue,"@APPLY_SNAPSHOT",function(t){if(t!==e.snapshot)return e.type.applySnapshot(e,t)}),Vt(this.storedValue,"$treenode",this),Vt(this.storedValue,"toJSON",ut)}}),Object.defineProperty(n.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAlive&&this.state!==Ke.DETACHING&&(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(n.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){0!==this._observableInstanceState&&(this.getChildren().forEach(function(e){e.aboutToDie()}),this.baseAboutToDie(),this._internalEventsEmit("dispose"),this._internalEventsClear("dispose"))}}),Object.defineProperty(n.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.getChildren().forEach(function(e){e.finalizeDeath()}),this.root.identifierCache.notifyDied(this);var e=this.snapshot;this._snapshotUponDeath=e,this._internalEventsClearAll(),this.baseFinalizeDeath()}}),Object.defineProperty(n.prototype,"onSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._addSnapshotReaction(),this._internalEventsRegister("snapshot",e)}}),Object.defineProperty(n.prototype,"emitSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEventsEmit("snapshot",e)}}),Object.defineProperty(n.prototype,"onPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsRegister("patch",e)}}),Object.defineProperty(n.prototype,"emitPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._internalEventsHasSubscribers("patch")){var r=b(Qt(_t({},e,{path:t.path.substr(this.path.length)+"/"+e.path})),2),n=r[0],i=r[1];this._internalEventsEmit("patch",n,i)}this.parent&&this.parent.emitPatch(e,t)}}),Object.defineProperty(n.prototype,"hasDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsHas("dispose",e)}}),Object.defineProperty(n.prototype,"addDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.hasDisposer(e))throw mt("cannot add a disposer when it is already registered for execution");this._internalEventsRegister("dispose",e,!0)}}),Object.defineProperty(n.prototype,"removeDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._internalEventsHas("dispose",e))throw mt("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister("dispose",e)}}),Object.defineProperty(n.prototype,"removeMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.middlewares){var t=this.middlewares.indexOf(e);t>=0&&this.middlewares.splice(t,1)}}}),Object.defineProperty(n.prototype,"addMiddleWare",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;void 0===t&&(t=!0);var n={handler:e,includeHooks:t};return this.middlewares?this.middlewares.push(n):this.middlewares=[n],function(){r.removeMiddleware(n)}}}),Object.defineProperty(n.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.assertWritable({subpath:e}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,e,t)}}),Object.defineProperty(n.prototype,"_addSnapshotReaction",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;if(!this._hasSnapshotReaction){var t=(0,r.reaction)(function(){return e.snapshot},function(t){return e.emitSnapshot(t)},oe);this.addDisposer(t),this._hasSnapshotReaction=!0}}}),Object.defineProperty(n.prototype,"_internalEventsHasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!!this._internalEvents&&this._internalEvents.hasSubscribers(e)}}),Object.defineProperty(n.prototype,"_internalEventsRegister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return void 0===r&&(r=!1),this._internalEvents||(this._internalEvents=new kt),this._internalEvents.register(e,t,r)}}),Object.defineProperty(n.prototype,"_internalEventsHas",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!!this._internalEvents&&this._internalEvents.has(e,t)}}),Object.defineProperty(n.prototype,"_internalEventsUnregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._internalEvents&&this._internalEvents.unregister(e,t)}}),Object.defineProperty(n.prototype,"_internalEventsEmit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];this._internalEvents&&(t=this._internalEvents).emit.apply(t,h([e],r))}}),Object.defineProperty(n.prototype,"_internalEventsClear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEvents&&this._internalEvents.clear(e)}}),Object.defineProperty(n.prototype,"_internalEventsClearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._internalEvents&&this._internalEvents.clearAll()}}),n}(ee);ae.prototype.createObservableInstance=(0,r.action)(ae.prototype.createObservableInstance),ae.prototype.detach=(0,r.action)(ae.prototype.detach),ae.prototype.die=(0,r.action)(ae.prototype.die),function(e){e[e.String=1]="String",e[e.Number=2]="Number",e[e.Boolean=4]="Boolean",e[e.Date=8]="Date",e[e.Literal=16]="Literal",e[e.Array=32]="Array",e[e.Map=64]="Map",e[e.Object=128]="Object",e[e.Frozen=256]="Frozen",e[e.Optional=512]="Optional",e[e.Reference=1024]="Reference",e[e.Identifier=2048]="Identifier",e[e.Late=4096]="Late",e[e.Refinement=8192]="Refinement",e[e.Union=16384]="Union",e[e.Null=32768]="Null",e[e.Undefined=65536]="Undefined",e[e.Integer=131072]="Integer",e[e.Custom=262144]="Custom",e[e.SnapshotProcessor=524288]="SnapshotProcessor"}(ne||(ne={}));var ue="cannotDetermine",le=Symbol("$type"),se=function(){function e(e){Object.defineProperty(this,re,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"C",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"S",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"T",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"N",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isType",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e}return Object.defineProperty(e.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Ze(this,e),this.instantiate(null,"",t,e).value}}),Object.defineProperty(e.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){throw mt("unimplemented method")}}),Object.defineProperty(e.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e===this}}),Object.defineProperty(e.prototype,"validate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(at(e)){var r=d(e);return this.isAssignableFrom(r)?Ge():Ye(t,e)}return this.isValidSnapshot(e,t)}}),Object.defineProperty(e.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return 0===this.validate(e,[{path:"",type:this}]).length}}),Object.defineProperty(e.prototype,"Type",{get:function(){throw mt("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"TypeWithoutSTN",{get:function(){throw mt("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"SnapshotType",{get:function(){throw mt("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"CreationType",{get:function(){throw mt("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`")},enumerable:!1,configurable:!0}),e}();re=le,se.prototype.create=(0,r.action)(se.prototype.create);var ce=function(e){function t(t){var r=e.call(this,t)||this;return Object.defineProperty(r,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r}return l(t,e),Object.defineProperty(t.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return void 0===t&&(t=this.getDefaultSnapshot()),e.prototype.create.call(this,t,r)}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.createObservableInstanceIfNeeded(),e.storedValue}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.identifierAttribute||e.identifier===En(t[e.identifierAttribute])}}),Object.defineProperty(t.prototype,"tryToReconcileNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.isDetaching&&(e.snapshot===t||(!(!nt(t)||ot(t)!==e)||!(e.type!==this||!At(t)||nt(t)||!this.isMatchingSnapshotId(e,t))&&(e.applySnapshot(t),!0)))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(this.tryToReconcileNode(e,t))return e.setParent(r,n),e;if(e.die(),nt(t)&&this.isAssignableFrom(d(t))){var i=ot(t);return i.setParent(r,n),i}return this.instantiate(r,n,void 0,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(se);ce.prototype.create=(0,r.action)(ce.prototype.create);var pe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l(t,e),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!e.isDetaching&&e.type===this&&e.storedValue===t)return e;var i=this.instantiate(r,n,void 0,t);return e.die(),i}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(se);function fe(e){return"object"==typeof e&&e&&!0===e.isType}function be(e,t){Ut(e,fe,"mobx-state-tree type",t)}var he=new Map;function de(e){return function(t,r,n){switch(t.type){case"action":if(e.filter&&!0!==e.filter(t))return r(t);var i=e.onStart(t);e.onResume(t,i),he.set(t.id,{call:t,context:i,async:!1});try{var o=r(t);return e.onSuspend(t,i),!1===he.get(t.id).async&&(he.delete(t.id),e.onSuccess(t,i,o)),o}catch(u){throw he.delete(t.id),e.onFail(t,i,u),u}case"flow_spawn":return(a=he.get(t.rootId)).async=!0,r(t);case"flow_resume":case"flow_resume_error":var a=he.get(t.rootId);e.onResume(t,a.context);try{return r(t)}finally{e.onSuspend(t,a.context)}case"flow_throw":a=he.get(t.rootId);return he.delete(t.rootId),e.onFail(t,a.context,t.args[0]),r(t);case"flow_return":a=he.get(t.rootId);return he.delete(t.rootId),e.onSuccess(t,a.context,t.args[0]),r(t)}}}var ye=function(){function e(e,t){Object.defineProperty(this,"hooks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"call",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"flowsPending",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"running",{enumerable:!0,configurable:!0,writable:!0,value:!0}),e&&e.onStart(t)}return Object.defineProperty(e.prototype,"finish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.running&&(this.running=!1,this.hooks&&this.hooks.onFinish(this.call,e))}}),Object.defineProperty(e.prototype,"incFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending++}}),Object.defineProperty(e.prototype,"decFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending--}}),Object.defineProperty(e.prototype,"hasFlowsPending",{get:function(){return this.flowsPending>0},enumerable:!1,configurable:!0}),e}();function ve(e){var t=new WeakMap;return function(r,n){var i=r.parentActionEvent?t.get(r.parentActionEvent):void 0;if("action"===r.type){var o=s(s({},r),{env:i&&i.call.env,parentCall:i&&i.call}),a=!e.filter||e.filter(o),u=new ye(a?e:void 0,o);t.set(r,u);var l=void 0;try{l=n(r)}catch(p){throw u.finish(p),p}return u.hasFlowsPending||u.finish(),l}if(!i)return n(r);switch(r.type){case"flow_spawn":return i.incFlowsPending(),n(r);case"flow_resume":case"flow_resume_error":return n(r);case"flow_throw":var c=r.args[0];try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish(c)}case"flow_return":try{return n(r)}finally{i.decFlowsPending(),i.hasFlowsPending||i.finish()}}}}function ge(e,t,r,n){if(n instanceof Date)return{$MST_DATE:n.getTime()};if(It(n))return n;if(nt(n))return we("[MSTNode: "+d(n).name+"]");if("function"==typeof n)return we("[function]");if("object"==typeof n&&!St(n)&&!Ot(n))return we("[object "+(n&&n.constructor&&n.constructor.name||"Complex Object")+"]");try{return JSON.stringify(n),n}catch(i){return we(""+i)}}function me(e,t){return t&&"object"==typeof t&&"$MST_DATE"in t?new Date(t.$MST_DATE):t}function we(e){return{$MST_UNSERIALIZABLE:!0,type:e}}function Pe(e,t){it(e,1),Ut(t,function(e){return"object"==typeof e},"object or array",2),(0,r.runInAction)(function(){jt(t).forEach(function(t){return Oe(e,t)})})}function Oe(e,t){var r=M(e,t.path||"");if(!r)throw mt("Invalid action path: "+(t.path||""));var n=ot(r);if("@APPLY_PATCHES"===t.name)return m.call(null,r,t.args[0]);if("@APPLY_SNAPSHOT"===t.name)return _.call(null,r,t.args[0]);if("function"!=typeof r[t.name])throw mt("Action '"+t.name+"' does not exist in '"+n.path+"'");return r[t.name].apply(r,t.args?t.args.map(function(e){return me(n,e)}):[])}function je(e,t){it(e,1);var r,n=[],i=function(e){(!t||t(e,Re()))&&n.push(e)},o={actions:n,get recording(){return!!r},stop:function(){r&&(r(),r=void 0)},resume:function(){r||(r=_e(e,i))},replay:function(e){Pe(e,n)}};return o.resume(),o}function _e(e,t,r){return void 0===r&&(r=!1),it(e,1),Lt()&&(N(e)||Mt("Warning: Attaching onAction listeners to non root nodes is dangerous: No events will be emitted for actions initiated higher up in the tree."),j(e)||Mt("Warning: Attaching onAction listeners to non protected nodes is dangerous: No events will be emitted for direct modifications without action.")),Ve(e,function(n,i){if("action"===n.type&&n.id===n.rootId){var o=ot(n.context),a={name:n.name,path:st(ot(e),o),args:n.args.map(function(e,t){return ge(o,n.name,t,e)})};if(r){var u=i(n);return t(a),u}return t(a),i(n)}return i(n)})}var Se,Ae=1;function Ie(){return Se}function xe(){return Ae++}function Te(e,t){var r=ot(e.context);"action"===e.type&&r.assertAlive({actionContext:e});var n=r._isRunningAction;r._isRunningAction=!0;var i=Se;Se=e;try{return ke(r,e,t)}finally{Se=i,r._isRunningAction=n}}function Ce(e){if(e)return"action"===e.type?e:e.parentActionEvent}function Ee(e,t,r){var n=function(){var n=xe(),i=Se,o=Ce(i);return Te({type:"action",name:t,id:n,args:Rt(arguments),context:e,tree:C(e),rootId:i?i.rootId:n,parentId:i?i.id:0,allParentIds:i?h(i.allParentIds,[i.id]):[],parentEvent:i,parentActionEvent:o},r)};return n._isMSTAction=!0,n}function Ve(e,t,r){void 0===r&&(r=!0);var n=ot(e);return Lt()&&(n.isProtectionEnabled||Mt("It is recommended to protect the state tree before attaching action middleware, as otherwise it cannot be guaranteed that all changes are passed through middleware. See `protect`")),n.addMiddleWare(t,r)}function Ne(e,t,r){void 0===r&&(r=!0);var n={handler:e,includeHooks:r};return t.$mst_middleware=t.$mst_middleware||[],t.$mst_middleware.push(n),t}var De=function(){function e(e,t){Object.defineProperty(this,"arrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"inArrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:[]}),t.$mst_middleware&&this.middlewares.push(t.$mst_middleware);for(var r=e;r;)r.middlewares&&this.middlewares.push(r.middlewares),r=r.parent}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getNextMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.middlewares[this.arrayIndex];if(e){var t=e[this.inArrayIndex++];return t||(this.arrayIndex++,this.inArrayIndex=0,this.getNextMiddleware())}}}),e}();function ke(e,n,i){var o=new De(e,i);if(o.isEmpty)return(0,r.action)(i).apply(null,n.args);var a=null;return function e(n){var u=o.getNextMiddleware(),l=u&&u.handler;if(!l)return(0,r.action)(i).apply(null,n.args);if(!u.includeHooks&&t[n.name])return e(n);var s=!1;var c=!1;if(l(n,function(t,r){s=!0,a=e(t),r&&(a=r(a))},function(e){c=!0,a=e}),Lt()){if(!s&&!c){var p=ot(n.tree);throw mt("Neither the next() nor the abort() callback within the middleware "+l.name+' for the action: "'+n.name+'" on the node: '+p.type.name+" was invoked.")}if(s&&c)throw p=ot(n.tree),mt("The next() and abort() callback within the middleware "+l.name+' for the action: "'+n.name+'" on the node: '+p.type.name+" were invoked.")}return a}(n)}function Re(){for(var e=Ie();e&&"action"!==e.type;)e=e.parentActionEvent;return e}function ze(e,t,r){for(var n="number"==typeof t?t:t.id,i=r?e:e.parentActionEvent;i;){if(i.id===n)return!0;i=i.parentActionEvent}return!1}function Fe(e,t){return ze(e,t,!1)}function Me(e,t){return ze(e,t,!0)}function He(e){try{return JSON.stringify(e)}catch(t){return"<Unserializable: "+t+">"}}function Le(e){return"function"==typeof e?"<function"+(e.name?" "+e.name:"")+">":nt(e)?"<"+e+">":"`"+He(e)+"`"}function Ue(e){return e.length<280?e:e.substring(0,272)+"......"+e.substring(e.length-8)}function $e(e){var t=e.value,r=e.context[e.context.length-1].type,n=e.context.map(function(e){return e.path}).filter(function(e){return e.length>0}).join("/"),i=n.length>0?'at path "/'+n+'" ':"",o=nt(t)?"value of type "+ot(t).type.name+":":It(t)?"value":"snapshot",a=r&&nt(t)&&r.is(ot(t).snapshot);return""+i+o+" "+Le(t)+" is not assignable "+(r?"to type: `"+r.name+"`":"")+(e.message?" ("+e.message+")":"")+(r?Ur(r)||It(t)?".":", expected an instance of `"+r.name+"` or a snapshot like `"+r.describe()+"` instead."+(a?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function We(e,t,r){return e.concat([{path:t,type:r}])}function Ge(){return yt}function Ye(e,t,r){return[{context:e,value:t,message:r}]}function Je(e){return e.reduce(function(e,t){return e.concat(t)},[])}function Ze(e,t){Ht()&&Be(e,t)}function Be(e,t){var r=e.validate(t,[{path:"",type:e}]);if(r.length>0)throw mt(qe(e,t,r))}function qe(e,t,r){if(0!==r.length)return"Error while converting "+Ue(Le(t))+" to `"+e.name+"`:\n\n "+r.map($e).join("\n ")}var Ke,Qe=0,Xe=function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:Qe++}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:r.observable.map()}),Object.defineProperty(this,"lastCacheModificationPerId",{enumerable:!0,configurable:!0,writable:!0,value:r.observable.map()})}return Object.defineProperty(e.prototype,"updateLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e);this.lastCacheModificationPerId.set(e,void 0===t?1:t+1)}}),Object.defineProperty(e.prototype,"getLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e)||0;return this.cacheId+"-"+t}}),Object.defineProperty(e.prototype,"addNodeToCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(void 0===t&&(t=!0),e.identifierAttribute){var n=e.identifier;this.cache.has(n)||this.cache.set(n,r.observable.array([],gt));var i=this.cache.get(n);if(-1!==i.indexOf(e))throw mt("Already registered");i.push(e),t&&this.updateLastCacheModificationPerId(n)}}}),Object.defineProperty(e.prototype,"mergeCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;(0,r.values)(e.identifierCache.cache).forEach(function(e){return e.forEach(function(e){t.addNodeToCache(e)})})}}),Object.defineProperty(e.prototype,"notifyDied",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.identifierAttribute){var t=e.identifier,r=this.cache.get(t);r&&(r.remove(e),r.length||this.cache.delete(t),this.updateLastCacheModificationPerId(e.identifier))}}}),Object.defineProperty(e.prototype,"splitCache",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this,i=new e,o=t.path;return(0,r.entries)(this.cache).forEach(function(e){for(var t=b(e,2),r=t[0],a=t[1],u=!1,l=a.length-1;l>=0;l--)0===a[l].path.indexOf(o)&&(i.addNodeToCache(a[l],!1),a.splice(l,1),u=!0);u&&n.updateLastCacheModificationPerId(r)}),i}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.cache.get(t);return!!r&&r.some(function(t){return e.isAssignableFrom(t.type)})}}),Object.defineProperty(e.prototype,"resolve",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.cache.get(t);if(!r)return null;var n=r.filter(function(t){return e.isAssignableFrom(t.type)});switch(n.length){case 0:return null;case 1:return n[0];default:throw mt("Cannot resolve a reference to type '"+e.name+"' with id: '"+t+"' unambigously, there are multiple candidates: "+n.map(function(e){return e.path}).join(", "))}}}),e}();function et(e,t,r,n,i){var o=at(i);if(o){if(o.parent)throw mt("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+(t?t.path:"")+"/"+r+"', but it lives already at '"+o.path+"'");return t&&o.setParent(t,r),o}return new ae(e,t,r,n,i)}function tt(e,t,r,n,i){return new te(e,t,r,n,i)}function rt(e){return e instanceof te||e instanceof ae}function nt(e){return!(!e||!e.$treenode)}function it(e,t){Ut(e,nt,"mobx-state-tree node",t)}function ot(e){if(!nt(e))throw mt("Value "+e+" is no MST Node");return e.$treenode}function at(e){return e&&e.$treenode||null}function ut(){return ot(this).snapshot}!function(e){e[e.INITIALIZING=0]="INITIALIZING",e[e.CREATED=1]="CREATED",e[e.FINALIZED=2]="FINALIZED",e[e.DETACHING=3]="DETACHING",e[e.DEAD=4]="DEAD"}(Ke||(Ke={}));var lt=function(e){return".."};function st(e,t){if(e.root!==t.root)throw mt("Cannot calculate relative path: objects '"+e+"' and '"+t+"' are not part of the same object tree");for(var r=or(e.path),n=or(t.path),i=0;i<r.length&&r[i]===n[i];i++);return r.slice(i).map(lt).join("/")+ir(n.slice(i))}function ct(e,t,r){return void 0===r&&(r=!0),pt(e,or(t),r)}function pt(e,t,r){void 0===r&&(r=!0);for(var n=e,i=0;i<t.length;i++){var o=t[i];if(".."===o){if(n=n.parent)continue}else{if("."===o)continue;if(n){if(n instanceof te)try{var a=n.value;nt(a)&&(n=ot(a))}catch(u){if(!r)return;throw u}if(n instanceof ae)if(n.getChildType(o)&&(n=n.getChildNode(o)))continue}}if(r)throw mt("Could not resolve '"+o+"' in path '"+(ir(t.slice(0,i))||"/")+"' while resolving '"+ir(t)+"'");return}return n}function ft(e){if(!e)return yt;var t=Object.keys(e);if(!t.length)return yt;var r=new Array(t.length);return t.forEach(function(t,n){r[n]=e[t]}),r}var bt="See https://github.com/mobxjs/mobx-state-tree/issues/399 for more information. Note that the middleware event types starting with `process` now start with `flow`.";function ht(e){return Ft("process","`process()` has been renamed to `flow()`. "+bt),Jt(e)}var dt=Object.toString(),yt=Object.freeze([]),vt=Object.freeze({}),gt=(0,r._getGlobalState)().useProxies?{deep:!1}:{deep:!1,proxy:!1};function mt(e){return void 0===e&&(e="Illegal state"),new Error("[mobx-state-tree] "+e)}function wt(e){return e}Object.freeze(gt);var Pt=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function Ot(e){return Array.isArray(e)||(0,r.isObservableArray)(e)}function jt(e){return e?Ot(e)?e:[e]:yt}function _t(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];for(var n=0;n<t.length;n++){var i=t[n];for(var o in i)e[o]=i[o]}return e}function St(e){var t;if(null===e||"object"!=typeof e)return!1;var r=Object.getPrototypeOf(e);return null==r||(null===(t=r.constructor)||void 0===t?void 0:t.toString())===dt}function At(e){return!(null===e||"object"!=typeof e||e instanceof Date||e instanceof RegExp)}function It(e,t){return void 0===t&&(t=!0),null==e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||t&&e instanceof Date}function xt(e){return Lt()?It(e)||(0,r.isObservableArray)(e)?e:Object.freeze(e):e}function Tt(e){return Lt()?(xt(e),St(e)&&Object.keys(e).forEach(function(t){It(e[t])||Object.isFrozen(e[t])||Tt(e[t])}),e):e}function Ct(e){return"function"!=typeof e}function Et(e,t,n){(0,r.isObservableObject)(e)?(0,r.defineProperty)(e,t,n):Object.defineProperty(e,t,n)}function Vt(e,t,r){Et(e,t,{enumerable:!1,writable:!1,configurable:!0,value:r})}function Nt(e,t,r){Et(e,t,{enumerable:!1,writable:!0,configurable:!0,value:r})}var Dt=function(){function e(){Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:[]})}return Object.defineProperty(e.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return void 0===t&&(t=!1),t?this.handlers.unshift(e):this.handlers.push(e),function(){r.unregister(e)}}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.handlers.indexOf(e)>=0}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.handlers.indexOf(e);t>=0&&this.handlers.splice(t,1)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.handlers.length=0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.handlers.slice().forEach(function(t){return t.apply(void 0,h(e))})}}),e}(),kt=function(){function e(){Object.defineProperty(this,"eventHandlers",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}return Object.defineProperty(e.prototype,"hasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.eventHandlers&&this.eventHandlers[e];return!!t&&t.hasSubscribers}}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){void 0===r&&(r=!1),this.eventHandlers||(this.eventHandlers={});var n=this.eventHandlers[e];return n||(n=this.eventHandlers[e]=new Dt),n.register(t,r)}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.eventHandlers&&this.eventHandlers[e];return!!r&&r.has(t)}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.eventHandlers&&this.eventHandlers[e];r&&r.unregister(t)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.eventHandlers&&delete this.eventHandlers[e]}}),Object.defineProperty(e.prototype,"clearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.eventHandlers=void 0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=this.eventHandlers&&this.eventHandlers[e];i&&(t=i).emit.apply(t,h(r))}}),e}();function Rt(e){for(var t=new Array(e.length),r=0;r<e.length;r++)t[r]=e[r];return t}function zt(e,t){return 0===e.indexOf(t)}var Ft=function(e,t){Lt()&&(Ft.ids&&!Ft.ids.hasOwnProperty(e)&&Mt("Deprecation warning: "+t),Ft.ids&&(Ft.ids[e]=!0))};function Mt(e){console.warn(new Error("[mobx-state-tree] "+e))}function Ht(){return Lt()||void 0!==e&&e.env&&!1}function Lt(){return!1}function Ut(e,t,r,n){if(Lt()&&!t(e))throw mt("expected "+r+" as argument "+jt(n).join(" or ")+", got "+e+" instead")}function $t(e,t){Ut(e,function(e){return"function"==typeof e},"function",t)}function Wt(e,t,r,n){Ut(e,function(e){return"number"==typeof e},"number",t),void 0!==r&&Ut(e,function(e){return e>=r},"number greater than "+r,t),void 0!==n&&Ut(e,function(e){return e<=n},"number lesser than "+n,t)}function Gt(e,t,r){void 0===r&&(r=!0),Ut(e,function(e){return"string"==typeof e},"string",t),r||Ut(e,function(e){return""!==e},"not empty string",t)}function Yt(e){"function"==typeof queueMicrotask?queueMicrotask(e):"function"==typeof setImmediate?setImmediate(e):setTimeout(e,1)}function Jt(e){return Kt(e.name,e)}function Zt(e){return e}function Bt(e){return function(){var t,r=[];for(t=0;t<arguments.length;t++)r[t]=arguments[t];return p(this,function(t){switch(t.label){case 0:return[4,e.apply(void 0,h(r))];case 1:return[2,t.sent()]}})}}function qt(e){return p(this,function(t){switch(t.label){case 0:return[4,e];case 1:return[2,t.sent()]}})}function Kt(e,t){var r=function(){var n=xe(),i=Ie();if(!i)throw mt("a mst flow must always have a parent context");var o=Ce(i);if(!o)throw mt("a mst flow must always have a parent action context");var a={name:e,id:n,tree:i.tree,context:i.context,parentId:i.id,allParentIds:h(i.allParentIds,[i.id]),rootId:i.rootId,parentEvent:i,parentActionEvent:o},u=arguments;function l(e,t,n){e.$mst_middleware=r.$mst_middleware,Te(s(s({},a),{type:t,args:[n]}),e)}return new Promise(function(e,n){var i,o=function(){i=t.apply(null,arguments),c(void 0)};function c(e){var t;try{l(function(e){t=i.next(e)},"flow_resume",e)}catch(r){return void Yt(function(){l(function(e){n(r)},"flow_throw",r)})}f(t)}function p(e){var t;try{l(function(e){t=i.throw(e)},"flow_resume_error",e)}catch(r){return void Yt(function(){l(function(e){n(r)},"flow_throw",r)})}f(t)}function f(t){if(!t.done){if(!t.value||"function"!=typeof t.value.then)throw mt("Only promises can be yielded to `async`, got: "+t);return t.value.then(c,p)}Yt(function(){l(function(t){e(t)},"flow_return",t.value)})}o.$mst_middleware=r.$mst_middleware,Te(s(s({},a),{type:"flow_spawn",args:Rt(u)}),o)})};return r}function Qt(e){if(!("oldValue"in e))throw mt("Patches without `oldValue` field cannot be inversed");return[Xt(e),er(e)]}function Xt(e){switch(e.op){case"add":return{op:"add",path:e.path,value:e.value};case"remove":return{op:"remove",path:e.path};case"replace":return{op:"replace",path:e.path,value:e.value}}}function er(e){switch(e.op){case"add":return{op:"remove",path:e.path};case"remove":return{op:"add",path:e.path,value:e.oldValue};case"replace":return{op:"replace",path:e.path,value:e.oldValue}}}function tr(e){return"number"==typeof e}function rr(e){return!0===tr(e)?""+e:-1===e.indexOf("/")&&-1===e.indexOf("~")?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function nr(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function ir(e){if(0===e.length)return"";var t=function(e){return e.map(rr).join("/")};return"."===e[0]||".."===e[0]?t(e):"/"+t(e)}function or(e){var t=e.split("/").map(nr);if(!(""===e||"."===e||".."===e||zt(e,"/")||zt(e,"./")||zt(e,"../")))throw mt("a json path must be either rooted, empty or relative, but got '"+e+"'");return""===t[0]&&t.shift(),t}Ft.ids={};var ar=Symbol("$preProcessorFailed"),ur=function(e){function t(t,r,n){var i=e.call(this,n||t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_processors",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return l(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|ne.SnapshotProcessor},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"snapshotProcessor("+this._subtype.describe()+")"}}),Object.defineProperty(t.prototype,"preProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._processors.preProcessor?this._processors.preProcessor.call(null,e):e}}),Object.defineProperty(t.prototype,"preProcessSnapshotSafe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){try{return this.preProcessSnapshot(e)}catch(t){return ar}}}),Object.defineProperty(t.prototype,"postProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._processors.postProcessor?this._processors.postProcessor.call(null,e):e}}),Object.defineProperty(t.prototype,"_fixNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;lr(e.type,this,"create");var r=e.getSnapshot;e.getSnapshot=function(){return t.postProcessSnapshot(r.call(e))},e.getReconciliationType=function(){return t}}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=nt(n)?n:this.preProcessSnapshot(n),o=this._subtype.instantiate(e,t,r,i);return this._fixNode(o),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this._subtype.reconcile(e,nt(t)?t:this.preProcessSnapshot(t),r,n);return i!==e&&this._fixNode(i),i}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=!0);var r=this._subtype.getSnapshot(e);return t?this.postProcessSnapshot(r):r}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.preProcessSnapshotSafe(e);return r===ar?Ye(t,e,"Failed to preprocess value"):this._subtype.validate(r,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),Object.defineProperty(t.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=fe(e)?this._subtype:nt(e)?S(e,!1):this.preProcessSnapshotSafe(e);return t!==ar&&0===this._subtype.validate(t,[{path:"",type:this._subtype}]).length}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!(this._subtype instanceof ce))return!1;var r=this.preProcessSnapshot(t);return this._subtype.isMatchingSnapshotId(e,r)}}),t}(se);function lr(e,t){for(var r,n,i=[],o=2;o<arguments.length;o++)i[o-2]=arguments[o];try{for(var a=f(i),u=a.next();!u.done;u=a.next()){var l=u.value;e[l]=t[l].bind(t)}}catch(s){r={error:s}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}}function sr(e,t,r){if(be(e,1),Lt()){if(t.postProcessor&&"function"!=typeof t.postProcessor)throw fail("postSnapshotProcessor must be a function");if(t.preProcessor&&"function"!=typeof t.preProcessor)throw fail("preSnapshotProcessor must be a function")}return new ur(e,t,r)}var cr,pr="Map.put can only be used to store complex values that have an identifier type attribute";function fr(e,t){var r,n,i=e.getSubTypes();if(i===ue)return!1;if(i){var o=jt(i);try{for(var a=f(o),u=a.next();!u.done;u=a.next()){if(!fr(u.value,t))return!1}}catch(l){r={error:l}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}}return e instanceof xr&&t.push(e),!0}!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.YES=1]="YES",e[e.NO=2]="NO"}(cr||(cr={}));var br=function(e){function t(t){return e.call(this,t,r.observable.ref.enhancer)||this}return l(t,e),Object.defineProperty(t.prototype,"get",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.get.call(this,""+t)}}),Object.defineProperty(t.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.has.call(this,""+t)}}),Object.defineProperty(t.prototype,"delete",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.delete.call(this,""+t)}}),Object.defineProperty(t.prototype,"set",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return e.prototype.set.call(this,""+t,r)}}),Object.defineProperty(t.prototype,"put",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!e)throw mt("Map.put cannot be used to set empty values");if(nt(e)){var t=ot(e);if(Lt()&&!t.identifierAttribute)throw mt(pr);if(null===t.identifier)throw mt(pr);return this.set(t.identifier,e),e}if(At(e)){var r=ot(this),n=r.type;if(n.identifierMode!==cr.YES)throw mt(pr);var i=e[n.mapIdentifierAttribute];if(!Vn(i)){var o=this.put(n.getChildType().create(e,r.environment));return this.put(S(o))}var a=En(i);return this.set(a,e),this.get(a)}throw mt("Map.put can only be used to store complex values")}}),t}(r.ObservableMap),hr=function(e){function t(t,r,n){void 0===n&&(n=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"identifierMode",{enumerable:!0,configurable:!0,writable:!0,value:cr.UNKNOWN}),Object.defineProperty(i,"mapIdentifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Map}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i._determineIdentifierMode(),i.hookInitializers=n,i}return l(t,e),Object.defineProperty(t.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new t(this.name,this._subType,r)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._determineIdentifierMode(),et(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"_determineIdentifierMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.identifierMode===cr.UNKNOWN){var e=[];if(fr(this._subType,e)){var t=e.reduce(function(e,t){if(!t.identifierAttribute)return e;if(e&&e!==t.identifierAttribute)throw mt("The objects in a map should all have the same identifier attribute, expected '"+e+"', but child of type '"+t.name+"' declared attribute '"+t.identifierAttribute+"' as identifier");return t.identifierAttribute},void 0);t?(this.identifierMode=cr.YES,this.mapIdentifierAttribute=t):this.identifierMode=cr.NO}}}}),Object.defineProperty(t.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t={});var r=e.type._subType,n={};return Object.keys(t).forEach(function(i){n[i]=r.instantiate(e,i,void 0,t[i])}),n}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new br(e)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){(0,r._interceptReads)(t,e.unbox),e.type.hookInitializers.forEach(function(e){var r=e(t);Object.keys(r).forEach(function(e){var n=r[e],i=Ee(t,e,n);(Lt()?Nt:Vt)(t,e,i)})}),(0,r.intercept)(t,this.willChange),(0,r.observe)(t,this.didChange)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"Map<string, "+this._subType.describe()+">"}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return(0,r.values)(e.storedValue)}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.storedValue.get(""+t);if(!r)throw mt("Not a child "+t);return r}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=ot(e.object),r=e.name;t.assertWritable({subpath:r});var n=t.type,i=n._subType;switch(e.type){case"update":var o=e.newValue;if(o===e.object.get(r))return null;Ze(i,o),e.newValue=i.reconcile(t.getChildNode(r),e.newValue,t,r),n.processIdentifier(r,e.newValue);break;case"add":Ze(i,e.newValue),e.newValue=i.instantiate(t,r,void 0,e.newValue),n.processIdentifier(r,e.newValue)}return e}}),Object.defineProperty(t.prototype,"processIdentifier",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.identifierMode===cr.YES&&t instanceof ae){var r=t.identifier;if(r!==e)throw mt("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+r+"', but expected: '"+e+"'")}}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return e.getChildren().forEach(function(e){t[e.subpath]=e.snapshot}),t}}),Object.defineProperty(t.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach(function(r){t[r]=e[r].getSnapshot()}),t}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=ot(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:rr(e.name),value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);case"add":return void t.emitPatch({op:"add",path:rr(e.name),value:e.newValue.snapshot,oldValue:void 0},t);case"delete":var r=e.oldValue.snapshot;return e.oldValue.die(),void t.emitPatch({op:"remove",path:rr(e.name),oldValue:r},t)}}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=e.storedValue;switch(r.op){case"add":case"replace":n.set(t,r.value);break;case"remove":n.delete(t)}}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){Ze(this,t);var r=e.storedValue,n={};if(Array.from(r.keys()).forEach(function(e){n[e]=!1}),t)for(var i in t)r.set(i,t[i]),n[""+i]=!0;Object.keys(n).forEach(function(e){!1===n[e]&&r.delete(e)})}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return St(e)?Je(Object.keys(e).map(function(n){return r._subType.validate(e[n],We(t,n,r._subType))})):Ye(t,e,"Value is not a plain object")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return vt}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.delete(t)}}),t}(ce);function dr(e){return new hr("map<string, "+e.name+">",e)}function yr(e){return fe(e)&&(e.flags&ne.Map)>0}hr.prototype.applySnapshot=(0,r.action)(hr.prototype.applySnapshot);var vr=function(e){function t(t,r,n){void 0===n&&(n=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Array}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i.hookInitializers=n,i}return l(t,e),Object.defineProperty(t.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new t(this.name,this._subType,r)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return et(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t=[]);var r=e.type._subType,n={};return t.forEach(function(t,i){var o=""+i;n[o]=r.instantiate(e,o,void 0,t)}),n}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return r.observable.array(ft(e),gt)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){(0,r._getAdministration)(t).dehancer=e.unbox,e.type.hookInitializers.forEach(function(e){var r=e(t);Object.keys(r).forEach(function(e){var n=r[e],i=Ee(t,e,n);(Lt()?Nt:Vt)(t,e,i)})}),(0,r.intercept)(t,this.willChange),(0,r.observe)(t,this.didChange)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType.describe()+"[]"}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.slice()}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=Number(t);if(r<e.storedValue.length)return e.storedValue[r];throw mt("Not a child: "+t)}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=ot(e.object);t.assertWritable({subpath:""+e.index});var r=t.type._subType,n=t.getChildren();switch(e.type){case"update":if(e.newValue===e.object[e.index])return null;var i=mr(t,r,[n[e.index]],[e.newValue],[e.index]);if(!i)return null;e.newValue=i[0];break;case"splice":var o=e.index,a=e.removedCount,u=e.added,l=mr(t,r,n.slice(o,o+a),u,u.map(function(e,t){return o+t}));if(!l)return null;e.added=l;for(var s=o+a;s<n.length;s++)n[s].setParent(t,""+(s+u.length-a))}return e}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.getChildren().map(function(e){return e.snapshot})}}),Object.defineProperty(t.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=[];return Object.keys(e).forEach(function(r){t.push(e[r].getSnapshot())}),t}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=ot(e.object);switch(e.type){case"update":return void t.emitPatch({op:"replace",path:""+e.index,value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);case"splice":for(var r=e.removedCount-1;r>=0;r--)t.emitPatch({op:"remove",path:""+(e.index+r),oldValue:e.removed[r].snapshot},t);for(r=0;r<e.addedCount;r++)t.emitPatch({op:"add",path:""+(e.index+r),value:t.getChildNode(""+(e.index+r)).snapshot,oldValue:void 0},t);return}}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=e.storedValue,i="-"===t?n.length:Number(t);switch(r.op){case"replace":n[i]=r.value;break;case"add":n.splice(i,0,r.value);break;case"remove":n.splice(i,1)}}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){Ze(this,t),e.storedValue.replace(t)}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return Ot(e)?Je(e.map(function(e,n){return r._subType.validate(e,We(t,""+n,r._subType))})):Ye(t,e,"Value is not an array")}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return yt}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.splice(Number(t),1)}}),t}(ce);function gr(e){return be(e,1),new vr(e.name+"[]",e)}function mr(e,t,r,n,i){for(var o=!0,a=0;;a++){var u=a<=n.length-1,l=r[a],s=u?n[a]:void 0,c=""+i[a];if(rt(s)&&(s=s.storedValue),!l&&!u)break;if(u)if(l)if(Pr(l,s))r[a]=wr(t,e,c,s,l);else{for(var p=void 0,f=a;f<r.length;f++)if(Pr(r[f],s)){p=r.splice(f,1)[0];break}o=!1;b=wr(t,e,c,s,p);r.splice(a,0,b)}else{if(nt(s)&&ot(s).parent===e)throw mt("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+e.path+"/"+c+"', but it lives already at '"+ot(s).path+"'");o=!1;var b=wr(t,e,c,s);r.splice(a,0,b)}else o=!1,r.splice(a,1),l instanceof ae&&l.createObservableInstanceIfNeeded(),l.die(),a--}return o?null:r}function wr(e,t,r,n,i){Ze(e,n);var o=function(){if(nt(n)){var o=ot(n);if(o.assertAlive(vt),null!==o.parent&&o.parent===t)return o.setParent(t,r),o}return i?e.reconcile(i,n,t,r):e.instantiate(t,r,void 0,n)}();return i&&i!==o&&(i instanceof ae&&i.createObservableInstanceIfNeeded(),i.die()),o}function Pr(e,t){if(!e.isAlive)return!1;if(nt(t)){var r=ot(t);return r.isAlive&&r===e}if(e.snapshot===t)return!0;if(!(e instanceof ae))return!1;var n=e.getReconciliationType();return null!==e.identifier&&e.identifierAttribute&&St(t)&&n.is(t)&&n.isMatchingSnapshotId(e,t)}function Or(e){return fe(e)&&(e.flags&ne.Array)>0}vr.prototype.applySnapshot=(0,r.action)(vr.prototype.applySnapshot);var jr="preProcessSnapshot",_r="postProcessSnapshot";function Sr(){return ot(this).toString()}var Ar={name:"AnonymousModel",properties:{},initializers:yt};function Ir(e){return Object.keys(e).reduce(function(e,r){var n,i,o;if(r in t)throw mt("Hook '"+r+"' was defined as property. Hooks should be defined as part of the actions");var a=Object.getOwnPropertyDescriptor(e,r);if("get"in a)throw mt("Getters are not supported as properties. Please use views instead");var u=a.value;if(null==u)throw mt("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(It(u))return Object.assign({},e,((n={})[r]=tn(Lr(u),u),n));if(u instanceof hr)return Object.assign({},e,((i={})[r]=tn(u,{}),i));if(u instanceof vr)return Object.assign({},e,((o={})[r]=tn(u,[]),o));if(fe(u))return e;throw Lt()&&"function"==typeof u?mt("Invalid type definition for property '"+r+"', it looks like you passed a function. Did you forget to invoke it, or did you intend to declare a view / action?"):Lt()&&"object"==typeof u?mt("Invalid type definition for property '"+r+"', it looks like you passed an object. Try passing another model type or a types.frozen."):mt("Invalid type definition for property '"+r+"', cannot infer a type from a value like '"+u+"' ("+typeof u+")")},e)}var xr=function(e){function n(t){var r=e.call(this,t.name||Ar.name)||this;return Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Object}),Object.defineProperty(r,"initializers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"preProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"postProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"propertyNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"named",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return r.cloneAndEnhance({name:e})}}),Object.defineProperty(r,"props",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return r.cloneAndEnhance({properties:e})}}),Object.defineProperty(r,"preProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=r.preProcessor;return t?r.cloneAndEnhance({preProcessor:function(r){return t(e(r))}}):r.cloneAndEnhance({preProcessor:e})}}),Object.defineProperty(r,"postProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=r.postProcessor;return t?r.cloneAndEnhance({postProcessor:function(r){return e(t(r))}}):r.cloneAndEnhance({postProcessor:e})}}),Object.assign(r,Ar,t),r.properties=Ir(r.properties),xt(r.properties),r.propertyNames=Object.keys(r.properties),r.identifierAttribute=r._getIdentifierAttribute(),r}return l(n,e),Object.defineProperty(n.prototype,"_getIdentifierAttribute",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=void 0;return this.forAllProps(function(t,r){if(r.flags&ne.Identifier){if(e)throw mt("Cannot define property '"+t+"' as object identifier, property '"+e+"' is already defined as identifier property");e=t}}),e}}),Object.defineProperty(n.prototype,"cloneAndEnhance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new n({name:e.name||this.name,properties:Object.assign({},this.properties,e.properties),initializers:this.initializers.concat(e.initializers||[]),preProcessor:e.preProcessor||this.preProcessor,postProcessor:e.postProcessor||this.postProcessor})}}),Object.defineProperty(n.prototype,"actions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){return t.instantiateActions(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateActions",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){if(!St(r))throw mt("actions initializer should return a plain object containing actions");Object.keys(r).forEach(function(n){if(n===jr)throw mt("Cannot define action '"+jr+"', it should be defined using 'type.preProcessSnapshot(fn)' instead");if(n===_r)throw mt("Cannot define action '"+_r+"', it should be defined using 'type.postProcessSnapshot(fn)' instead");var i=r[n],o=e[n];if(n in t&&o){var a=i;i=function(){o.apply(null,arguments),a.apply(null,arguments)}}var u=i.$mst_middleware,l=i.bind(r);l.$mst_middleware=u;var s=Ee(e,n,l);r[n]=s,(Lt()?Nt:Vt)(e,n,s)})}}),Object.defineProperty(n.prototype,"volatile",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;if("function"!=typeof e)throw mt("You passed an "+typeof e+" to volatile state as an argument, when function is expected");return this.cloneAndEnhance({initializers:[function(r){return t.instantiateVolatileState(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateVolatileState",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!St(t))throw mt("volatile state initializer should return a plain object containing state");(0,r.set)(e,t)}}),Object.defineProperty(n.prototype,"extend",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){var n=e(r),i=n.actions,o=n.views,a=n.state,u=c(n,["actions","views","state"]);for(var l in u)throw mt("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '"+l+"'");return a&&t.instantiateVolatileState(r,a),o&&t.instantiateViews(r,o),i&&t.instantiateActions(r,i),r}]})}}),Object.defineProperty(n.prototype,"views",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(r){return t.instantiateViews(r,e(r)),r}]})}}),Object.defineProperty(n.prototype,"instantiateViews",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!St(t))throw mt("views initializer should return a plain object containing views");Object.keys(t).forEach(function(n){var i,o=Object.getOwnPropertyDescriptor(t,n);if("get"in o)(0,r.defineProperty)(e,n,o),(0,r.makeObservable)(e,((i={})[n]=r.computed,i));else{if("function"!=typeof o.value)throw mt("A view member should either be a function or getter based property");(Lt()?Nt:Vt)(e,n,o.value)}})}}),Object.defineProperty(n.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return et(this,e,t,r,nt(n)?n:this.applySnapshotPreProcessor(n))}}),Object.defineProperty(n.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===t&&(t={});var r=e.type,n={};return r.forAllProps(function(r,i){n[r]=i.instantiate(e,r,void 0,t[r])}),n}}),Object.defineProperty(n.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return r.observable.object(e,vt,gt)}}),Object.defineProperty(n.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){Vt(t,"toString",Sr),this.forAllProps(function(n){(0,r._interceptReads)(t,n,e.unbox)}),this.initializers.reduce(function(e,t){return t(e)},t),(0,r.intercept)(t,this.willChange),(0,r.observe)(t,this.didChange)}}),Object.defineProperty(n.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,r=ot(t.object),n=t.name;r.assertWritable({subpath:n});var i=r.type.properties[n];return i&&(Ze(i,t.newValue),t.newValue=i.reconcile(r.getChildNode(n),t.newValue,r,n)),t}}),Object.defineProperty(n.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,r=ot(t.object);if(r.type.properties[t.name]){var n=t.oldValue?t.oldValue.snapshot:void 0;r.emitPatch({op:"replace",path:rr(t.name),value:t.newValue.snapshot,oldValue:n},r)}}}),Object.defineProperty(n.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=[];return this.forAllProps(function(n){r.push(t.getChildNode(e,n))}),r}}),Object.defineProperty(n.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!(t in this.properties))throw mt("Not a value property: "+t);var n=(0,r._getAdministration)(e.storedValue,t).raw();if(!n)throw mt("Node not available for property "+t);return n}}),Object.defineProperty(n.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this;void 0===t&&(t=!0);var i={};return this.forAllProps(function(t,o){(0,r.getAtom)(e.storedValue,t).reportObserved(),i[t]=n.getChildNode(e,t).snapshot}),t?this.applySnapshotPostProcessor(i):i}}),Object.defineProperty(n.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach(function(r){t[r]=e[r].getSnapshot()}),this.applySnapshotPostProcessor(t)}}),Object.defineProperty(n.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){if("replace"!==r.op&&"add"!==r.op)throw mt("object does not support operation "+r.op);e.storedValue[t]=r.value}}),Object.defineProperty(n.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.applySnapshotPreProcessor(t);Ze(this,r),this.forAllProps(function(t){e.storedValue[t]=r[t]})}}),Object.defineProperty(n.prototype,"applySnapshotPreProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.preProcessor;return t?t.call(null,e):e}}),Object.defineProperty(n.prototype,"applySnapshotPostProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.postProcessor;return t?t.call(null,e):e}}),Object.defineProperty(n.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return Gt(e,1),this.properties[e]}}),Object.defineProperty(n.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,n=this.applySnapshotPreProcessor(e);return St(n)?Je(this.propertyNames.map(function(e){return r.properties[e].validate(n[e],We(t,e,r.properties[e]))})):Ye(t,n,"Value is not a plain object")}}),Object.defineProperty(n.prototype,"forAllProps",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this.propertyNames.forEach(function(r){return e(r,t.properties[r])})}}),Object.defineProperty(n.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;return"{ "+this.propertyNames.map(function(t){return t+": "+e.properties[t].describe()}).join("; ")+" }"}}),Object.defineProperty(n.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return vt}}),Object.defineProperty(n.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue[t]=void 0}}),n}(ce);function Tr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0]?e.shift():"AnonymousModel",n=e.shift()||{};return new xr({name:r,properties:n})}function Cr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0],n=r?e[0]:"AnonymousModel";return r&&e.shift(),Lt()&&e.forEach(function(e,t){Ut(e,Er,"mobx-state-tree model type",r?t+2:t+1)}),e.reduce(function(e,t){return e.cloneAndEnhance({name:e.name+"_"+t.name,properties:t.properties,initializers:t.initializers,preProcessor:function(r){return t.applySnapshotPreProcessor(e.applySnapshotPreProcessor(r))},postProcessor:function(r){return t.applySnapshotPostProcessor(e.applySnapshotPostProcessor(r))}})}).named(n)}function Er(e){return fe(e)&&(e.flags&ne.Object)>0}xr.prototype.applySnapshot=(0,r.action)(xr.prototype.applySnapshot);var Vr=function(e){function t(t,r,n,i){void 0===i&&(i=wt);var o=e.call(this,t)||this;return Object.defineProperty(o,"flags",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(o,"checker",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(o,"initializer",{enumerable:!0,configurable:!0,writable:!0,value:i}),o.flags=r,o}return l(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return tt(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.initializer(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return It(e)&&this.checker(e)?Ge():Ye(t,e,"Value is not a "+("Date"===this.name?"Date or a unix milliseconds timestamp":this.name))}}),t}(pe),Nr=new Vr("string",ne.String,function(e){return"string"==typeof e}),Dr=new Vr("number",ne.Number,function(e){return"number"==typeof e}),kr=new Vr("integer",ne.Integer,function(e){return Pt(e)}),Rr=new Vr("boolean",ne.Boolean,function(e){return"boolean"==typeof e}),zr=new Vr("null",ne.Null,function(e){return null===e}),Fr=new Vr("undefined",ne.Undefined,function(e){return void 0===e}),Mr=new Vr("Date",ne.Date,function(e){return"number"==typeof e||e instanceof Date},function(e){return e instanceof Date?e:new Date(e)});Mr.getSnapshot=function(e){return e.storedValue.getTime()};var Hr=Mr;function Lr(e){switch(typeof e){case"string":return Nr;case"number":return Dr;case"boolean":return Rr;case"object":if(e instanceof Date)return Hr}throw mt("Cannot determine primitive type from value "+e)}function Ur(e){return fe(e)&&(e.flags&(ne.String|ne.Number|ne.Integer|ne.Boolean|ne.Date))>0}var $r=function(e){function t(t){var r=e.call(this,JSON.stringify(t))||this;return Object.defineProperty(r,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Literal}),r.value=t,r}return l(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return tt(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return JSON.stringify(this.value)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return It(e)&&e===this.value?Ge():Ye(t,e,"Value is not a literal "+JSON.stringify(this.value))}}),t}(pe);function Wr(e){return Ut(e,It,"primitive",1),new $r(e)}function Gr(e){return fe(e)&&(e.flags&ne.Literal)>0}var Yr=function(e){function t(t,r,n,i){var o=e.call(this,t)||this;return Object.defineProperty(o,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(o,"_predicate",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(o,"_message",{enumerable:!0,configurable:!0,writable:!0,value:i}),o}return l(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|ne.Refinement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this._subtype.validate(e,t);if(r.length>0)return r;var n=nt(e)?ot(e).snapshot:e;return this._predicate(n)?Ge():Ye(t,e,this._message(e))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(se);function Jr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r="string"==typeof e[0]?e.shift():fe(e[0])?e[0].name:null,n=e[0],i=e[1],o=e[2]?e[2]:function(e){return"Value does not respect the refinement predicate"};return be(n,[1,2]),Gt(r,1),$t(i,[2,3]),$t(o,[3,4]),new Yr(r,n,i,o)}function Zr(e){return(e.flags&ne.Refinement)>0}function Br(e,t){var r="string"==typeof e?t:e;Lt()&&r.forEach(function(e,t){Gt(e,t+1)});var n=Kr.apply(void 0,h(r.map(function(e){return Wr(""+e)})));return"string"==typeof e&&(n.name=e),n}var qr=function(e){function t(t,r,n){var i=e.call(this,t)||this;return Object.defineProperty(i,"_types",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"_dispatcher",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"_eager",{enumerable:!0,configurable:!0,writable:!0,value:!0}),n=s({eager:!0,dispatcher:void 0},n),i._dispatcher=n.dispatcher,n.eager||(i._eager=!1),i}return l(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){var e=ne.Union;return this._types.forEach(function(t){e|=t.flags}),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._types.some(function(t){return t.isAssignableFrom(e)})}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"("+this._types.map(function(e){return e.describe()}).join(" | ")+")"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this.determineType(n,void 0);if(!i)throw mt("No matching type for union "+this.describe());return i.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this.determineType(t,e.getReconciliationType());if(!i)throw mt("No matching type for union "+this.describe());return i.reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"determineType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._dispatcher?this._dispatcher(e):t?t.is(e)?t:this._types.filter(function(e){return e!==t}).find(function(t){return t.is(e)}):this._types.find(function(t){return t.is(e)})}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._dispatcher)return this._dispatcher(e).validate(e,t);for(var r=[],n=0,i=0;i<this._types.length;i++){var o=this._types[i].validate(e,t);if(0===o.length){if(this._eager)return Ge();n++}else r.push(o)}return 1===n?Ge():Ye(t,e,"No type is applicable for the union").concat(Je(r))}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),t}(se);function Kr(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=fe(e)?void 0:e,i=fe(e)?h([e],t):t,o="("+i.map(function(e){return e.name}).join(" | ")+")";return Lt()&&(n&&Ut(n,function(e){return St(e)},"object { eager?: boolean, dispatcher?: Function }",1),i.forEach(function(e,t){be(e,n?t+2:t+1)})),new qr(o,i,n)}function Qr(e){return(e.flags&ne.Union)>0}var Xr=function(e){function t(t,r,n){var i=e.call(this,t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"optionalValues",{enumerable:!0,configurable:!0,writable:!0,value:n}),i}return l(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|ne.Optional},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype.describe()+"?"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(this.optionalValues.indexOf(n)>=0){var i=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(e,t,r,i)}return this._subtype.instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this._subtype.reconcile(e,this.optionalValues.indexOf(t)<0&&this._subtype.is(t)?t:this.getDefaultInstanceOrSnapshot(),r,n)}}),Object.defineProperty(t.prototype,"getDefaultInstanceOrSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e="function"==typeof this._defaultValue?this._defaultValue():this._defaultValue;return"function"==typeof this._defaultValue&&Ze(this,e),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.optionalValues.indexOf(e)>=0?Ge():this._subtype.validate(e,t)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(se);function en(e,t){if("function"!=typeof t&&nt(t))throw mt("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead");be(e,1),Lt()&&"function"!=typeof t&&Ze(e,t)}function tn(e,t,r){return en(e,t),new Xr(e,t,r||rn)}var rn=[void 0];function nn(e){return fe(e)&&(e.flags&ne.Optional)>0}var on=tn(Fr,void 0),an=tn(zr,null);function un(e){return be(e,1),Kr(e,on)}function ln(e){return be(e,1),Kr(e,an)}var sn=function(e){function t(t,r){var n=e.call(this,t)||this;return Object.defineProperty(n,"_definition",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n}return l(t,e),Object.defineProperty(t.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|ne.Late},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSubType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._subType){var t=void 0;try{t=this._definition()}catch(r){if(!(r instanceof ReferenceError))throw r;t=void 0}if(e&&void 0===t)throw mt("Late type seems to be used too early, the definition (still) returns undefined");if(t){if(Lt()&&!fe(t))throw mt("Failed to determine subtype, make sure types.late returns a type definition.");this._subType=t}}return this._subType}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this.getSubType(!0).instantiate(e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return this.getSubType(!0).reconcile(e,t,r,n)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getSubType(!1);return e?e.name:"<uknown late type>"}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.getSubType(!1);return r?r.validate(e,t):Ge()}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getSubType(!1);return!!t&&t.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getSubType(!1);return e||ue}}),t}(se);function cn(e,t){var r="string"==typeof e?e:"late("+e.toString()+")",n="string"==typeof e?t:e;if(Lt()&&("function"!=typeof n||0!==n.length))throw mt("Invalid late type, expected a function with zero arguments that returns a type, got: "+n);return new sn(r,n)}function pn(e){return fe(e)&&(e.flags&ne.Late)>0}var fn=function(e){function t(t){var r=e.call(this,t?"frozen("+t.name+")":"frozen")||this;return Object.defineProperty(r,"subType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Frozen}),r}return l(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<any immutable value>"}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return tt(this,e,t,r,Tt(n))}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Ct(e)?this.subType?this.subType.validate(e,t):Ge():Ye(t,e,"Value is not serializable and cannot be frozen")}}),t}(pe),bn=new fn;function hn(e){return 0===arguments.length?bn:fe(e)?new fn(e):tn(bn,e)}function dn(e){return fe(e)&&(e.flags&ne.Frozen)>0}function yn(e){switch(e){case t.beforeDestroy:return"destroy";case t.beforeDetach:return"detach";default:return}}var vn=function(){function e(e,t){if(Object.defineProperty(this,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"node",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"resolvedReference",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Vn(e))this.identifier=e;else{if(!nt(e))throw mt("Can only store references to tree nodes or identifiers, got: '"+e+"'");var r=ot(e);if(!r.identifierAttribute)throw mt("Can only store references with a defined identifier attribute.");var n=r.unnormalizedIdentifier;if(null==n)throw mt("Can only store references to tree nodes with a defined identifier.");this.identifier=n}}return Object.defineProperty(e.prototype,"updateResolvedReference",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=En(this.identifier),r=e.root,n=r.identifierCache.getLastCacheModificationPerId(t);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==n){var i=this.targetType,o=r.identifierCache.resolve(i,t);if(!o)throw new gn("[mobx-state-tree] Failed to resolve reference '"+this.identifier+"' to type '"+this.targetType.name+"' (from node: "+e.path+")");this.resolvedReference={node:o,lastCacheModification:n}}}}),Object.defineProperty(e.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),e}(),gn=function(e){function t(r){var n=e.call(this,r)||this;return Object.setPrototypeOf(n,t.prototype),n}return l(t,e),t}(Error),mn=function(e){function r(t,r){var n=e.call(this,"reference("+t.name+")")||this;return Object.defineProperty(n,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"onInvalidated",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Reference}),n}return l(r,e),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.targetType.isAssignableFrom(e)}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Vn(e)?Ge():Ye(t,e,"Value is not a valid identifier, which is a string or a number")}}),Object.defineProperty(r.prototype,"fireInvalidated",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=t.parent;if(i&&i.isAlive){var o=i.storedValue;o&&this.onInvalidated({cause:e,parent:o,invalidTarget:n?n.storedValue:void 0,invalidId:r,replaceRef:function(e){m(t.root.storedValue,{op:"replace",value:e,path:t.path})},removeRef:function(){Er(i.type)?this.replaceRef(void 0):m(t.root.storedValue,{op:"remove",path:t.path})}})}}}),Object.defineProperty(r.prototype,"addTargetNodeWatcher",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=this,i=this.getValue(e);if(i){var o=ot(i),a=function(t,i){var a=yn(i);a&&n.fireInvalidated(a,e,r,o)},u=o.registerHook(t.beforeDetach,a),l=o.registerHook(t.beforeDestroy,a);return function(){u(),l()}}}}),Object.defineProperty(r.prototype,"watchTargetNodeForInvalidations",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,n){var i=this;if(this.onInvalidated){var o;e.registerHook(t.beforeDestroy,function(){o&&o()});var a=function(t){o&&o();var a=e.parent,u=a&&a.storedValue;if(a&&a.isAlive&&u){(n?!!n.get(r,u):e.root.identifierCache.has(i.targetType,En(r)))?o=i.addTargetNodeWatcher(e,r):t||i.fireInvalidated("invalidSnapshotReference",e,r,null)}};e.state===Ke.FINALIZED?a(!0):(e.isRoot||e.root.registerHook(t.afterCreationFinalization,function(){e.parent&&e.parent.createObservableInstanceIfNeeded()}),e.registerHook(t.afterAttach,function(){a(!1)}))}}}),r}(pe),wn=function(e){function t(t,r){return e.call(this,t,r)||this}return l(t,e),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return e.storedValue.resolvedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.identifier}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=nt(n)?R(n):n,o=new vn(n,this.targetType),a=tt(this,e,t,r,o);return o.node=a,this.watchTargetNodeForInvalidations(a,i,void 0),a}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!e.isDetaching&&e.type===this){var i=nt(t),o=e.storedValue;if(!i&&o.identifier===t||i&&o.resolvedValue===t)return e.setParent(r,n),e}var a=this.instantiate(r,n,void 0,t);return e.die(),a}}),t}(mn),Pn=function(e){function t(t,r,n){var i=e.call(this,t,n)||this;return Object.defineProperty(i,"options",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return l(t,e),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return this.options.get(e.storedValue,e.parent?e.parent.storedValue:null)}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=nt(n)?this.options.set(n,e?e.storedValue:null):n,o=tt(this,e,t,r,i);return this.watchTargetNodeForInvalidations(o,i,this.options),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=nt(t)?this.options.set(t,e?e.storedValue:null):t;if(!e.isDetaching&&e.type===this&&e.storedValue===i)return e.setParent(r,n),e;var o=this.instantiate(r,n,void 0,i);return e.die(),o}}),t}(mn);function On(e,t){if(be(e,1),Lt()&&2===arguments.length&&"string"==typeof arguments[1])throw mt("References with base path are no longer supported. Please remove the base path.");var r=t||void 0,n=t?t.onInvalidated:void 0;if(r&&(r.get||r.set)){if(Lt()&&(!r.get||!r.set))throw mt("reference options must either contain both a 'get' and a 'set' method or none of them");return new Pn(e,{get:r.get,set:r.set},n)}return new wn(e,n)}function jn(e){return(e.flags&ne.Reference)>0}function _n(e,t){var r=On(e,s(s({},t),{onInvalidated:function(e){t&&t.onInvalidated&&t.onInvalidated(e),e.removeRef()}}));return t&&!1===t.acceptsUndefined?r:un(r)}var Sn=function(e){function t(t,r){var n=e.call(this,t)||this;return Object.defineProperty(n,"validType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Identifier}),n}return l(t,e),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(!(e&&e.type instanceof xr))throw mt("Identifier types can only be instantiated as direct child of a model type");return tt(this,e,t,r,n)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){if(e.storedValue!==t)throw mt("Tried to change identifier from '"+e.storedValue+"' to '"+t+"'. Changing identifiers is not allowed.");return e.setParent(r,n),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return typeof e!==this.validType?Ye(t,e,"Value is not a valid "+this.describe()+", expected a "+this.validType):Ge()}}),t}(pe),An=function(e){function t(){var t=e.call(this,"identifier","string")||this;return Object.defineProperty(t,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Identifier}),t}return l(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifier"}}),t}(Sn),In=function(e){function t(){return e.call(this,"identifierNumber","number")||this}return l(t,e),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifierNumber"}}),t}(Sn),xn=new An,Tn=new In;function Cn(e){return fe(e)&&(e.flags&ne.Identifier)>0}function En(e){return""+e}function Vn(e){return"string"==typeof e||"number"==typeof e}function Nn(e,t){Ut(e,Vn,"string or number (identifier)",t)}function Dn(e){return new kn(e)}var kn=function(e){function t(t){var r=e.call(this,t.name)||this;return Object.defineProperty(r,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:ne.Custom}),r}return l(t,e),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.options.isTargetType(e))return Ge();var r=this.options.getValidationMessage(e);return r?Ye(t,e,"Invalid value for type '"+this.name+"': "+r):Ge()}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.options.toSnapshot(e.storedValue)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return tt(this,e,t,r,this.options.isTargetType(n)?n:this.options.fromSnapshot(n,e&&e.root.environment))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=!this.options.isTargetType(t);if(!e.isDetaching&&(e.type===this&&(i?t===e.snapshot:t===e.storedValue)))return e.setParent(r,n),e;var o=i?this.options.fromSnapshot(t,r.root.environment):t,a=this.instantiate(r,n,void 0,o);return e.die(),a}}),t}(pe),Rn={enumeration:Br,model:Tr,compose:Cr,custom:Dn,reference:On,safeReference:_n,union:Kr,optional:tn,literal:Wr,maybe:un,maybeNull:ln,refinement:Jr,string:Nr,boolean:Rr,number:Dr,integer:kr,Date:Hr,map:dr,array:gr,frozen:hn,identifier:xn,identifierNumber:Tn,late:cn,undefined:Fr,null:zr,snapshotProcessor:sr};exports.types=Rn;
@@ -860,19 +860,19 @@ var e=require("process");Object.defineProperty(exports,"__esModule",{value:!0}),
860
860
  },{}],"sptl":[function(require,module,exports) {
861
861
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPdfKit=exports.getJsPDF=void 0;const e="https://unpkg.com/jspdf@2.2.0/dist/jspdf.umd.min.js";let t;function o(){return t?Promise.resolve(t):new Promise(o=>{var n=document.createElement("script");n.onload=function(){t=window.jspdf.jsPDF,o(t)},n.src=e,document.head.appendChild(n)})}exports.getJsPDF=o;const n="https://unpkg.com/pdfkit@0.13.0/js/pdfkit.standalone.js",s="https://github.com/devongovett/blob-stream/releases/download/v0.1.3/blob-stream.js";async function r(e){return new Promise(t=>{var o=document.createElement("script");o.onload=function(){t(null)},o.src=e,document.head.appendChild(o)})}let d;async function i(){return d?Promise.resolve(d):(await r(n),await r(s),d=window.PDFDocument)}exports.getPdfKit=i;
862
862
  },{}],"GRkH":[function(require,module,exports) {
863
- "use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,o,n){void 0===n&&(n=o),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[o]}})}:function(e,t,o,n){void 0===n&&(n=o),e[n]=t[o]}),t=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(o){if(o&&o.__esModule)return o;var n={};if(null!=o)for(var s in o)"default"!==s&&Object.prototype.hasOwnProperty.call(o,s)&&e(n,o,s);return t(n,o),n},n=this&&this.__rest||function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.createStore=exports.Store=exports.Font=exports.Page=exports.registerShapeModel=exports.SVGElement=exports.ImageElement=exports.TextElement=exports.Element=void 0;const i=require("mobx-state-tree"),a=require("./history"),r=require("nanoid"),l=s(require("konva")),d=require("../utils/download"),c=require("../utils/pdf"),p=require("../utils/validate-key"),g=o(require("../utils/fonts")),h=require("../utils/svg"),m=require("../utils/loader");(0,i.setLivelinessChecking)("ignore"),exports.Element=i.types.model("Element",{id:i.types.identifier,type:"none",x:0,y:0,rotation:0,opacity:1,visible:!0,locked:!1,blurEnabled:!1,blurRadius:10,brightnessEnabled:!1,brightness:0,sepiaEnabled:!1,grayscaleEnabled:!1,shadowEnabled:!1,shadowBlur:5,shadowOffsetX:0,shadowOffsetY:0,shadowColor:"black",custom:i.types.frozen(),selectable:!0,alwaysOnTop:!1,showInExport:!0}).preProcessSnapshot(e=>{const t=Object.assign(Object.assign({},e),{x:e.x||0,y:e.y||0});return"width"in e&&(t.width=t.width||1),"height"in e&&(t.height=t.height||1),t}).postProcessSnapshot(e=>{const t=Object.assign({},e),o={};for(var n in t)"_"!==n[0]&&(o[n]=e[n]);return o}).views(e=>({get page(){return(0,i.getParentOfType)(e,exports.Page)},get store(){return(0,i.getParentOfType)(e,exports.Store)}})).actions(e=>({toJSON:()=>Object.assign({},(0,i.getSnapshot)(e))})).actions(e=>({clone(t){const o=e.toJSON();return t.id=t.id||(0,r.nanoid)(10),Object.assign(o,t),e.page.addElement(o)},set(t){Object.assign(e,t)},moveUp(){e.page.moveElementsUp([e.id])},moveTop(){e.page.moveElementsTop([e.id])},moveDown(){e.page.moveElementsDown([e.id])},moveBottom(){e.page.moveElementsBottom([e.id])},beforeDestroy(){e.store.history.endTransaction()}})),exports.TextElement=exports.Element.named("Text").props({type:"text",text:"",placeholder:"",fontSize:14,fontFamily:"Roboto",fontStyle:"normal",fontWeight:"normal",textDecoration:"",fill:"black",align:"center",width:100,height:14,strokeWidth:0,stroke:"black",lineHeight:i.types.optional(i.types.union(i.types.number,i.types.string),1.2),letterSpacing:0,_editModeEnabled:!1}).preProcessSnapshot(e=>Object.assign({},e)).actions(e=>({toggleEditMode(t){e._editModeEnabled=null!=t?t:!e._editModeEnabled,e._editModeEnabled?e.store.history.startTransaction():e.store.history.endTransaction()}})),exports.ImageElement=exports.Element.named("Image").props({type:"image",width:100,height:100,src:"",cropX:0,cropY:0,cropWidth:1,cropHeight:1,cornerRadius:0,flipX:!1,flipY:!1,clipSrc:"",borderColor:"black",borderSize:0,_cropModeEnabled:!1}).actions(e=>({toggleCropMode(t){e._cropModeEnabled=null!=t?t:!e._cropModeEnabled,e._cropModeEnabled?e.store.history.startTransaction():e.store.history.endTransaction()}})),exports.SVGElement=exports.Element.named("SVG").props({type:"svg",src:"",maskSrc:"",__svgString:"",cropX:0,cropY:0,cropWidth:1,cropHeight:1,keepRatio:!0,flipX:!1,flipY:!1,width:100,height:100,borderColor:"black",borderSize:0,colorsReplace:i.types.map(i.types.string)}).preProcessSnapshot(e=>Object.assign(Object.assign({},e),{src:e.src||e.svgSource})).views(e=>({get colors(){return e.__svgString?(0,h.getColors)(e.__svgString):[]},get __finalSrc(){return e.__svgString?(0,h.replaceColors)(e.__svgString,e.colorsReplace):this.src},get __isLoaded(){return!!e.__svgString&&(!(Array.from(e.colorsReplace.keys()).length>0)||e.__finalSrc!==e.src)}})).actions(e=>{let t=()=>{};return{async _loadSVG(){if(!e.src)return;const t=await(0,h.urlToString)(e.src);(0,i.isAlive)(e)&&(0,i.hasParent)(e)&&e.store.history.ignore(()=>{e.set({__svgString:(0,h.fixSize)(t)})})},async afterCreate(){e._loadSVG();let o=e.src;t=(0,i.onSnapshot)(e,t=>{t.src===o&&e.__svgString||(e._loadSVG(),o=e.src)})},beforeDestroy(){t()},replaceColor(t,o){e.colorsReplace.set(t,o)}}});const f={svg:exports.SVGElement,text:exports.TextElement,image:exports.ImageElement},u=[];function y(e){const t=e.type;if(!t)throw new Error('You must pass "type" attribute to custom model.');const o=exports.Element.named(t).props(e);f[t]=o,u.push(o)}exports.registerShapeModel=y;const E=[...new Array(20)].map((e,t)=>i.types.late(()=>u[t])),b=i.types.union({dispatcher:e=>{const t=f[e.type];if(!t)throw new Error(`Unknown element type: "${e.type}"`);return t}},exports.SVGElement,exports.TextElement,exports.ImageElement,...E);function v({key:e,showCredit:t}={key:"",showCredit:!1}){const o=exports.Store.create();return(0,p.validateKey)(e,t),o}exports.Page=i.types.model("Page",{id:i.types.identifier,children:i.types.array(b),width:i.types.optional(i.types.union(i.types.number,i.types.literal("auto")),"auto"),height:i.types.optional(i.types.union(i.types.number,i.types.literal("auto")),"auto"),background:"white",bleed:0,custom:i.types.frozen(),_exporting:!1}).postProcessSnapshot(e=>{const t=Object.assign({},e),o={};for(var n in t)"_"!==n[0]&&(o[n]=e[n]);return o}).views(e=>({get store(){return(0,i.getParentOfType)(e,exports.Store)}})).views(e=>({get computedWidth(){return"auto"===e.width?e.store.width:e.width},get computedHeight(){return"auto"===e.height?e.store.height:e.height}})).actions(e=>({toJSON:()=>JSON.parse(JSON.stringify((0,i.getSnapshot)(e))),_forEachElementUp(t,o){const n=t.map(t=>({id:t,index:e.children.findIndex(e=>e.id===t)}));n.sort((e,t)=>t.index-e.index);for(const{index:s}of n){if(-1==s)continue;const n=s<e.children.length-1&&e.children[s+1],i=t.indexOf(null==n?void 0:n.id)>=0;s===e.children.length-1||i||o(s)}},_forEachElementDown(t,o){const n=t.map(t=>({id:t,index:e.children.findIndex(e=>e.id===t)}));n.sort((e,t)=>e.index-t.index);for(const{index:s}of n){if(-1==s)continue;const n=s>0&&e.children[s-1],i=t.indexOf(null==n?void 0:n.id)>=0;0===s||i||o(s)}return!1}})).actions(e=>({clone(t){const o=e.toJSON();o.children.forEach(e=>{e.id=(0,r.nanoid)(10)});const n=Object.assign(Object.assign(Object.assign({},o),{id:(0,r.nanoid)(10)}),t),s=e.store.addPage(n),i=e.store.pages.indexOf(e);s.setZIndex(i+1),s.select()},setZIndex(t){e.store.setPageZIndex(e.id,t)},set(t){Object.assign(e,t)},select(){e.store.selectPage(e.id)},addElement(t){const o=f[t.type];if(!o)return void console.error("Can not find model with type "+t.type);const n=o.create(Object.assign({id:(0,r.nanoid)(10)},t));return e.children.push(n),n.selectable&&e.store.selectElements([n.id]),n},canMoveElementsUp(t){let o=!1;return e._forEachElementUp(t,()=>{o=o||!0}),o},moveElementsUp(t){e._forEachElementUp(t,t=>{const o=e.children[t];(0,i.detach)(o),e.children.splice(t+1,0,o)})},canMoveElementsTop(e){return this.canMoveElementsUp(e)},moveElementsTop(t){const o=[],n=[];e.children.forEach(e=>{t.indexOf(e.id)>=0?o.push(e):n.push(e)}),e.children.replace(n.concat(o))},canMoveElementsDown(t){let o=!1;return e._forEachElementDown(t,()=>{o=o||!0}),o},moveElementsDown(t){e._forEachElementDown(t,t=>{const o=e.children[t];(0,i.detach)(o),e.children.splice(t-1,0,o)})},canMoveElementsBottom(e){return this.canMoveElementsDown(e)},moveElementsBottom(t){const o=[],n=[];e.children.forEach(e=>{t.indexOf(e.id)>=0?o.push(e):n.push(e)}),e.children.replace(o.concat(n))}})).actions(e=>({moveElementUp(t){console.warn("page.moveElementUp(id) is deprecated. Please use page.moveElementsUp([id1, id2]) instead."),e.moveElementsUp([t])},moveElementDown(t){console.warn("page.moveElementDown(id) is deprecated. Please use page.moveElementsDown([id1, id2]) instead."),e.moveElementsDown([t])},moveElementTop(t){console.warn("page.moveElementTop(id) is deprecated. Please use page.moveElementsTop([id1, id2]) instead."),e.moveElementsTop([t])},moveElementBottom(t){console.warn("page.moveElementBottom(id) is deprecated. Please use page.moveElementsBottom([id1, id2]) instead."),e.moveElementsBottom([t])}})),exports.Font=i.types.model("Font",{fontFamily:i.types.string,url:i.types.optional(i.types.string,""),styles:i.types.frozen()}).preProcessSnapshot(e=>Object.assign(Object.assign({},e),{fontFamily:e.fontFamily||e.name})),exports.Store=i.types.model("Store",{role:"",pages:i.types.array(exports.Page),fonts:i.types.array(exports.Font),width:1080,height:1080,scale:1,scaleToFit:1,_bleedVisible:!1,openedSidePanel:"",selectedElementsIds:i.types.array(i.types.string),history:i.types.optional(a.UndoManager,{targetPath:"../pages"}),_elementsPixelRatio:2,_activePageId:""}).views(e=>({get selectedElements(){return e.selectedElementsIds.map(t=>{for(const o of e.pages)for(const e of o.children)if(e.id===t)return e}).filter(e=>!!e)},get activePage(){return e.pages.slice().find(t=>t.id===e._activePageId)||(e.pages.length?e.pages[0]:null)}})).actions(e=>({setRole(t){e.role=t},getElementById(t){for(const o of e.pages)for(const e of o.children)if(e.id===t)return e},addPage(t){const o=exports.Page.create(Object.assign({id:(0,r.nanoid)(10)},t));return e.pages.push(o),e._activePageId=o.id,o},selectPage(t){e._activePageId=t},selectElements(t){e.selectedElementsIds=(0,i.cast)(t)},_toggleBleed(t){e._bleedVisible=null!=t?t:!e._bleedVisible},openSidePanel(t){e.openedSidePanel=t},setScale(t){e.scale=t},_setScaleToFit(t){e.scaleToFit=t},setElementsPixelRatio(t){e._elementsPixelRatio=t},setSize(t,o,n){if(n){const n=t/e.width,s=o/e.height;for(const t of e.pages)for(const e of t.children)e.set({x:e.x*n,y:e.y*s}),"text"===e.type?e.set({fontSize:e.fontSize*n,width:Math.max(e.width*n,2)}):"image"===e.type?e.set({width:e.width*n,height:e.height*s}):"svg"===e.type&&e.set({width:Math.max(e.width*n,2),height:Math.max(e.height*n,2)})}e.width=t,e.height=o},setPageZIndex(t,o){const n=e.pages.find(e=>e.id===t);n&&((0,i.detach)(n),e.pages.remove(n),e.pages.splice(o,0,n))},deletePages(t){const o=e.pages.indexOf(e.activePage);t.forEach(t=>{const o=e.pages.find(e=>e.id===t);(0,i.destroy)(o)});const n=Math.min(e.pages.length-1,o),s=e.pages[n];s&&(e._activePageId=s.id),e.selectedElementsIds=(0,i.cast)(e.selectedElementsIds.filter(t=>e.getElementById(t)))},deleteElements(t){t.forEach(t=>{e.pages.forEach(e=>{const o=e.children.find(e=>e.id===t);o&&(0,i.destroy)(o)})}),e.selectedElementsIds=(0,i.cast)([])},on(t,o){if("change"===t){let t=e.toJSON();return(0,i.onSnapshot)(e,n=>{const s=e.toJSON();JSON.stringify(s)!==JSON.stringify(t)&&(t=s,o(s))})}},async toDataURL({pixelRatio:t,ignoreBackground:o,pageId:n,mimeType:s,includeBleed:i,quality:a}={}){var r;const d=t||1;n=n||(null===(r=e.pages[0])||void 0===r?void 0:r.id);const c=e.pages.find(e=>e.id===n);if(!c)throw new Error(`No page for export with id ${n}`);null==c||c.set({_exporting:!0}),await new Promise(e=>{setTimeout(e,0)}),await e.waitLoading();const p=l.default.stages.find(e=>e.getAttr("pageId")===n);if(!p)throw new Error(`Export is failed. Can not find stage for page ${n}. Looks like <Workspace /> component is not mounted, but it is required in order to process the export.`);const g=p.findOne(".page-container");p.find("Transformer").forEach(e=>e.visible(!1)),g.findOne(".page-background").shadowEnabled(!1),g.findOne(".page-background").strokeEnabled(!1),g.find(".highlighter").forEach(e=>e.visible(!1));const h=g.findOne(".page-background-group"),m=h.clip();h.clip({x:null,y:null,width:null,height:null});const f=g.find(e=>e.getAttr("hideInExport"));f.forEach(e=>{e.setAttr("oldVisible",e.visible()),e.hide()}),o&&g.findOne(".page-background").hide();const u=i?c.bleed:0;let y=u;e._bleedVisible&&i?y=0:e._bleedVisible&&!i&&(y=-c.bleed);const E=document.createElement("canvas");E.width=(c.computedWidth+2*u)*d,E.height=(c.computedHeight+2*u)*d;const b=E.getContext("2d");"image/jpeg"===s&&(b.fillStyle="white",b.fillRect(0,0,E.width,E.height));const v=g.toCanvas({x:g.x()-y*g.scaleX(),y:g.y()-y*g.scaleY(),width:(c.computedWidth+2*u)*g.scaleX(),height:(c.computedHeight+2*u)*g.scaleY(),pixelRatio:1/g.scaleX()*d});b.drawImage(v,0,0);const x=E.toDataURL(s,a);return o&&g.findOne(".page-background").show(),f.forEach(e=>{e.visible(e.getAttr("oldVisible"))}),g.findOne(".page-background").shadowEnabled(!0),g.findOne(".page-background").strokeEnabled(!0),p.find("Transformer").forEach(e=>e.visible(!0)),g.find(".highlighter").forEach(e=>e.visible(!0)),h.clip(m),null==c||c.set({_exporting:!1}),x},async saveAsImage(t={}){var{fileName:o}=t,s=n(t,["fileName"]);const i=s.mimeType||"image/png",a=i.split("/")[1];(0,d.downloadFile)(await e.toDataURL(s),o||"polotno."+a,i)},async _toPDF(t){const o=t.dpi||300,n=t.parallel||1,s=t.unit||"mm",i=t.pixelUnitRatio||25.4/o,a=t.pixelRatio||1,r=await(0,c.getJsPDF)(),l=e=>e*i,d=e.pages[0]||{},p=t.includeBleed?d.bleed:0,g=l(d.computedWidth+2*p),h=l(d.computedHeight+2*p);var m=new r({unit:s,orientation:g>h?"landscape":"portrait",format:[g,h],compress:!0});m.deletePage(1);const f=e._elementsPixelRatio;e.setElementsPixelRatio(a),await new Promise(e=>setTimeout(e));const u=((e,t)=>{for(var o=[],n=0;n<e.length;n+=t)o.push(e.slice(n,n+t));return o})(e.pages,n);for(const c of u){const o=c.map(async o=>{const n=t.includeBleed?o.bleed:0,s=l(o.computedWidth+2*n),i=l(o.computedHeight+2*n);let r=0,d=a;for(;r<10;){2===(r+=1)&&console.error("Polotno can not export PDF with current settings. Quality is automatically reduced.");const n=await e.toDataURL(Object.assign(Object.assign({},t),{pageId:o.id,pixelRatio:d}));if(n.length>20)return{url:n,width:s,height:i};d*=.8}});(await Promise.all(o)).forEach(({url:e,width:t,height:o})=>{m.addPage([t,o],t>o?"landscape":"portrait"),m.addImage(e,0,0,t,o,void 0,"FAST")})}return e.setElementsPixelRatio(f),m},toPDFDataURL:async t=>(await e._toPDF(Object.assign({mimeType:"image/jpeg"},t))).output("datauristring"),async saveAsPDF(t={}){var{fileName:o}=t,s=n(t,["fileName"]);(await e._toPDF(Object.assign({mimeType:"image/jpeg"},s))).save(o||"polotno.pdf")},async waitLoading(){await(0,m.whenLoaded)()},toJSON:()=>({width:e.width,height:e.height,fonts:(0,i.getSnapshot)(e.fonts),pages:(0,i.getSnapshot)(e.pages)}),loadJSON(t,o=!1){var n;const s=Object.assign({},t);e.pages.forEach(e=>e.children.forEach(e=>(0,i.detach)(e)));const a=e.pages.indexOf(e.activePage);let r=null===(n=s.pages[a]||s.pages[0])||void 0===n?void 0:n.id;e.pages=(0,i.cast)([]),s._activePageId=r,s.scale=e.scale,s.openedSidePanel=e.openedSidePanel,s._bleedVisible=e._bleedVisible,o&&(s.history=e.history.toJSON()),(0,i.applySnapshot)(e,s)},addFont(t){e.removeFont(t.fontFamily),e.fonts.push(t),e.loadFont(t.fontFamily)},removeFont(t){e.fonts.filter(e=>e.fontFamily===t).forEach(e=>(0,i.destroy)(e))},async loadFont(t){const o=e.fonts.find(e=>e.fontFamily===t)||g.globalFonts.find(e=>e.fontFamily===t);o?g.injectCustomFont(o):g.injectGoogleFont(t),await g.loadFont(t)}})),exports.createStore=v,exports.default=v;
863
+ "use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,o,n){void 0===n&&(n=o),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[o]}})}:function(e,t,o,n){void 0===n&&(n=o),e[n]=t[o]}),t=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(o){if(o&&o.__esModule)return o;var n={};if(null!=o)for(var s in o)"default"!==s&&Object.prototype.hasOwnProperty.call(o,s)&&e(n,o,s);return t(n,o),n},n=this&&this.__rest||function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.createStore=exports.Store=exports.Font=exports.Page=exports.registerShapeModel=exports.SVGElement=exports.ImageElement=exports.TextElement=exports.Element=void 0;const i=require("mobx-state-tree"),a=require("./history"),r=require("nanoid"),l=s(require("konva")),d=require("../utils/download"),c=require("../utils/pdf"),p=require("../utils/validate-key"),g=o(require("../utils/fonts")),h=require("../utils/svg"),m=require("../utils/loader");(0,i.setLivelinessChecking)("ignore"),exports.Element=i.types.model("Element",{id:i.types.identifier,type:"none",name:"",x:0,y:0,rotation:0,opacity:1,visible:!0,locked:!1,blurEnabled:!1,blurRadius:10,brightnessEnabled:!1,brightness:0,sepiaEnabled:!1,grayscaleEnabled:!1,shadowEnabled:!1,shadowBlur:5,shadowOffsetX:0,shadowOffsetY:0,shadowColor:"black",custom:i.types.frozen(),selectable:!0,alwaysOnTop:!1,showInExport:!0}).preProcessSnapshot(e=>{const t=Object.assign(Object.assign({},e),{x:e.x||0,y:e.y||0});return"width"in e&&(t.width=t.width||1),"height"in e&&(t.height=t.height||1),t}).postProcessSnapshot(e=>{const t=Object.assign({},e),o={};for(var n in t)"_"!==n[0]&&(o[n]=e[n]);return o}).views(e=>({get page(){return(0,i.getParentOfType)(e,exports.Page)},get store(){return(0,i.getParentOfType)(e,exports.Store)}})).actions(e=>({toJSON:()=>Object.assign({},(0,i.getSnapshot)(e))})).actions(e=>({clone(t){const o=e.toJSON();return t.id=t.id||(0,r.nanoid)(10),Object.assign(o,t),e.page.addElement(o)},set(t){Object.assign(e,t)},moveUp(){e.page.moveElementsUp([e.id])},moveTop(){e.page.moveElementsTop([e.id])},moveDown(){e.page.moveElementsDown([e.id])},moveBottom(){e.page.moveElementsBottom([e.id])},beforeDestroy(){e.store.history.endTransaction()}})),exports.TextElement=exports.Element.named("Text").props({type:"text",text:"",placeholder:"",fontSize:14,fontFamily:"Roboto",fontStyle:"normal",fontWeight:"normal",textDecoration:"",fill:"black",align:"center",width:100,height:14,strokeWidth:0,stroke:"black",lineHeight:i.types.optional(i.types.union(i.types.number,i.types.string),1.2),letterSpacing:0,_editModeEnabled:!1}).preProcessSnapshot(e=>Object.assign({},e)).actions(e=>({toggleEditMode(t){e._editModeEnabled=null!=t?t:!e._editModeEnabled,e._editModeEnabled?e.store.history.startTransaction():e.store.history.endTransaction()}})),exports.ImageElement=exports.Element.named("Image").props({type:"image",width:100,height:100,src:"",cropX:0,cropY:0,cropWidth:1,cropHeight:1,cornerRadius:0,flipX:!1,flipY:!1,clipSrc:"",borderColor:"black",borderSize:0,_cropModeEnabled:!1}).actions(e=>({toggleCropMode(t){e._cropModeEnabled=null!=t?t:!e._cropModeEnabled,e._cropModeEnabled?e.store.history.startTransaction():e.store.history.endTransaction()}})),exports.SVGElement=exports.Element.named("SVG").props({type:"svg",src:"",maskSrc:"",__svgString:"",cropX:0,cropY:0,cropWidth:1,cropHeight:1,keepRatio:!0,flipX:!1,flipY:!1,width:100,height:100,borderColor:"black",borderSize:0,colorsReplace:i.types.map(i.types.string)}).preProcessSnapshot(e=>Object.assign(Object.assign({},e),{src:e.src||e.svgSource})).views(e=>({get colors(){return e.__svgString?(0,h.getColors)(e.__svgString):[]},get __finalSrc(){return e.__svgString?(0,h.replaceColors)(e.__svgString,e.colorsReplace):this.src},get __isLoaded(){return!!e.__svgString&&(!(Array.from(e.colorsReplace.keys()).length>0)||e.__finalSrc!==e.src)}})).actions(e=>{let t=()=>{};return{async _loadSVG(){if(!e.src)return;const t=await(0,h.urlToString)(e.src);(0,i.isAlive)(e)&&(0,i.hasParent)(e)&&e.store.history.ignore(()=>{e.set({__svgString:(0,h.fixSize)(t)})})},async afterCreate(){e._loadSVG();let o=e.src;t=(0,i.onSnapshot)(e,t=>{t.src===o&&e.__svgString||(e._loadSVG(),o=e.src)})},beforeDestroy(){t()},replaceColor(t,o){e.colorsReplace.set(t,o)}}});const f={svg:exports.SVGElement,text:exports.TextElement,image:exports.ImageElement},u=[];function y(e){const t=e.type;if(!t)throw new Error('You must pass "type" attribute to custom model.');const o=exports.Element.named(t).props(e);f[t]=o,u.push(o)}exports.registerShapeModel=y;const E=[...new Array(20)].map((e,t)=>i.types.late(()=>u[t])),b=i.types.union({dispatcher:e=>{const t=f[e.type];if(!t)throw new Error(`Unknown element type: "${e.type}"`);return t}},exports.SVGElement,exports.TextElement,exports.ImageElement,...E);function v({key:e,showCredit:t}={key:"",showCredit:!1}){const o=exports.Store.create();return(0,p.validateKey)(e,t),o}exports.Page=i.types.model("Page",{id:i.types.identifier,children:i.types.array(b),width:i.types.optional(i.types.union(i.types.number,i.types.literal("auto")),"auto"),height:i.types.optional(i.types.union(i.types.number,i.types.literal("auto")),"auto"),background:"white",bleed:0,custom:i.types.frozen(),_exporting:!1}).postProcessSnapshot(e=>{const t=Object.assign({},e),o={};for(var n in t)"_"!==n[0]&&(o[n]=e[n]);return o}).views(e=>({get store(){return(0,i.getParentOfType)(e,exports.Store)}})).views(e=>({get computedWidth(){return"auto"===e.width?e.store.width:e.width},get computedHeight(){return"auto"===e.height?e.store.height:e.height}})).actions(e=>({toJSON:()=>JSON.parse(JSON.stringify((0,i.getSnapshot)(e))),_forEachElementUp(t,o){const n=t.map(t=>({id:t,index:e.children.findIndex(e=>e.id===t)}));n.sort((e,t)=>t.index-e.index);for(const{index:s}of n){if(-1==s)continue;const n=s<e.children.length-1&&e.children[s+1],i=t.indexOf(null==n?void 0:n.id)>=0;s===e.children.length-1||i||o(s)}},_forEachElementDown(t,o){const n=t.map(t=>({id:t,index:e.children.findIndex(e=>e.id===t)}));n.sort((e,t)=>e.index-t.index);for(const{index:s}of n){if(-1==s)continue;const n=s>0&&e.children[s-1],i=t.indexOf(null==n?void 0:n.id)>=0;0===s||i||o(s)}return!1}})).actions(e=>({clone(t){const o=e.toJSON();o.children.forEach(e=>{e.id=(0,r.nanoid)(10)});const n=Object.assign(Object.assign(Object.assign({},o),{id:(0,r.nanoid)(10)}),t),s=e.store.addPage(n),i=e.store.pages.indexOf(e);s.setZIndex(i+1),s.select()},setZIndex(t){e.store.setPageZIndex(e.id,t)},set(t){Object.assign(e,t)},select(){e.store.selectPage(e.id)},addElement(t){const o=f[t.type];if(!o)return void console.error("Can not find model with type "+t.type);const n=o.create(Object.assign({id:(0,r.nanoid)(10)},t));return e.children.push(n),n.selectable&&e.store.selectElements([n.id]),n},canMoveElementsUp(t){let o=!1;return e._forEachElementUp(t,()=>{o=o||!0}),o},moveElementsUp(t){e._forEachElementUp(t,t=>{const o=e.children[t];(0,i.detach)(o),e.children.splice(t+1,0,o)})},canMoveElementsTop(e){return this.canMoveElementsUp(e)},moveElementsTop(t){const o=[],n=[];e.children.forEach(e=>{t.indexOf(e.id)>=0?o.push(e):n.push(e)}),e.children.replace(n.concat(o))},canMoveElementsDown(t){let o=!1;return e._forEachElementDown(t,()=>{o=o||!0}),o},moveElementsDown(t){e._forEachElementDown(t,t=>{const o=e.children[t];(0,i.detach)(o),e.children.splice(t-1,0,o)})},canMoveElementsBottom(e){return this.canMoveElementsDown(e)},moveElementsBottom(t){const o=[],n=[];e.children.forEach(e=>{t.indexOf(e.id)>=0?o.push(e):n.push(e)}),e.children.replace(o.concat(n))},setElementZIndex(t,o){const n=e.children.find(e=>e.id===t);n&&((0,i.detach)(n),e.children.remove(n),e.children.splice(o,0,n))}})).actions(e=>({moveElementUp(t){console.warn("page.moveElementUp(id) is deprecated. Please use page.moveElementsUp([id1, id2]) instead."),e.moveElementsUp([t])},moveElementDown(t){console.warn("page.moveElementDown(id) is deprecated. Please use page.moveElementsDown([id1, id2]) instead."),e.moveElementsDown([t])},moveElementTop(t){console.warn("page.moveElementTop(id) is deprecated. Please use page.moveElementsTop([id1, id2]) instead."),e.moveElementsTop([t])},moveElementBottom(t){console.warn("page.moveElementBottom(id) is deprecated. Please use page.moveElementsBottom([id1, id2]) instead."),e.moveElementsBottom([t])}})),exports.Font=i.types.model("Font",{fontFamily:i.types.string,url:i.types.optional(i.types.string,""),styles:i.types.frozen()}).preProcessSnapshot(e=>Object.assign(Object.assign({},e),{fontFamily:e.fontFamily||e.name})),exports.Store=i.types.model("Store",{role:"",pages:i.types.array(exports.Page),fonts:i.types.array(exports.Font),width:1080,height:1080,scale:1,scaleToFit:1,_bleedVisible:!1,openedSidePanel:"",selectedElementsIds:i.types.array(i.types.string),history:i.types.optional(a.UndoManager,{targetPath:"../pages"}),_elementsPixelRatio:2,_activePageId:""}).views(e=>({get selectedElements(){return e.selectedElementsIds.map(t=>{for(const o of e.pages)for(const e of o.children)if(e.id===t)return e}).filter(e=>!!e)},get activePage(){return e.pages.slice().find(t=>t.id===e._activePageId)||(e.pages.length?e.pages[0]:null)}})).actions(e=>({setRole(t){e.role=t},getElementById(t){for(const o of e.pages)for(const e of o.children)if(e.id===t)return e},addPage(t){const o=exports.Page.create(Object.assign({id:(0,r.nanoid)(10)},t));return e.pages.push(o),e._activePageId=o.id,o},selectPage(t){e._activePageId=t},selectElements(t){e.selectedElementsIds=(0,i.cast)(t)},_toggleBleed(t){e._bleedVisible=null!=t?t:!e._bleedVisible},openSidePanel(t){e.openedSidePanel=t},setScale(t){e.scale=t},_setScaleToFit(t){e.scaleToFit=t},setElementsPixelRatio(t){e._elementsPixelRatio=t},setSize(t,o,n){if(n){const n=t/e.width,s=o/e.height;for(const t of e.pages)for(const e of t.children)e.set({x:e.x*n,y:e.y*s}),"text"===e.type?e.set({fontSize:e.fontSize*n,width:Math.max(e.width*n,2)}):"image"===e.type?e.set({width:e.width*n,height:e.height*s}):"svg"===e.type&&e.set({width:Math.max(e.width*n,2),height:Math.max(e.height*n,2)})}e.width=t,e.height=o},setPageZIndex(t,o){const n=e.pages.find(e=>e.id===t);n&&((0,i.detach)(n),e.pages.remove(n),e.pages.splice(o,0,n))},deletePages(t){const o=e.pages.indexOf(e.activePage);t.forEach(t=>{const o=e.pages.find(e=>e.id===t);(0,i.destroy)(o)});const n=Math.min(e.pages.length-1,o),s=e.pages[n];s&&(e._activePageId=s.id),e.selectedElementsIds=(0,i.cast)(e.selectedElementsIds.filter(t=>e.getElementById(t)))},deleteElements(t){t.forEach(t=>{e.pages.forEach(e=>{const o=e.children.find(e=>e.id===t);o&&(0,i.destroy)(o)})}),e.selectedElementsIds=(0,i.cast)([])},on(t,o){if("change"===t){let t=e.toJSON();return(0,i.onSnapshot)(e,n=>{const s=e.toJSON();JSON.stringify(s)!==JSON.stringify(t)&&(t=s,o(s))})}},async toDataURL({pixelRatio:t,ignoreBackground:o,pageId:n,mimeType:s,includeBleed:i,quality:a}={}){var r;const d=t||1;n=n||(null===(r=e.pages[0])||void 0===r?void 0:r.id);const c=e.pages.find(e=>e.id===n);if(!c)throw new Error(`No page for export with id ${n}`);null==c||c.set({_exporting:!0}),await new Promise(e=>{setTimeout(e,0)}),await e.waitLoading();const p=l.default.stages.find(e=>e.getAttr("pageId")===n);if(!p)throw new Error(`Export is failed. Can not find stage for page ${n}. Looks like <Workspace /> component is not mounted, but it is required in order to process the export.`);const g=p.findOne(".page-container");p.find("Transformer").forEach(e=>e.visible(!1)),g.findOne(".page-background").shadowEnabled(!1),g.findOne(".page-background").strokeEnabled(!1),g.find(".highlighter").forEach(e=>e.visible(!1));const h=g.findOne(".page-background-group"),m=h.clip();h.clip({x:null,y:null,width:null,height:null});const f=g.find(e=>e.getAttr("hideInExport"));f.forEach(e=>{e.setAttr("oldVisible",e.visible()),e.hide()}),o&&g.findOne(".page-background").hide();const u=i?c.bleed:0;let y=u;e._bleedVisible&&i?y=0:e._bleedVisible&&!i&&(y=-c.bleed);const E=document.createElement("canvas");E.width=(c.computedWidth+2*u)*d,E.height=(c.computedHeight+2*u)*d;const b=E.getContext("2d");"image/jpeg"===s&&(b.fillStyle="white",b.fillRect(0,0,E.width,E.height));const v=g.toCanvas({x:g.x()-y*g.scaleX(),y:g.y()-y*g.scaleY(),width:(c.computedWidth+2*u)*g.scaleX(),height:(c.computedHeight+2*u)*g.scaleY(),pixelRatio:1/g.scaleX()*d});b.drawImage(v,0,0);const x=E.toDataURL(s,a);return o&&g.findOne(".page-background").show(),f.forEach(e=>{e.visible(e.getAttr("oldVisible"))}),g.findOne(".page-background").shadowEnabled(!0),g.findOne(".page-background").strokeEnabled(!0),p.find("Transformer").forEach(e=>e.visible(!0)),g.find(".highlighter").forEach(e=>e.visible(!0)),h.clip(m),null==c||c.set({_exporting:!1}),x},async saveAsImage(t={}){var{fileName:o}=t,s=n(t,["fileName"]);const i=s.mimeType||"image/png",a=i.split("/")[1];(0,d.downloadFile)(await e.toDataURL(s),o||"polotno."+a,i)},async _toPDF(t){const o=t.dpi||300,n=t.parallel||1,s=t.unit||"mm",i=t.pixelUnitRatio||25.4/o,a=t.pixelRatio||1,r=await(0,c.getJsPDF)(),l=e=>e*i,d=e.pages[0]||{},p=t.includeBleed?d.bleed:0,g=l(d.computedWidth+2*p),h=l(d.computedHeight+2*p);var m=new r({unit:s,orientation:g>h?"landscape":"portrait",format:[g,h],compress:!0});m.deletePage(1);const f=e._elementsPixelRatio;e.setElementsPixelRatio(a),await new Promise(e=>setTimeout(e));const u=((e,t)=>{for(var o=[],n=0;n<e.length;n+=t)o.push(e.slice(n,n+t));return o})(e.pages,n);for(const c of u){const o=c.map(async o=>{const n=t.includeBleed?o.bleed:0,s=l(o.computedWidth+2*n),i=l(o.computedHeight+2*n);let r=0,d=a;for(;r<10;){2===(r+=1)&&console.error("Polotno can not export PDF with current settings. Quality is automatically reduced.");const n=await e.toDataURL(Object.assign(Object.assign({},t),{pageId:o.id,pixelRatio:d}));if(n.length>20)return{url:n,width:s,height:i};d*=.8}});(await Promise.all(o)).forEach(({url:e,width:t,height:o})=>{m.addPage([t,o],t>o?"landscape":"portrait"),m.addImage(e,0,0,t,o,void 0,"FAST")})}return e.setElementsPixelRatio(f),m},toPDFDataURL:async t=>(await e._toPDF(Object.assign({mimeType:"image/jpeg"},t))).output("datauristring"),async saveAsPDF(t={}){var{fileName:o}=t,s=n(t,["fileName"]);(await e._toPDF(Object.assign({mimeType:"image/jpeg"},s))).save(o||"polotno.pdf")},async waitLoading(){await(0,m.whenLoaded)()},toJSON:()=>({width:e.width,height:e.height,fonts:(0,i.getSnapshot)(e.fonts),pages:(0,i.getSnapshot)(e.pages)}),loadJSON(t,o=!1){var n;const s=Object.assign({},t);e.pages.forEach(e=>e.children.forEach(e=>(0,i.detach)(e)));const a=e.pages.indexOf(e.activePage);let r=null===(n=s.pages[a]||s.pages[0])||void 0===n?void 0:n.id;e.pages=(0,i.cast)([]),s._activePageId=r,s.scale=e.scale,s.openedSidePanel=e.openedSidePanel,s._bleedVisible=e._bleedVisible,o&&(s.history=e.history.toJSON()),(0,i.applySnapshot)(e,s)},addFont(t){e.removeFont(t.fontFamily),e.fonts.push(t),e.loadFont(t.fontFamily)},removeFont(t){e.fonts.filter(e=>e.fontFamily===t).forEach(e=>(0,i.destroy)(e))},async loadFont(t){const o=e.fonts.find(e=>e.fontFamily===t)||g.globalFonts.find(e=>e.fontFamily===t);o?g.injectCustomFont(o):g.injectGoogleFont(t),await g.loadFont(t)}})),exports.createStore=v,exports.default=v;
864
864
  },{"mobx-state-tree":"pk4v","./history":"X9z9","nanoid":"iDyL","konva":"aTGn","../utils/download":"HWHW","../utils/pdf":"sptl","../utils/validate-key":"zree","../utils/fonts":"XXLd","../utils/svg":"B1DI","../utils/loader":"bN4e"}],"GGhN":[function(require,module,exports) {
865
865
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getImageSize=void 0;const e=require("./svg");function t(t){return new Promise(i=>{const o=document.createElement("img");o.onload=(async()=>{0===o.width||0===o.height?i(await(0,e.getSvgSize)(t)):i({width:o.width,height:o.height})}),o.src=t})}exports.getImageSize=t;
866
866
  },{"./svg":"B1DI"}],"oiQN":[function(require,module,exports) {
867
867
  "use strict";async function e(e){return new Promise((o,r)=>{const t=new FileReader;t.readAsDataURL(e),t.onload=(()=>o(t.result)),t.onerror=(e=>r(e))})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.localFileToURL=void 0,exports.localFileToURL=e;
868
868
  },{}],"Tz78":[function(require,module,exports) {
869
- "use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ImagesGrid=void 0;const t=e(require("react")),a=e(require("../utils/styled")),r=require("@blueprintjs/core"),l=require("../utils/l10n"),i=require("../canvas/page"),o=(0,a.default)("div")`
869
+ "use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ImagesGrid=void 0;const t=e(require("react")),r=e(require("../utils/styled")),l=require("@blueprintjs/core"),a=require("../utils/l10n"),i=require("../canvas/page"),o=(0,r.default)("div",t.default.forwardRef)`
870
870
  height: 100%;
871
871
  overflow: auto;
872
- `,d=(0,a.default)("div")`
872
+ `,d=(0,r.default)("div")`
873
873
  width: 33%;
874
874
  float: left;
875
- `,n=(0,a.default)("div")`
875
+ `,n=(0,r.default)("div")`
876
876
  padding: 5px;
877
877
  width: 100%;
878
878
  &:hover .credit {
@@ -883,16 +883,16 @@ var e=require("process");Object.defineProperty(exports,"__esModule",{value:!0}),
883
883
  opacity: 1;
884
884
  }
885
885
  }
886
- `,s=(0,a.default)("div")`
886
+ `,s=(0,r.default)("div")`
887
887
  border-radius: 5px;
888
888
  position: relative;
889
889
  overflow: hidden;
890
890
  box-shadow: ${e=>e["data-shadowenabled"]?"0 0 5px rgba(16, 22, 26, 0.3)":""};
891
- `,c=(0,a.default)("img")`
891
+ `,u=(0,r.default)("img")`
892
892
  width: 100%;
893
893
  cursor: pointer;
894
894
  display: block;
895
- `,u=(0,a.default)("div")`
895
+ `,c=(0,r.default)("div")`
896
896
  position: absolute;
897
897
  bottom: 0px;
898
898
  left: 0px;
@@ -909,10 +909,10 @@ var e=require("process");Object.defineProperty(exports,"__esModule",{value:!0}),
909
909
  width: 100%;
910
910
  opacity: 0;
911
911
  color: white;
912
- `,g=(0,a.default)("p")`
912
+ `,g=(0,r.default)("p")`
913
913
  text-align: center;
914
914
  padding: 30px;
915
- `,p=({url:e,credit:a,onSelect:r,crossOrigin:l,shadowEnabled:o,itemHeight:d,className:g})=>{const p=null==o||o;return t.default.createElement(n,{onClick:()=>{r()},className:"polotno-close-panel"},t.default.createElement(s,{"data-shadowenabled":p},t.default.createElement(c,{className:g,style:{height:null!=d?d:"auto"},src:e,draggable:!0,crossOrigin:l,onDragStart:()=>{(0,i.registerNextDomDrop)(({x:e,y:t},a)=>{r({x:e,y:t},a)})},onDragEnd:()=>{(0,i.registerNextDomDrop)(null)}}),a&&t.default.createElement(u,{className:"credit"},a)))},m=({images:e,onSelect:a,isLoading:i,getPreview:n,loadMore:s,getCredit:c,getImageClassName:u,rowsNumber:m,crossOrigin:f,shadowEnabled:h,itemHeight:x,error:b})=>{const w=m||2,v=[];for(var E=0;E<w;E++)v.push((e||[]).filter((e,t)=>t%w===E));return t.default.createElement(o,{onScroll:e=>{const t=e.target.scrollHeight-e.target.scrollTop-e.target.offsetHeight;s&&!i&&t<200&&s()}},v.map((e,l)=>t.default.createElement(d,{key:l,style:{width:100/w+"%"}},e.map(e=>t.default.createElement(p,{url:n(e),onSelect:(t,r)=>a(e,t,r),key:n(e),credit:c&&c(e),crossOrigin:f,shadowEnabled:h,itemHeight:x,className:u&&u(e)})),i&&t.default.createElement("div",{style:{padding:"30px"}},t.default.createElement(r.Spinner,null)))),!i&&(!e||!e.length)&&!b&&t.default.createElement(g,null,(0,l.t)("sidePanel.noResults")),b&&t.default.createElement(g,null,(0,l.t)("sidePanel.error")))};exports.ImagesGrid=m;
915
+ `,f=({url:e,credit:r,onSelect:l,crossOrigin:a,shadowEnabled:o,itemHeight:d,className:g})=>{const f=null==o||o;return t.default.createElement(n,{onClick:()=>{l()},className:"polotno-close-panel"},t.default.createElement(s,{"data-shadowenabled":f},t.default.createElement(u,{className:g,style:{height:null!=d?d:"auto"},src:e,draggable:!0,crossOrigin:a,onDragStart:()=>{(0,i.registerNextDomDrop)(({x:e,y:t},r)=>{l({x:e,y:t},r)})},onDragEnd:()=>{(0,i.registerNextDomDrop)(null)}}),r&&t.default.createElement(c,{className:"credit"},r)))},p=({images:e,onSelect:r,isLoading:i,getPreview:n,loadMore:s,getCredit:u,getImageClassName:c,rowsNumber:p,crossOrigin:m,shadowEnabled:h,itemHeight:w,error:x})=>{const v=p||2,b=t.default.useRef(null),E=[];for(var y=0;y<v;y++)E.push((e||[]).filter((e,t)=>t%v===y));const N=t.default.useRef(null);return t.default.useEffect(()=>{var t,r;const l=(null===(t=b.current)||void 0===t?void 0:t.scrollHeight)>(null===(r=b.current)||void 0===r?void 0:r.offsetHeight)+5,a=e&&e.length;return!l&&s&&!i&&a&&(N.current||(N.current=window.setTimeout(()=>{N.current=null,s&&s()},2500)),s()),()=>{window.clearTimeout(N.current)}},[e&&e.length,i]),t.default.createElement(o,{onScroll:e=>{const t=e.target.scrollHeight-e.target.scrollTop-e.target.offsetHeight;s&&!i&&t<200&&s()},ref:b},E.map((e,a)=>t.default.createElement(d,{key:a,style:{width:100/v+"%"}},e.map(e=>t.default.createElement(f,{url:n(e),onSelect:(t,l)=>r(e,t,l),key:n(e),credit:u&&u(e),crossOrigin:m,shadowEnabled:h,itemHeight:w,className:c&&c(e)})),i&&t.default.createElement("div",{style:{padding:"30px"}},t.default.createElement(l.Spinner,null)))),!i&&(!e||!e.length)&&!x&&t.default.createElement(g,null,(0,a.t)("sidePanel.noResults")),x&&t.default.createElement(g,null,(0,a.t)("sidePanel.error")))};exports.ImagesGrid=p;
916
916
  },{"react":"HdMw","../utils/styled":"PsiH","@blueprintjs/core":"Ydrz","../utils/l10n":"FlVj","../canvas/page":"Co9b"}],"ioqf":[function(require,module,exports) {
917
917
  "use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.UploadPanel=exports.setUploadFunc=void 0;const t=e(require("react")),i=require("@blueprintjs/core"),l=require("../utils/image"),a=require("../utils/file"),n=require("./images-grid"),o=require("../utils/l10n");let r=async e=>(0,a.localFileToURL)(e);function s(e){r=e}exports.setUploadFunc=s;let u=[];const d=({store:e})=>{const[a,s]=t.default.useState(u),[d,c]=t.default.useState(!1);return t.default.useEffect(()=>{u=a},[a]),t.default.createElement("div",{style:{height:"100%",display:"flex",flexDirection:"column"}},t.default.createElement("div",{style:{height:"45px",paddingTop:"5px"}},(0,o.t)("sidePanel.uploadTip")),t.default.createElement("div",{style:{marginBottom:"20px"}},t.default.createElement("label",{htmlFor:"input-file"},t.default.createElement(i.Button,{icon:"upload",style:{width:"100%"},onClick:()=>{var e;null===(e=document.querySelector("#input-file"))||void 0===e||e.click()}},(0,o.t)("sidePanel.uploadImage")),t.default.createElement("input",{type:"file",id:"input-file",style:{display:"none"},onChange:async e=>{const{target:t}=e;c(!0);for(const i of t.files){const e=await r(i);s(t=>t.concat([e]))}c(!1),t.value=null},multiple:!0}))),t.default.createElement(n.ImagesGrid,{images:a,isLoading:d,getPreview:e=>e,onSelect:async(t,i,a)=>{var n;let{width:o,height:r}=await(0,l.getImageSize)(t);const s=t.indexOf("svg+xml")>=0||t.indexOf(".svg")>=0?"svg":"image";if(a&&"svg"===a.type&&!a.locked&&"image"===s)return void a.set({maskSrc:t});if(a&&"image"===a.type&&!a.locked&&"image"==s)return void a.set({src:t});const u=Math.min(e.width/o,e.height/r,1);o*=u,r*=u;const d=((null==i?void 0:i.x)||e.width/2)-o/2,c=((null==i?void 0:i.y)||e.height/2)-r/2;null===(n=e.activePage)||void 0===n||n.addElement({type:s,src:t,x:d,y:c,width:o,height:r})}}))};exports.UploadPanel=d;
918
918
  },{"react":"HdMw","@blueprintjs/core":"Ydrz","../utils/image":"GGhN","../utils/file":"oiQN","./images-grid":"Tz78","../utils/l10n":"FlVj"}],"APqM":[function(require,module,exports) {
@@ -1805,20 +1805,20 @@ var r=require("../lib").GenIcon;module.exports=function(t){return r({tag:"svg",a
1805
1805
  },{"react":"HdMw","mobx-react-lite":"ZfSi","@blueprintjs/core":"Ydrz","@blueprintjs/popover2":"mZnF","@meronex/icons/md/MdOpacity":"eGcA","../utils/l10n":"FlVj"}],"ccY3":[function(require,module,exports) {
1806
1806
  "use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.AdminButton=void 0;const t=e(require("react")),n=require("mobx-react-lite"),l=require("@blueprintjs/core"),r=require("@blueprintjs/popover2"),o=require("@blueprintjs/core"),a=require("../utils/l10n");exports.AdminButton=(0,n.observer)(({store:e})=>{const n=e.selectedElements.length>0,i=e.selectedElements[0]||{};return t.default.createElement(r.Popover2,{disabled:!n,minimal:!1,content:t.default.createElement("div",{style:{padding:"15px",paddingTop:"25px",width:"200px"}},t.default.createElement(o.Switch,{checked:i.selectable,label:(0,a.t)("toolbar.selectable"),onChange:e=>{i.set({selectable:e.target.checked})},alignIndicator:o.Alignment.RIGHT}),t.default.createElement(o.Switch,{checked:i.alwaysOnTop,label:(0,a.t)("toolbar.alwaysOnTop"),onChange:e=>{i.set({alwaysOnTop:e.target.checked})},alignIndicator:o.Alignment.RIGHT,style:{marginTop:"20px"}}),t.default.createElement(o.Switch,{checked:i.showInExport,label:(0,a.t)("toolbar.showInExport"),onChange:e=>{i.set({showInExport:e.target.checked})},alignIndicator:o.Alignment.RIGHT,style:{marginTop:"20px"}})),position:l.Position.BOTTOM},t.default.createElement(l.Button,{icon:"cog",minimal:!0,disabled:!n}))});
1807
1807
  },{"react":"HdMw","mobx-react-lite":"ZfSi","@blueprintjs/core":"Ydrz","@blueprintjs/popover2":"mZnF","../utils/l10n":"FlVj"}],"CetC":[function(require,module,exports) {
1808
- "use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Toolbar=exports.registerToolbarComponent=void 0;const t=e(require("react")),r=require("mobx-react-lite"),o=require("@blueprintjs/core"),a=e(require("../utils/styled")),i=require("./history-buttons"),l=require("./text-toolbar"),n=require("./html-toolbar"),d=require("./image-toolbar"),u=require("./svg-toolbar"),s=require("./download-button"),c=require("./duplicate-button"),m=require("./remove-button"),f=require("./lock-button"),p=require("./position-picker"),h=require("./opacity-picker"),b=require("./admin-button"),g=require("../utils/flags"),E={text:l.TextToolbar,image:d.ImageToolbar,svg:u.SvgToolbar};function x(e,t){E[e]=t}exports.registerToolbarComponent=x;const v=(0,a.default)("div")`
1808
+ "use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Toolbar=exports.registerToolbarComponent=void 0;const t=e(require("react")),r=require("mobx-react-lite"),o=require("@blueprintjs/core"),l=e(require("../utils/styled")),a=require("./history-buttons"),i=require("./text-toolbar"),n=require("./html-toolbar"),d=require("./image-toolbar"),u=require("./svg-toolbar"),s=require("./download-button"),c=require("./duplicate-button"),m=require("./remove-button"),p=require("./lock-button"),f=require("./position-picker"),h=require("./opacity-picker"),b=require("./admin-button"),g=require("../utils/flags"),E={text:i.TextToolbar,image:d.ImageToolbar,svg:u.SvgToolbar};function x(e,t){E[e]=t}exports.registerToolbarComponent=x;const v=(0,l.default)("div")`
1809
1809
  @media screen and (max-width: 500px) {
1810
1810
  overflow-x: auto;
1811
1811
  overflow-y: hidden;
1812
1812
  max-width: 100vw;
1813
1813
  }
1814
- `,q=(0,a.default)("div")`
1814
+ `,q=(0,l.default)("div")`
1815
1815
  @media screen and (max-width: 500px) {
1816
1816
  display: flex;
1817
1817
  }
1818
- `;exports.Toolbar=(0,r.observer)(({store:e,downloadButtonEnabled:r,hideTextSpacing:a,hideTextEffects:l,hideImageFlip:d,hideImageEffects:u,hideImageCrop:x,hideImageFit:y,hideSvgEffects:T,hidePosition:w,hideOpacity:I,hideDuplicate:k,hideLock:B,hideRemove:_})=>{const S=1===new Set(e.selectedElements.map(e=>e.type)).size,D=1===e.selectedElements.length,F=e.selectedElements[0];let P=D&&E[F.type];S&&"text"===(null==F?void 0:F.type)&&(P=E[F.type]),D&&"text"===F.type&&g.flags.htmlRenderEnabled&&(P=n.HtmlToolbar);const C=D&&F._cropModeEnabled;return t.default.createElement(v,{className:"bp3-navbar"},t.default.createElement(q,null,!C&&t.default.createElement(i.HistoryButtons,{store:e}),P&&t.default.createElement(P,{store:e,hideTextSpacing:a,hideTextEffects:l,hideImageFlip:d,hideImageEffects:u,hideImageCrop:x,hideImageFit:y,hideSvgEffects:T}),!C&&t.default.createElement(o.Navbar.Group,{align:o.Alignment.RIGHT},"admin"===e.role&&t.default.createElement(b.AdminButton,{store:e}),!w&&t.default.createElement(p.PositionPicker,{store:e}),!I&&t.default.createElement(h.OpacityPicker,{store:e}),!B&&t.default.createElement(f.LockButton,{store:e}),!k&&t.default.createElement(c.DuplicateButton,{store:e}),!_&&t.default.createElement(m.RemoveButton,{store:e}),r&&t.default.createElement(t.default.Fragment,null,t.default.createElement(o.Divider,{style:{height:"100%",margin:"0 15px"}}),t.default.createElement(s.DownloadButton,{store:e})))))}),exports.default=exports.Toolbar;
1818
+ `,y={};exports.Toolbar=(0,r.observer)(({store:e,downloadButtonEnabled:r,hideTextSpacing:l,hideTextEffects:i,hideImageFlip:d,hideImageEffects:u,hideImageCrop:x,hideImageFit:y,hideSvgEffects:T,hidePosition:w,hideOpacity:I,hideDuplicate:k,hideLock:B,hideRemove:_,components:S})=>{const C=1===new Set(e.selectedElements.map(e=>e.type)).size,D=1===e.selectedElements.length,F=e.selectedElements[0];let P=D&&E[F.type];C&&"text"===(null==F?void 0:F.type)&&(P=E[F.type]),D&&"text"===F.type&&g.flags.htmlRenderEnabled&&(P=n.HtmlToolbar);const R=D&&F._cropModeEnabled,A=(null==S?void 0:S.ActionControls)||(r?s.DownloadButton:null);return t.default.createElement(v,{className:"bp3-navbar"},t.default.createElement(q,null,!R&&t.default.createElement(a.HistoryButtons,{store:e}),P&&t.default.createElement(P,{store:e,hideTextSpacing:l,hideTextEffects:i,hideImageFlip:d,hideImageEffects:u,hideImageCrop:x,hideImageFit:y,hideSvgEffects:T}),!R&&t.default.createElement(o.Navbar.Group,{align:o.Alignment.RIGHT},"admin"===e.role&&t.default.createElement(b.AdminButton,{store:e}),!w&&t.default.createElement(f.PositionPicker,{store:e}),!I&&t.default.createElement(h.OpacityPicker,{store:e}),!B&&t.default.createElement(p.LockButton,{store:e}),!k&&t.default.createElement(c.DuplicateButton,{store:e}),!_&&t.default.createElement(m.RemoveButton,{store:e}),A&&t.default.createElement(t.default.Fragment,null,t.default.createElement(o.Divider,{style:{height:"100%",margin:"0 15px"}}),t.default.createElement(A,{store:e})))))}),exports.default=exports.Toolbar;
1819
1819
  },{"react":"HdMw","mobx-react-lite":"ZfSi","@blueprintjs/core":"Ydrz","../utils/styled":"PsiH","./history-buttons":"APqM","./text-toolbar":"LDge","./html-toolbar":"JODo","./image-toolbar":"LcnJ","./svg-toolbar":"nsjL","./download-button":"hzA0","./duplicate-button":"I7IM","./remove-button":"F6AQ","./lock-button":"xZD7","./position-picker":"Taqf","./opacity-picker":"tmro","./admin-button":"ccY3","../utils/flags":"IDY9"}],"Otsg":[function(require,module,exports) {
1820
1820
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.unstable_setForceTextFit=exports.unstable_useHtmlTextRender=exports.unstable_setRemoveBackgroundEnabled=exports.useDownScaling=exports.setAPI=exports.getGoogleFontImage=exports.getGoogleFontsListAPI=exports.unstable_registerNextDomDrop=exports.getTranslations=exports.setTranslations=exports.unstable_registerToolbarComponent=exports.unstable_registerTransformerAttrs=exports.unstable_registerShapeComponent=exports.unstable_registerShapeModel=exports.unstable_setImageLoaderHook=exports.toggleFadeInAnimation=exports.setUploadFunc=exports.addGlobalFont=exports.setGoogleFonts=void 0;var e=require("./utils/fonts");Object.defineProperty(exports,"setGoogleFonts",{enumerable:!0,get:function(){return e.setGoogleFonts}}),Object.defineProperty(exports,"addGlobalFont",{enumerable:!0,get:function(){return e.addGlobalFont}});var t=require("./side-panel/upload-panel");Object.defineProperty(exports,"setUploadFunc",{enumerable:!0,get:function(){return t.setUploadFunc}});var r=require("./canvas/use-fadein");Object.defineProperty(exports,"toggleFadeInAnimation",{enumerable:!0,get:function(){return r.toggleFadeInAnimation}});var n=require("./canvas/image-element");Object.defineProperty(exports,"unstable_setImageLoaderHook",{enumerable:!0,get:function(){return n.setImageLoaderHook}});var o=require("./model/store");Object.defineProperty(exports,"unstable_registerShapeModel",{enumerable:!0,get:function(){return o.registerShapeModel}});var s=require("./canvas/element");Object.defineProperty(exports,"unstable_registerShapeComponent",{enumerable:!0,get:function(){return s.registerShapeComponent}});var a=require("./canvas/page");Object.defineProperty(exports,"unstable_registerTransformerAttrs",{enumerable:!0,get:function(){return a.registerTransformerAttrs}});var u=require("./toolbar/toolbar");Object.defineProperty(exports,"unstable_registerToolbarComponent",{enumerable:!0,get:function(){return u.registerToolbarComponent}});var i=require("./utils/l10n");Object.defineProperty(exports,"setTranslations",{enumerable:!0,get:function(){return i.setTranslations}}),Object.defineProperty(exports,"getTranslations",{enumerable:!0,get:function(){return i.getTranslations}});var l=require("./canvas/page");Object.defineProperty(exports,"unstable_registerNextDomDrop",{enumerable:!0,get:function(){return l.registerNextDomDrop}});var p=require("./utils/api");Object.defineProperty(exports,"getGoogleFontsListAPI",{enumerable:!0,get:function(){return p.getGoogleFontsListAPI}}),Object.defineProperty(exports,"getGoogleFontImage",{enumerable:!0,get:function(){return p.getGoogleFontImage}}),Object.defineProperty(exports,"setAPI",{enumerable:!0,get:function(){return p.setAPI}});var g=require("./utils/flags");Object.defineProperty(exports,"useDownScaling",{enumerable:!0,get:function(){return g.useDownScaling}});var b=require("./utils/flags");Object.defineProperty(exports,"unstable_setRemoveBackgroundEnabled",{enumerable:!0,get:function(){return b.useRemoveBackground}});var c=require("./utils/flags");Object.defineProperty(exports,"unstable_useHtmlTextRender",{enumerable:!0,get:function(){return c.useHtmlTextRender}});var d=require("./utils/flags");Object.defineProperty(exports,"unstable_setForceTextFit",{enumerable:!0,get:function(){return d.setForceTextFit}});
1821
1821
  },{"./utils/fonts":"XXLd","./side-panel/upload-panel":"ioqf","./canvas/use-fadein":"N3c2","./canvas/image-element":"VbEp","./model/store":"GRkH","./canvas/element":"XEPK","./canvas/page":"Co9b","./toolbar/toolbar":"CetC","./utils/l10n":"FlVj","./utils/api":"Ic0q","./utils/flags":"IDY9"}],"IVsl":[function(require,module,exports) {
1822
1822
  "use strict";var e=i(require("react")),o=i(require("react-dom")),t=require("polotno/canvas/workspace"),r=require("polotno/model/store"),a=require("polotno/canvas/use-fadein"),n=require("polotno/config"),l=require("polotno/utils/fonts");function i(e){return e&&e.__esModule?e:{default:e}}(0,a.toggleFadeInAnimation)(!1),(0,n.unstable_setForceTextFit)(!0);var u=new URLSearchParams(location.search).get("key"),c=(0,r.createStore)({key:u});window.store=c,window.config={addGlobalFont:l.addGlobalFont},o.default.render(e.default.createElement(t.Workspace,{store:c}),document.getElementById("root"));
1823
1823
  },{"react":"HdMw","react-dom":"X9zx","polotno/canvas/workspace":"twsc","polotno/model/store":"GRkH","polotno/canvas/use-fadein":"N3c2","polotno/config":"Otsg","polotno/utils/fonts":"XXLd"}]},{},["IVsl"], null)
1824
- //# sourceMappingURL=client.6d8588e5.js.map
1824
+ //# sourceMappingURL=client.41cd7b05.js.map
package/dist/client.html CHANGED
@@ -1 +1 @@
1
- <html><head><title>Canvas editor</title><style>body{padding:0;margin:0}</style><meta name="viewport" content="width=device-width, initial-scale=1"></head><body class="bp3-dark"> <div id="root"></div> <script src="client.6d8588e5.js"></script> </body></html>
1
+ <html><head><title>Canvas editor</title><style>body{padding:0;margin:0}</style><meta name="viewport" content="width=device-width, initial-scale=1"></head><body class="bp3-dark"> <div id="root"></div> <script src="client.41cd7b05.js"></script> </body></html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polotno-node",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "Polotno workflow from NodeJS",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -15,7 +15,7 @@
15
15
  ],
16
16
  "devDependencies": {
17
17
  "parcel-bundler": "^1.12.4",
18
- "polotno": "^0.40.0",
18
+ "polotno": "^0.41.2",
19
19
  "react": "^17.0.2",
20
20
  "react-dom": "^17.0.2"
21
21
  },