@valbuild/ui 0.60.24 → 0.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,7 +40,7 @@ Error generating stack: `+i.message+`
40
40
  */var rD=m,oD=Symbol.for("react.element"),iD=Symbol.for("react.fragment"),sD=Object.prototype.hasOwnProperty,aD=rD.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,lD={key:!0,ref:!0,__self:!0,__source:!0};function RO(e,t,n){var r,o={},i=null,s=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(s=t.ref);for(r in t)sD.call(t,r)&&!lD.hasOwnProperty(r)&&(o[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)o[r]===void 0&&(o[r]=t[r]);return{$$typeof:oD,type:e,key:i,ref:s,props:o,_owner:aD.current}}xm.Fragment=iD;xm.jsx=RO;xm.jsxs=RO;NO.exports=xm;var v=NO.exports;function $y(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Gx(e,t){if(e){if(typeof e=="string")return $y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $y(e,t)}}function bm(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=Gx(e))||t&&e&&typeof e.length=="number"){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(l){throw l},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
41
41
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i=!0,s=!1,a;return{s:function(){n=n.call(e)},n:function(){var l=n.next();return i=l.done,l},e:function(l){s=!0,a=l},f:function(){try{!i&&n.return!=null&&n.return()}finally{if(s)throw a}}}}function Yx(e){return e.length>0}var Qd=Object.freeze({kind:"ok",value:void 0});function nn(e){return e===void 0?Qd:{kind:"ok",value:e}}function _t(e){return{kind:"err",error:e}}function yc(e){return e===Qd||e.kind==="ok"}function wm(e){return e!==Qd&&e.kind==="err"}function $O(e){var t=[],n=[],r=bm(e),o;try{for(r.s();!(o=r.n()).done;){var i=o.value;yc(i)?t.push(i.value):n.push(i.error)}}catch(s){r.e(s)}finally{r.f()}return Yx(n)?_t(n):nn(t)}function cD(e){return $O(e)}function uD(e){var t=[],n=bm(e),r;try{for(n.s();!(r=n.n()).done;){var o=r.value;wm(o)&&t.push(o.error)}}catch(i){n.e(i)}finally{n.f()}return Yx(t)?_t(t):Qd}function Xx(e,t){return function(n){for(var r=nn(t),o=0;o<n.length&&yc(r);++o)r=e(r.value,n[o],o);return r}}function xr(e){return function(t){return yc(t)?nn(e(t.value)):t}}function ga(e){return function(t){return yc(t)?e(t.value):t}}function dD(e){return function(t){return wm(t)?_t(e(t.error)):t}}function fD(e,t){return function(n){return e(n)?nn(n):_t(t(n))}}var km=function(t,n){return function(r){return yc(r)?t(r.value)?r:_t(n(r.value)):r}},He=Object.freeze({__proto__:null,voidOk:Qd,ok:nn,err:_t,isOk:yc,isErr:wm,allT:$O,all:cD,allV:uD,flatMapReduce:Xx,map:xr,flatMap:ga,mapErr:dD,fromPredicate:fD,filterOrElse:km});function pD(e){if(Array.isArray(e))return $y(e)}function hD(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function mD(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
42
42
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function AO(e){return pD(e)||hD(e)||Gx(e)||mD()}function ce(e){"@babel/helpers - typeof";return ce=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ce(e)}function gD(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function IO(e){var t=gD(e,"string");return typeof t=="symbol"?t:String(t)}function se(e,t,n){return t=IO(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rk(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function br(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?rk(Object(n),!0).forEach(function(r){se(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rk(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function vD(e){if(Array.isArray(e))return e}function yD(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,i,s,a=[],l=!0,c=!1;try{if(i=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(u){c=!0,o=u}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw o}}return a}}function xD(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
43
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sn(e,t){return vD(e)||yD(e,t)||Gx(e,t)||xD()}function jt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ok(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,IO(r.key),r)}}function zt(e,t,n){return t&&ok(e.prototype,t),n&&ok(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function rh(e){return rh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},rh(e)}function DO(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(DO=function(){return!!e})()}function LO(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function bD(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return LO(e)}function dr(e,t,n){return t=rh(t),bD(e,DO()?Reflect.construct(t,n||[],rh(e).constructor):t.apply(e,n))}function Ay(e,t){return Ay=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Ay(e,t)}function fr(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ay(e,t)}var pr=function(){function e(){jt(this,e)}return zt(e,[{key:"nullable",value:function(){return this.optional()}},{key:"appendValidationError",value:function(n,r,o,i){return n?(n[r]?n[r].push({message:o,value:i}):n[r]=[{message:o,value:i}],n):se({},r,[{message:o,value:i}])}}]),e}(),Au=Symbol("GetSchema"),wn=Symbol("Path"),Rt=Symbol("GetSource");function wD(e){return e[Au]}var Zx=zt(function e(t){jt(this,e),this.span=t}),kD=function(e){fr(t,e);function t(n,r){var o;return jt(this,t),o=dr(this,t,[r]),se(LO(o),"type","Sym"),o.value=n,o}return zt(t,[{key:"transpile",value:function(){return this.value}}]),t}(Zx);new kD("()");var Gt="_type",rn="_ref",ik="_tag",SD=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.options=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){return this.opt&&o==null?!1:o==null?se({},r,[{message:"Non-optional file was null or undefined.",value:o}]):typeof o[rn]!="string"?se({},r,[{message:"File did not have a file reference string. Got: ".concat(ce(o[rn])),value:o}]):o[Gt]!=="file"?se({},r,[{message:"File did not have the valid file extension type. Got: ".concat(o[Gt]),value:o}]):o.metadata?se({},r,[{message:"Found metadata, but it could not be validated. File metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",value:o,fixes:["file:check-metadata"]}]):se({},r,[{message:"Missing File metadata.",value:o,fixes:["file:add-metadata"]}])}},{key:"assert",value:function(r){return this.opt&&r==null?!0:(r==null?void 0:r[rn])==="file"&&(r==null?void 0:r[Gt])==="file"}},{key:"optional",value:function(){return new t(this.options,!0)}},{key:"serialize",value:function(){return{type:"file",options:this.options,opt:this.opt}}}]),t}(pr),ED=function(t){return new SD(t)};function jO(e){var t,n;if(!e[rn].startsWith("/public")){var r,o;return{url:e[rn]+((r=e.metadata)!==null&&r!==void 0&&r.sha256?"?sha256=".concat((o=e.metadata)===null||o===void 0?void 0:o.sha256):""),metadata:e.metadata}}return{url:e[rn].slice(7)+((t=e.metadata)!==null&&t!==void 0&&t.sha256?"?sha256=".concat((n=e.metadata)===null||n===void 0?void 0:n.sha256):""),metadata:e.metadata}}function zO(e){return ce(e)==="object"&&e!==null&&e!==void 0&&("val"in e||"valPath"in e)}function _D(e){return ce(e)==="object"&&e!==null&&e!==void 0&&wn in e&&"val"in e}function FO(e){return e[wn]}function CD(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function sk(e,t,n){return t?Bt(e(Bt(t,n))):Bt(t,n)}function ls(e){return ce(e)==="object"&&e!==null&&(Rt in e||wn in e)}function Bt(e,t,n){if(ce(e)==="object"){if(ls(e))return e;if(zO(e))return Bt(e.val,e.valPath)}if(e&&e[rn]&&e[Gt]==="file"){var r=e[rn];if(typeof r!="string")throw Error("Invalid file ref: "+r);return Bt(jO(e),t,n)}switch(ce(e)){case"function":case"symbol":throw Error("Invalid selector type: ".concat(ce(e),": ").concat(e));case"object":if(e!==null)return new Proxy(e,{has:function(i,s){return s===Rt||s===wn||s==="andThen"||s===Au?!0:s in i},get:function(i,s){if(s===Rt)return e;if(s===wn)return t;if(s===Au)return n;if(s==="andThen")return function(l){return sk(l,e,t)};if(Array.isArray(i)){if(s==="filter")return function(l){var c=i.map(function(u,d){return Bt(u,kr(t,d),n==null?void 0:n.item)}).filter(function(u){return l&&l instanceof pr?l.assert(ak(u)):ak(l(u))});return Bt(c,t,n)};if(s==="map")return function(l){var c=i.map(function(u,d){var f=l(Bt(u,kr(t,d),n==null?void 0:n.item),Bt(d));return ls(f)?f:Bt(f)});return Bt(c,t,n)}}if(Array.isArray(i)&&s==="length")return Bt(i.length);var a=Reflect.get(i,s);return CD(e,s)?Number.isNaN(Number(s))?Bt(a,kr(t,s),n==null?void 0:n.items[s]):Bt(a,kr(t,Number(s)),n==null?void 0:n.item):a}});default:return se(se(se({eq:function(i){var s=i;if(ls(i)&&(s=i[Rt],s instanceof Zx))throw Error("TODO: Cannot evaluate equality with an Expr");return Bt(e===s,void 0)},andThen:function(i){return sk(i,e===void 0?null:e,t)}},Rt,e===void 0?null:e),wn,t),Au,n)}}function kr(e,t){if(ce(t)==="symbol")throw Error("Cannot create val path of array item with symbol prop: ".concat(t.toString()));return e!==void 0?"".concat(e,".").concat(JSON.stringify(t)):void 0}function ak(e){if(ce(e)==="object"&&(Rt in e||wn in e)){var t=e[Rt];return t}return e}var Jx=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.items=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){var i=this,s=!1;return this.opt&&o==null?!1:ce(o)!=="object"?se({},r,[{message:"Expected 'object', got '".concat(ce(o),"'")}]):Array.isArray(o)?se({},r,[{message:"Expected 'object', got 'array'"}]):(Object.entries(this.items).forEach(function(a){var l=Sn(a,2),c=l[0],u=l[1],d=kr(r,c);if(!d)s=i.appendValidationError(s,r,"Internal error: could not create path at ".concat(!r&&typeof r=="string"?"<empty string>":r," at key ").concat(c),o);else{var f=u.validate(d,o[c]);f&&s?s=br(br({},f),s):f&&(s=f)}}),s)}},{key:"assert",value:function(r){if(this.opt&&r==null)return!0;if(!r)return!1;for(var o=0,i=Object.entries(this.items);o<i.length;o++){var s=Sn(i[o],2),a=s[0],l=s[1];if(!l.assert(r[a]))return!1}return ce(r)==="object"&&!Array.isArray(r)}},{key:"optional",value:function(){return new t(this.items,!0)}},{key:"serialize",value:function(){return{type:"object",items:Object.fromEntries(Object.entries(this.items).map(function(r){var o=Sn(r,2),i=o[0],s=o[1];return[i,s.serialize()]})),opt:this.opt}}}]),t}(pr),OD=function(t){return new Jx(t)},BO=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.item=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){var i=this,s=!1;return this.opt&&o==null?!1:ce(o)!=="object"||!Array.isArray(o)?se({},r,[{message:"Expected 'array', got '".concat(ce(o),"'")}]):(o.forEach(function(a,l){var c=kr(r,l);if(!c)s=i.appendValidationError(s,r,"Internal error: could not create path at ".concat(!r&&typeof r=="string"?"<empty string>":r," at index ").concat(l),o);else{var u=i.item.validate(c,a);u&&s?s=br(br({},u),s):u&&(s=u)}}),s)}},{key:"assert",value:function(r){if(this.opt&&r==null)return!0;if(!r)return!1;var o=bm(r),i;try{for(o.s();!(i=o.n()).done;){var s=i.value;if(!this.item.assert(s))return!1}}catch(a){o.e(a)}finally{o.f()}return ce(r)==="object"&&Array.isArray(r)}},{key:"optional",value:function(){return new t(this.item,!0)}},{key:"serialize",value:function(){return{type:"array",item:this.item.serialize(),opt:this.opt}}}]),t}(pr),TD=function(t){return new BO(t)},Iy=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.value=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){return this.opt&&o==null?!1:typeof o!="string"?se({},r,[{message:"Expected 'string', got '".concat(ce(o),"'"),value:o}]):o!==this.value?se({},r,[{message:"Expected literal '".concat(this.value,"', got '").concat(o,"'"),value:o}]):!1}},{key:"assert",value:function(r){return this.opt&&r==null?!0:typeof r=="string"}},{key:"optional",value:function(){return new t(this.value,!0)}},{key:"serialize",value:function(){return{type:"literal",value:this.value,opt:this.opt}}}]),t}(pr),PD=function(t){return new Iy(t)},VO=function(e){fr(t,e);function t(n,r){var o,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return jt(this,t),o=dr(this,t),o.key=n,o.items=r,o.opt=i,o}return zt(t,[{key:"validate",value:function(r,o){var i=o,s=!1;if(this.opt&&i==null)return!1;if(!this.key)return se({},r,[{message:"Missing required first argument in union"}]);var a=this.key;if(!Array.isArray(this.items))return se({},r,[{message:"A union schema must take more than 1 schema arguments",fatal:!0}]);if(typeof a=="string"){if(this.items.some(function(P){return!(P instanceof Jx)}))return se({},r,[{message:"Key is a string, so all schema items must be objects",fatal:!0}]);var l=this.items,c=l.map(function(P){return P.serialize()}),u=c.filter(function(P){return P.type!=="object"||P.items[a].type!=="literal"});if(u.length>0)return se({},r,[{message:"All schema items must be objects with a key: ".concat(a," that is a literal schema. Found: ").concat(JSON.stringify(u,null,2)),fatal:!0}]);var d=c,f=d.filter(function(P){return P.items[a].opt});if(f.length>1)return se({},r,[{message:"Schema cannot have an optional keys: ".concat(a),fatal:!0}]);if(ce(i)!=="object")return se({},r,[{message:"Expected an object"}]);var p=i;if(p[a]===void 0)return se({},r,[{message:"Missing required key: ".concat(a)}]);var h=[],g=bm(d),b;try{for(g.s();!(b=g.n()).done;){var y=b.value,x=y.items[a];if(x.type==="literal")if(!h.includes(x.value))h.push(x.value);else return se({},r,[{message:"Found duplicate key in schema: ".concat(x.value),fatal:!0}])}}catch(P){g.e(P)}finally{g.f()}var w=l.find(function(P){return!P.items[a].validate(r,p[a])});if(!w){var k=kr(r,a);if(!k)throw new Error("Internal error: could not create path at ".concat(!r&&typeof r=="string"?"<empty string>":r," at key ").concat(a));return se({},k,[{message:'Invalid key: "'.concat(a,'". Value was: "').concat(p[a],'". Valid values: ').concat(d.map(function(P){var N=P.items[a];if(N.type==="literal"&&N.value)return'"'.concat(N.value,'"');throw new Error("Expected literal schema, got ".concat(JSON.stringify(N,null,2)))}).join(", "))}])}var S=w.validate(r,p);if(S)return S}else if(a instanceof Iy){if(this.items.some(function(P){return!(P instanceof Iy)}))return se({},r,[{message:"Key is a literal schema, so all schema items must be literals",fatal:!0}]);var O=[a].concat(AO(this.items));if(typeof i=="string"){var E=O.some(function(P){return!P.validate(r,i)});if(!E)return se({},r,[{message:"Union must match one of the following: ".concat(O.map(function(P){return'"'.concat(P.value,'"')}).join(", "))}])}}else return se({},r,[{message:"Expected a string or literal"}]);return s}},{key:"assert",value:function(r){return!0}},{key:"optional",value:function(){return new t(this.key,this.items,!0)}},{key:"serialize",value:function(){return typeof this.key=="string"?{type:"union",key:this.key,items:this.items.map(function(r){return r.serialize()}),opt:this.opt}:{type:"union",key:this.key.serialize(),items:this.items.map(function(r){return r.serialize()}),opt:this.opt}}}]),t}(pr),MD=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new VO(t,r)},UO=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.options=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){return!1}},{key:"assert",value:function(r){return!0}},{key:"optional",value:function(){return new t(this.options,!0)}},{key:"serialize",value:function(){return{type:"richtext",opt:this.opt,options:this.options}}}]),t}(pr),ND=function(t){return new UO(t??{})},HO=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.options=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){return this.opt&&o==null?!1:o==null?se({},r,[{message:"Non-optional image was null or undefined.",value:o}]):typeof o[rn]!="string"?se({},r,[{message:"Image did not have a file reference string. Got: ".concat(ce(o[rn])),value:o}]):o[Gt]!=="file"?se({},r,[{message:"Image did not have the valid file extension type. Got: ".concat(o[Gt]),value:o}]):o.metadata?se({},r,[{message:"Found metadata, but it could not be validated. Image metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",value:o,fixes:["image:replace-metadata"]}]):se({},r,[{message:"Could not validate Image metadata.",value:o,fixes:["image:add-metadata"]}])}},{key:"assert",value:function(r){return this.opt&&r==null?!0:(r==null?void 0:r[rn])==="image"&&(r==null?void 0:r[Gt])==="file"}},{key:"optional",value:function(){return new t(this.options,!0)}},{key:"serialize",value:function(){return{type:"image",options:this.options,opt:this.opt}}}]),t}(pr),RD=function(t){return new HO(t)},WO=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.item=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){var i=this,s=!1;return this.opt&&o==null?!1:ce(o)!=="object"?se({},r,[{message:"Expected 'object', got '".concat(ce(o),"'")}]):Array.isArray(o)?se({},r,[{message:"Expected 'object', got 'array'"}]):(Object.entries(o).forEach(function(a){var l=Sn(a,2),c=l[0],u=l[1],d=kr(r,c);if(!d)s=i.appendValidationError(s,r,"Internal error: could not create path at ".concat(!r&&typeof r=="string"?"<empty string>":r," at key ").concat(u),o);else{var f=i.item.validate(d,u);f&&s?s=br(br({},f),s):f&&(s=f)}}),s)}},{key:"assert",value:function(r){if(this.opt&&r==null)return!0;if(!r)return!1;for(var o=0,i=Object.entries(r);o<i.length;o++){var s=Sn(i[o],2),a=s[1];if(!this.item.assert(a))return!1}return ce(r)==="object"&&!Array.isArray(r)}},{key:"optional",value:function(){return new t(this.item,!0)}},{key:"serialize",value:function(){return{type:"record",item:this.item.serialize(),opt:this.opt}}}]),t}(pr),$D=function(t){return new WO(t)};function AD(e){var t=e[Rt];if(t instanceof Zx)throw Error("Cannot get raw source of an Expr");var n=t;return n}function ID(e){return e.indexOf(".")===-1?[e,""]:[e.slice(0,e.indexOf(".")),e.slice(e.indexOf(".")+1)]}function DD(e){return e instanceof Jx||ce(e)==="object"&&"type"in e&&e.type==="object"}function LD(e){return e instanceof WO||ce(e)==="object"&&"type"in e&&e.type==="record"}function jD(e){return e instanceof BO||ce(e)==="object"&&"type"in e&&e.type==="array"}function zD(e){return e instanceof VO||ce(e)==="object"&&"type"in e&&e.type==="union"}function FD(e){return e instanceof UO||ce(e)==="object"&&"type"in e&&e.type==="richtext"}function BD(e){return e instanceof HO||ce(e)==="object"&&"type"in e&&e.type==="image"}function VD(e,t,n){for(var r=KO(e),o=AO(r),i=n,s=t,a=function(){var u=r.shift();if(u===void 0)throw Error("Unexpected undefined part");if(jD(i)){if(Number.isNaN(Number(u)))throw Error("Invalid path: array schema ".concat(JSON.stringify(i)," must have a number as path, but got ").concat(u,". Path: ").concat(e));if(ce(s)!=="object"&&!Array.isArray(s))throw Error("Schema type error: expected source to be type of array, but got ".concat(ce(s)));if(s[u]===void 0){var d;throw Error("Invalid path: array source (length: ".concat((d=s)===null||d===void 0?void 0:d.length,") did not have index ").concat(u," from path: ").concat(e))}s=s[u],i=i.item}else if(LD(i)){if(typeof u!="string")throw Error("Invalid path: record schema ".concat(i," must have path: ").concat(u," as string"));if(ce(s)!=="object"&&!Array.isArray(s))throw Error("Schema type error: expected source to be type of record, but got ".concat(ce(s)));if(!s[u])throw Error("Invalid path: record source did not have key ".concat(u," from path: ").concat(e));s=s[u],i=i.item}else if(DD(i)){if(ce(s)!=="object")throw Error("Schema type error: expected source to be type of object, but got ".concat(ce(s)));if(!s[u])throw Error("Invalid path: object source did not have key ".concat(u," from path: ").concat(e));s=s[u],i=i.items[u]}else{if(BD(i))return{v:{path:o.slice(0,o.length-r.length-1).map(function(g){return JSON.stringify(g)}).join("."),schema:i,source:s}};if(zD(i)){var f=i.key;if(typeof f!="string")return{v:{path:o.map(function(g){return Number.isNaN(Number(g))?JSON.stringify(g):g}).join("."),schema:i,source:s}};var p=s[f];if(!p)throw Error("Invalid path: union source ".concat(i," did not have required key ").concat(f," in path: ").concat(e));var h=i.items.find(function(g){var b;return(g==null||(b=g.items)===null||b===void 0||(b=b[f])===null||b===void 0?void 0:b.value)===p});if(!h)throw Error("Invalid path: union schema ".concat(i," did not have a child object with ").concat(f," of value ").concat(p," in path: ").concat(e));i=h.items[u],s=s[u]}else{if(FD(i))return{v:{path:o.slice(0,o.length-r.length-1).map(function(g){return JSON.stringify(g)}).join("."),schema:i,source:s}};throw Error("Invalid path: ".concat(u," resolved to an unexpected schema ").concat(JSON.stringify(i)))}}},l;r.length>0;)if(l=a(),l)return l.v;if(r.length>0)throw Error("Invalid path: ".concat(r.join(".")," is not a valid path"));return{path:o.map(function(c){return Number.isNaN(Number(c))?JSON.stringify(c):c}).join("."),schema:i,source:s}}function KO(e){for(var t=[],n=0;n<e.length;){var r="";if(e[n]==='"'){for(n++;n<e.length&&e[n]!=='"';)e[n]==="\\"&&e[n+1]==='"'?(r+='"',n++):r+=e[n],n++;if(e[n]!=='"'){var o;throw new Error("Invalid input (".concat(JSON.stringify(e),"): Missing closing double quote: ").concat((o=e[n])!==null&&o!==void 0?o:"at end of string"," (char: ").concat(n,"; length: ").concat(e.length,")"))}}else for(;n<e.length&&e[n]!==".";)r+=e[n],n++;r!==""&&t.push(r),n++}return t}var sr=zt(function e(t){jt(this,e),this.message=t}),UD=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.options=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){return this.opt&&o==null?!1:typeof o!="number"?se({},r,[{message:"Expected 'number', got '".concat(ce(o),"'"),value:o}]):!1}},{key:"assert",value:function(r){return this.opt&&r==null?!0:typeof r=="number"}},{key:"optional",value:function(){return new t(this.options,!0)}},{key:"serialize",value:function(){return{type:"number",options:this.options,opt:this.opt}}}]),t}(pr),HD=function(t){return new UD(t)},qO=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return jt(this,t),r=dr(this,t),r.options=n,r.opt=o,r.isRaw=i,r}return zt(t,[{key:"min",value:function(r){return new t(br(br({},this.options),{},{minLength:r}),this.opt,this.isRaw)}},{key:"max",value:function(r){return new t(br(br({},this.options),{},{maxLength:r}),this.opt,this.isRaw)}},{key:"regexp",value:function(r){return new t(br(br({},this.options),{},{regexp:r}),this.opt,this.isRaw)}},{key:"validate",value:function(r,o){var i,s,a;if(this.opt&&o==null)return!1;if(typeof o!="string")return se({},r,[{message:"Expected 'string', got '".concat(ce(o),"'"),value:o}]);var l=[];return(i=this.options)!==null&&i!==void 0&&i.maxLength&&o.length>this.options.maxLength&&l.push({message:"Expected string to be at most ".concat(this.options.maxLength," characters long, got ").concat(o.length),value:o}),(s=this.options)!==null&&s!==void 0&&s.minLength&&o.length<this.options.minLength&&l.push({message:"Expected string to be at least ".concat(this.options.minLength," characters long, got ").concat(o.length),value:o}),(a=this.options)!==null&&a!==void 0&&a.regexp&&!this.options.regexp.test(o)&&l.push({message:"Expected string to match reg exp: ".concat(this.options.regexp.toString(),", got '").concat(o,"'"),value:o}),l.length>0?se({},r,l):!1}},{key:"assert",value:function(r){return this.opt&&r==null?!0:typeof r=="string"}},{key:"optional",value:function(){return new t(this.options,!0,this.isRaw)}},{key:"raw",value:function(){return new t(this.options,this.opt,!0)}},{key:"serialize",value:function(){var r,o,i;return{type:"string",options:{maxLength:(r=this.options)===null||r===void 0?void 0:r.maxLength,minLength:(o=this.options)===null||o===void 0?void 0:o.minLength,regexp:((i=this.options)===null||i===void 0?void 0:i.regexp)&&{source:this.options.regexp.source,flags:this.options.regexp.flags}},opt:this.opt,raw:this.isRaw}}}]),t}(pr),WD=function(t){return new qO(t)},KD=function(e){fr(t,e);function t(){var n,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return jt(this,t),n=dr(this,t),n.opt=r,n}return zt(t,[{key:"validate",value:function(r,o){return this.opt&&o==null?!1:typeof o!="boolean"?se({},r,[{message:"Expected 'boolean', got '".concat(ce(o),"'"),value:o}]):!1}},{key:"assert",value:function(r){return this.opt&&r==null?!0:typeof r=="boolean"}},{key:"optional",value:function(){return new t(!0)}},{key:"serialize",value:function(){return{type:"boolean",opt:this.opt}}}]),t}(pr),qD=function(){return new KD},GD=function(e){fr(t,e);function t(n,r){var o,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return jt(this,t),o=dr(this,t),o.schema=n,o.sourcePath=r,o.opt=i,o}return zt(t,[{key:"validate",value:function(r,o){if(this.opt&&o==null)return!1;if(!this.schema)return se({},r,[{message:"Schema not found for module. keyOf must be used with a Val Module"}]);var i=this.schema;if(!(i.type==="array"||i.type==="object"||i.type==="record"))return se({},r,[{message:"Schema in keyOf must be an 'array', 'object' or 'record'. Found '".concat(i.type,"'")}]);if(i.opt&&o==null)return!1;if(i.type==="array"&&typeof o!="number")return se({},r,[{message:"Type of value in keyof (array) must be 'number'"}]);if(i.type==="record"&&typeof o!="string")return se({},r,[{message:"Type of value in keyof (record) must be 'string'"}]);if(i.type==="object"){var s=Object.keys(i.items);if(!s.includes(o))return se({},r,[{message:"Value of keyOf (object) must be: ".concat(s.join(", "),". Found: ").concat(o)}])}return!1}},{key:"assert",value:function(r){if(this.opt&&r==null)return!0;var o=this.schema;if(!o)return!1;var i=o;if(!(i.type==="array"||i.type==="object"||i.type==="record"))return!1;if(i.opt&&r==null)return!0;if(i.type==="array"&&typeof r!="number"||i.type==="record"&&typeof r!="string")return!1;if(i.type==="object"){var s=Object.keys(i.items);if(!s.includes(r))return!1}return!0}},{key:"optional",value:function(){return new t(this.schema,this.sourcePath,!0)}},{key:"serialize",value:function(){var r=this.sourcePath;if(!r)throw new Error("Cannot serialize keyOf schema with empty selector. TIP: keyOf must be used with a Val Module.");var o=this.schema;if(!o)throw new Error("Cannot serialize keyOf schema with empty selector.");var i;switch(o.type){case"array":i="number";break;case"record":i="string";break;case"object":i=Object.keys(o.items);break;default:throw new Error("Cannot serialize keyOf schema with selector of type '".concat(o.type,"'. keyOf must be used with a Val Module."))}return{type:"keyOf",path:r,schema:o,opt:this.opt,values:i}}}]),t}(pr),YD=function(t){var n;return new GD(t==null||(n=t[Au])===null||n===void 0?void 0:n.serialize(),FO(t))};function XD(){return{string:WD,boolean:qD,array:TD,object:OD,number:HD,union:MD,richtext:ND,image:RD,literal:PD,keyOf:YD,record:$D,file:ED}}var lk="rt_image";function ZD(e){return GO(e3(e))}function JD(e){return ls(e)?ce(e[Rt])==="object"&&e[Rt]!==null&&Array.isArray(e[Rt]):Array.isArray(e)}function QD(e){return ls(e)?ce(e[Rt])==="object"&&e[Rt]!==null&&!Array.isArray(e[Rt]):ce(e)==="object"}function e3(e){var t=Bt(e);function n(r){var o=JD(r),i=QD(r);if(o){var s=Rt in r?r[Rt]:r,a=wn in r?r[wn]:void 0;return{val:s.map(function(u,d){return n(ls(u)?u:Bt(u,kr(a,d)))}),valPath:a}}else if(i){var l=Rt in r?r[Rt]:r,c=wn in r?r[wn]:void 0;return{val:l!==null&&Object.fromEntries(Object.entries(l).map(function(u){var d=Sn(u,2),f=d[0],p=d[1];return[f,n(ls(p)?p:Bt(p,kr(c,f)))]})),valPath:c}}else return ls(r)?{val:n(r[Rt]),valPath:r[wn]}:r}return n(t)}function Dy(e){var t=zO(e)?e.val:e;switch(ce(t)){case"function":case"symbol":throw Error("Invalid val type: ".concat(ce(t)));case"object":return t===null?null:Array.isArray(t)?t.map(Dy):Object.fromEntries(Object.entries(t).map(function(n){var r=Sn(n,2),o=r[0],i=r[1];return[o,i&&Dy(i)]}));default:return t}}function GO(e){var t=e.val;switch(ce(t)){case"function":case"symbol":throw Error("Invalid val type: ".concat(ce(t)));case"object":if(t!==null)return new Proxy(t,{has:function(r,o){return o==="val"||o===wn?!0:ck(r,o)},get:function(r,o){if(o===wn)return e.valPath;if(o==="val")return Dy(e);if(Array.isArray(r)&&o==="length")return r.length;if(ck(t,o)){var i,s;return GO({val:Reflect.get(r,o).val,valPath:(i=(s=Reflect.get(r,o))===null||s===void 0?void 0:s.valPath)!==null&&i!==void 0?i:kr(e.valPath,Array.isArray(r)?Number(o):o)})}return Reflect.get(r,o)}});default:return se(se({},wn,e.valPath),"val",e.val)}}function ck(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var t3=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998],Qe=function(e){return e[e.inputBytes=64]="inputBytes",e[e.inputWords=16]="inputWords",e[e.highIndex=14]="highIndex",e[e.lowIndex=15]="lowIndex",e[e.workWords=64]="workWords",e[e.allocBytes=80]="allocBytes",e[e.allocWords=20]="allocWords",e[e.allocTotal=8e3]="allocTotal",e}(Qe||{}),uk={sha256:1};function n3(e){if(e&&!uk[e]&&!uk[e.toLowerCase()])throw new Error("Digest method not supported");return new r3}var r3=function(){function e(){jt(this,e),se(this,"A",1779033703),se(this,"B",-1150833019),se(this,"C",1013904242),se(this,"D",-1521486534),se(this,"E",1359893119),se(this,"F",-1694144372),se(this,"G",528734635),se(this,"H",1541459225),se(this,"_size",0),se(this,"_sp",0),(!Lf||Fc>=Qe.allocTotal)&&(Lf=new ArrayBuffer(Qe.allocTotal),Fc=0),this._byte=new Uint8Array(Lf,Fc,Qe.allocBytes),this._word=new Int32Array(Lf,Fc,Qe.allocWords),Fc+=Qe.allocBytes}return zt(e,[{key:"update",value:function(n){if(typeof n=="string")return this._utf8(n);if(n==null)throw new TypeError("Invalid type: "+ce(n));var r=n.byteOffset,o=n.byteLength,i=o/Qe.inputBytes|0,s=0;if(i&&!(r&3)&&!(this._size%Qe.inputBytes)){for(var a=new Int32Array(n.buffer,r,i*Qe.inputWords);i--;)this._int32(a,s>>2),s+=Qe.inputBytes;this._size+=s}var l=n.BYTES_PER_ELEMENT;if(l!==1&&n.buffer){var c=new Uint8Array(n.buffer,r+s,o-s);return this._uint8(c)}return s===o?this:this._uint8(n,s)}},{key:"_uint8",value:function(n,r){var o=this._byte,i=this._word,s=n.length;for(r=r|0;r<s;){for(var a=this._size%Qe.inputBytes,l=a;r<s&&l<Qe.inputBytes;)o[l++]=n[r++];l>=Qe.inputBytes&&this._int32(i),this._size+=l-a}return this}},{key:"_utf8",value:function(n){for(var r=this._byte,o=this._word,i=n.length,s=this._sp,a=0;a<i;){for(var l=this._size%Qe.inputBytes,c=l;a<i&&c<Qe.inputBytes;){var u=n.charCodeAt(a++)|0;u<128?r[c++]=u:u<2048?(r[c++]=192|u>>>6,r[c++]=128|u&63):u<55296||u>57343?(r[c++]=224|u>>>12,r[c++]=128|u>>>6&63,r[c++]=128|u&63):s?(u=((s&1023)<<10)+(u&1023)+65536,r[c++]=240|u>>>18,r[c++]=128|u>>>12&63,r[c++]=128|u>>>6&63,r[c++]=128|u&63,s=0):s=u}c>=Qe.inputBytes&&(this._int32(o),o[0]=o[Qe.inputWords]),this._size+=c-l}return this._sp=s,this}},{key:"_int32",value:function(n,r){var o=this.A,i=this.B,s=this.C,a=this.D,l=this.E,c=this.F,u=this.G,d=this.H,f=0;for(r=r|0;f<Qe.inputWords;)Is[f++]=zr(n[r++]);for(f=Qe.inputWords;f<Qe.workWords;f++)Is[f]=d3(Is[f-2])+Is[f-7]+u3(Is[f-15])+Is[f-16]|0;for(f=0;f<Qe.workWords;f++){var p=d+c3(l)+s3(l,c,u)+t3[f]+Is[f]|0,h=l3(o)+a3(o,i,s)|0;d=u,u=c,c=l,l=a+p|0,a=s,s=i,i=o,o=p+h|0}this.A=o+this.A|0,this.B=i+this.B|0,this.C=s+this.C|0,this.D=a+this.D|0,this.E=l+this.E|0,this.F=c+this.F|0,this.G=u+this.G|0,this.H=d+this.H|0}},{key:"digest",value:function(n){var r=this._byte,o=this._word,i=this._size%Qe.inputBytes|0;for(r[i++]=128;i&3;)r[i++]=0;if(i>>=2,i>Qe.highIndex){for(;i<Qe.inputWords;)o[i++]=0;i=0,this._int32(o)}for(;i<Qe.inputWords;)o[i++]=0;var s=this._size*8,a=(s&4294967295)>>>0,l=(s-a)/4294967296;return l&&(o[Qe.highIndex]=zr(l)),a&&(o[Qe.lowIndex]=zr(a)),this._int32(o),n==="hex"?this._hex():this._bin()}},{key:"_hex",value:function(){var n=this.A,r=this.B,o=this.C,i=this.D,s=this.E,a=this.F,l=this.G,c=this.H;return ki(n)+ki(r)+ki(o)+ki(i)+ki(s)+ki(a)+ki(l)+ki(c)}},{key:"_bin",value:function(){var n=this.A,r=this.B,o=this.C,i=this.D,s=this.E,a=this.F,l=this.G,c=this.H,u=this._byte,d=this._word;return d[0]=zr(n),d[1]=zr(r),d[2]=zr(o),d[3]=zr(i),d[4]=zr(s),d[5]=zr(a),d[6]=zr(l),d[7]=zr(c),u.slice(0,32)}}]),e}(),Is=new Int32Array(Qe.workWords),Lf,Fc=0,ki=function(t){return(t+4294967296).toString(16).substr(-8)},o3=function(t){return t<<24&4278190080|t<<8&16711680|t>>8&65280|t>>24&255},i3=function(t){return t},zr=f3()?i3:o3,s3=function(t,n,r){return r^t&(n^r)},a3=function(t,n,r){return t&n|r&(t|n)},l3=function(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)},c3=function(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)},u3=function(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3},d3=function(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10};function f3(){var e=new Uint8Array(new Uint16Array([65279]).buffer);return e[0]===254}var p3=function(t){return n3().update(t).digest("hex")};function Yn(){Yn=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(_,T,C){_[T]=C.value},i=typeof Symbol=="function"?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function c(_,T,C){return Object.defineProperty(_,T,{value:C,enumerable:!0,configurable:!0,writable:!0}),_[T]}try{c({},"")}catch{c=function(T,C,M){return T[C]=M}}function u(_,T,C,M){var R=T&&T.prototype instanceof y?T:y,L=Object.create(R.prototype),G=new U(M||[]);return o(L,"_invoke",{value:$(_,C,G)}),L}function d(_,T,C){try{return{type:"normal",arg:_.call(T,C)}}catch(M){return{type:"throw",arg:M}}}t.wrap=u;var f="suspendedStart",p="suspendedYield",h="executing",g="completed",b={};function y(){}function x(){}function w(){}var k={};c(k,s,function(){return this});var S=Object.getPrototypeOf,O=S&&S(S(K([])));O&&O!==n&&r.call(O,s)&&(k=O);var E=w.prototype=y.prototype=Object.create(k);function P(_){["next","throw","return"].forEach(function(T){c(_,T,function(C){return this._invoke(T,C)})})}function N(_,T){function C(R,L,G,ve){var me=d(_[R],_,L);if(me.type!=="throw"){var Be=me.arg,Te=Be.value;return Te&&typeof Te=="object"&&r.call(Te,"__await")?T.resolve(Te.__await).then(function(J){C("next",J,G,ve)},function(J){C("throw",J,G,ve)}):T.resolve(Te).then(function(J){Be.value=J,G(Be)},function(J){return C("throw",J,G,ve)})}ve(me.arg)}var M;o(this,"_invoke",{value:function(R,L){function G(){return new T(function(ve,me){C(R,L,ve,me)})}return M=M?M.then(G,G):G()}})}function $(_,T,C){var M=f;return function(R,L){if(M===h)throw new Error("Generator is already running");if(M===g){if(R==="throw")throw L;return{value:e,done:!0}}for(C.method=R,C.arg=L;;){var G=C.delegate;if(G){var ve=z(G,C);if(ve){if(ve===b)continue;return ve}}if(C.method==="next")C.sent=C._sent=C.arg;else if(C.method==="throw"){if(M===f)throw M=g,C.arg;C.dispatchException(C.arg)}else C.method==="return"&&C.abrupt("return",C.arg);M=h;var me=d(_,T,C);if(me.type==="normal"){if(M=C.done?g:p,me.arg===b)continue;return{value:me.arg,done:C.done}}me.type==="throw"&&(M=g,C.method="throw",C.arg=me.arg)}}}function z(_,T){var C=T.method,M=_.iterator[C];if(M===e)return T.delegate=null,C==="throw"&&_.iterator.return&&(T.method="return",T.arg=e,z(_,T),T.method==="throw")||C!=="return"&&(T.method="throw",T.arg=new TypeError("The iterator does not provide a '"+C+"' method")),b;var R=d(M,_.iterator,T.arg);if(R.type==="throw")return T.method="throw",T.arg=R.arg,T.delegate=null,b;var L=R.arg;return L?L.done?(T[_.resultName]=L.value,T.next=_.nextLoc,T.method!=="return"&&(T.method="next",T.arg=e),T.delegate=null,b):L:(T.method="throw",T.arg=new TypeError("iterator result is not an object"),T.delegate=null,b)}function j(_){var T={tryLoc:_[0]};1 in _&&(T.catchLoc=_[1]),2 in _&&(T.finallyLoc=_[2],T.afterLoc=_[3]),this.tryEntries.push(T)}function le(_){var T=_.completion||{};T.type="normal",delete T.arg,_.completion=T}function U(_){this.tryEntries=[{tryLoc:"root"}],_.forEach(j,this),this.reset(!0)}function K(_){if(_||_===""){var T=_[s];if(T)return T.call(_);if(typeof _.next=="function")return _;if(!isNaN(_.length)){var C=-1,M=function R(){for(;++C<_.length;)if(r.call(_,C))return R.value=_[C],R.done=!1,R;return R.value=e,R.done=!0,R};return M.next=M}}throw new TypeError(typeof _+" is not iterable")}return x.prototype=w,o(E,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:x,configurable:!0}),x.displayName=c(w,l,"GeneratorFunction"),t.isGeneratorFunction=function(_){var T=typeof _=="function"&&_.constructor;return!!T&&(T===x||(T.displayName||T.name)==="GeneratorFunction")},t.mark=function(_){return Object.setPrototypeOf?Object.setPrototypeOf(_,w):(_.__proto__=w,c(_,l,"GeneratorFunction")),_.prototype=Object.create(E),_},t.awrap=function(_){return{__await:_}},P(N.prototype),c(N.prototype,a,function(){return this}),t.AsyncIterator=N,t.async=function(_,T,C,M,R){R===void 0&&(R=Promise);var L=new N(u(_,T,C,M),R);return t.isGeneratorFunction(T)?L:L.next().then(function(G){return G.done?G.value:L.next()})},P(E),c(E,l,"Generator"),c(E,s,function(){return this}),c(E,"toString",function(){return"[object Generator]"}),t.keys=function(_){var T=Object(_),C=[];for(var M in T)C.push(M);return C.reverse(),function R(){for(;C.length;){var L=C.pop();if(L in T)return R.value=L,R.done=!1,R}return R.done=!0,R}},t.values=K,U.prototype={constructor:U,reset:function(_){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(le),!_)for(var T in this)T.charAt(0)==="t"&&r.call(this,T)&&!isNaN(+T.slice(1))&&(this[T]=e)},stop:function(){this.done=!0;var _=this.tryEntries[0].completion;if(_.type==="throw")throw _.arg;return this.rval},dispatchException:function(_){if(this.done)throw _;var T=this;function C(me,Be){return L.type="throw",L.arg=_,T.next=me,Be&&(T.method="next",T.arg=e),!!Be}for(var M=this.tryEntries.length-1;M>=0;--M){var R=this.tryEntries[M],L=R.completion;if(R.tryLoc==="root")return C("end");if(R.tryLoc<=this.prev){var G=r.call(R,"catchLoc"),ve=r.call(R,"finallyLoc");if(G&&ve){if(this.prev<R.catchLoc)return C(R.catchLoc,!0);if(this.prev<R.finallyLoc)return C(R.finallyLoc)}else if(G){if(this.prev<R.catchLoc)return C(R.catchLoc,!0)}else{if(!ve)throw new Error("try statement without catch or finally");if(this.prev<R.finallyLoc)return C(R.finallyLoc)}}}},abrupt:function(_,T){for(var C=this.tryEntries.length-1;C>=0;--C){var M=this.tryEntries[C];if(M.tryLoc<=this.prev&&r.call(M,"finallyLoc")&&this.prev<M.finallyLoc){var R=M;break}}R&&(_==="break"||_==="continue")&&R.tryLoc<=T&&T<=R.finallyLoc&&(R=null);var L=R?R.completion:{};return L.type=_,L.arg=T,R?(this.method="next",this.next=R.finallyLoc,b):this.complete(L)},complete:function(_,T){if(_.type==="throw")throw _.arg;return _.type==="break"||_.type==="continue"?this.next=_.arg:_.type==="return"?(this.rval=this.arg=_.arg,this.method="return",this.next="end"):_.type==="normal"&&T&&(this.next=T),b},finish:function(_){for(var T=this.tryEntries.length-1;T>=0;--T){var C=this.tryEntries[T];if(C.finallyLoc===_)return this.complete(C.completion,C.afterLoc),le(C),b}},catch:function(_){for(var T=this.tryEntries.length-1;T>=0;--T){var C=this.tryEntries[T];if(C.tryLoc===_){var M=C.completion;if(M.type==="throw"){var R=M.arg;le(C)}return R}}throw new Error("illegal catch attempt")},delegateYield:function(_,T,C){return this.delegate={iterator:K(_),resultName:T,nextLoc:C},this.method==="next"&&(this.arg=e),b}},t}function dk(e,t,n,r,o,i,s){try{var a=e[i](s),l=a.value}catch(c){n(c);return}a.done?t(l):Promise.resolve(l).then(r,o)}function ol(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function s(l){dk(i,r,o,s,a,"next",l)}function a(l){dk(i,r,o,s,a,"throw",l)}s(void 0)})}}var Qx=function(){function e(t){jt(this,e),this.host=t}return zt(e,[{key:"getDisableUrl",value:function(n){return"".concat(this.host,"/disable?redirect_to=").concat(encodeURIComponent(n))}},{key:"getLoginUrl",value:function(n){return"".concat(this.host,"/authorize?redirect_to=").concat(encodeURIComponent(n))}},{key:"getEnableUrl",value:function(n){return"".concat(this.host,"/enable?redirect_to=").concat(encodeURIComponent(n))}},{key:"getPatches",value:function(){var t=ol(Yn().mark(function r(o){var i,s,a;return Yn().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return i=o.patchIds,s=o.headers,a=i?"?".concat(i.map(function(u){return"".concat(u,"=").concat(encodeURIComponent(u))}).join("&")):"",c.abrupt("return",fetch("".concat(this.host,"/patches/~").concat(a),{headers:s||{"Content-Type":"application/json"}}).then(function(u){return Si(u)}).catch(Ds));case 3:case"end":return c.stop()}},r,this)}));function n(r){return t.apply(this,arguments)}return n}()},{key:"deletePatches",value:function(){var t=ol(Yn().mark(function r(o,i){var s;return Yn().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return s=new URLSearchParams,o.forEach(function(c){return s.append("id",c)}),l.abrupt("return",fetch("".concat(this.host,"/patches/~?").concat(s),{method:"DELETE",headers:i||{"Content-Type":"application/json"}}).then(function(c){return Si(c)}).catch(Ds));case 3:case"end":return l.stop()}},r,this)}));function n(r,o){return t.apply(this,arguments)}return n}()},{key:"getEditUrl",value:function(){return"/val"}},{key:"postPatches",value:function(n,r,o){return fetch("".concat(this.host,"/patches/~"),{headers:o||{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(se({},n,r))}).then(function(){var i=ol(Yn().mark(function s(a){return Yn().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.abrupt("return",Si(a));case 1:case"end":return c.stop()}},s)}));return function(s){return i.apply(this,arguments)}}()).catch(Ds)}},{key:"getSession",value:function(){return fetch("".concat(this.host,"/session")).then(function(n){return Si(n).catch(Ds)})}},{key:"getTree",value:function(n){var r=n.patch,o=r===void 0?!1:r,i=n.includeSchema,s=i===void 0?!1:i,a=n.includeSource,l=a===void 0?!1:a,c=n.treePath,u=c===void 0?"/":c,d=n.headers,f=new URLSearchParams;return f.set("patch",o.toString()),f.set("schema",s.toString()),f.set("source",l.toString()),fetch("".concat(this.host,"/tree/~").concat(u,"?").concat(f.toString()),{headers:d}).then(function(p){return Si(p)}).catch(Ds)}},{key:"postCommit",value:function(n){var r=n.patches,o=n.headers;return fetch("".concat(this.host,"/commit"),{method:"POST",body:JSON.stringify({patches:r}),headers:o||{"Content-Type":"application/json"}}).then(function(){var i=ol(Yn().mark(function s(a){var l;return Yn().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!a.ok){u.next=4;break}return u.abrupt("return",Si(a));case 4:if(!(a.status===400&&a.headers.get("content-type")==="application/json")){u.next=13;break}return u.next=7,a.json();case 7:if(l=u.sent,!("validationErrors"in l)){u.next=12;break}return u.abrupt("return",_t(l));case 12:return u.abrupt("return",YO(a.status,l,a.statusText));case 13:return u.abrupt("return",Si(a));case 14:case"end":return u.stop()}},s)}));return function(s){return i.apply(this,arguments)}}()).catch(Ds)}},{key:"postValidate",value:function(n){var r=n.patches,o=n.headers;return fetch("".concat(this.host,"/validate"),{method:"POST",body:JSON.stringify({patches:r}),headers:o||{"Content-Type":"application/json"}}).then(function(){var i=ol(Yn().mark(function s(a){return Yn().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.abrupt("return",Si(a));case 1:case"end":return c.stop()}},s)}));return function(s){return i.apply(this,arguments)}}()).catch(Ds)}}]),e}();function Ds(e){return _t({statusCode:500,message:e instanceof Error||ce(e)==="object"&&e&&"message"in e&&typeof e.message=="string"?e.message:"Unknown error",details:ce(e)==="object"&&e&&"details"in e?e.details:void 0})}function YO(e,t,n){return _t({statusCode:e,message:t.message||n,details:t.details||Object.fromEntries(Object.entries(t).filter(function(r){var o=Sn(r,1),i=o[0];return i!=="message"}))})}function Si(e){return Ly.apply(this,arguments)}function Ly(){return Ly=ol(Yn().mark(function e(t){var n;return Yn().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(o.prev=0,!t.ok){o.next=9;break}return o.t0=He,o.next=5,t.json();case 5:return o.t1=o.sent,o.abrupt("return",o.t0.ok.call(o.t0,o.t1));case 9:return o.prev=9,o.next=12,t.json();case 12:return n=o.sent,o.abrupt("return",YO(t.status,n,t.statusText));case 16:return o.prev=16,o.t2=o.catch(9),o.abrupt("return",_t({statusCode:t.status,message:t.statusText}));case 19:o.next=24;break;case 21:return o.prev=21,o.t3=o.catch(0),o.abrupt("return",_t({message:o.t3 instanceof Error?o.t3.message:"Unknown error"}));case 24:case"end":return o.stop()}},e,null,[[0,21],[9,16]])})),Ly.apply(this,arguments)}var Fe={VERSION:{core:function(){try{return require("../package.json").version}catch{return null}}()},convertFileSource:jO,getSchema:wD,getValPath:FO,getVal:ZD,getSource:AD,resolvePath:VD,splitModuleIdAndModulePath:ID,isVal:_D,createValPathOfItem:kr,getSHA256Hash:p3,initSchema:XD,notFileOp:function(t){return t.op!=="file"},isFileOp:function(t){return t.op==="file"&&typeof t.filePath=="string"},createPatchJSONPath:function(t){return"/".concat(t.split(".").map(function(n){return n&&h3(n)}).join("/"))},createPatchPath:function(t){return KO(t)},patchPathToModulePath:function(t){return t.map(function(n){return Number.isInteger(Number(n))?n:JSON.stringify(n)}).join(".")},VAL_ENABLE_COOKIE_NAME:"val_enable",VAL_STATE_COOKIE:"val_state",VAL_SESSION_COOKIE:"val_session"};function h3(e){try{return JSON.parse(e)}catch{return e}}var XO={exports:{}};/*!
43
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sn(e,t){return vD(e)||yD(e,t)||Gx(e,t)||xD()}function jt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ok(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,IO(r.key),r)}}function zt(e,t,n){return t&&ok(e.prototype,t),n&&ok(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function rh(e){return rh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},rh(e)}function DO(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(DO=function(){return!!e})()}function LO(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function bD(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return LO(e)}function dr(e,t,n){return t=rh(t),bD(e,DO()?Reflect.construct(t,n||[],rh(e).constructor):t.apply(e,n))}function Ay(e,t){return Ay=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Ay(e,t)}function fr(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ay(e,t)}var pr=function(){function e(){jt(this,e)}return zt(e,[{key:"appendValidationError",value:function(n,r,o,i){return n?(n[r]?n[r].push({message:o,value:i}):n[r]=[{message:o,value:i}],n):se({},r,[{message:o,value:i}])}}]),e}(),Au=Symbol("GetSchema"),wn=Symbol("Path"),Rt=Symbol("GetSource");function wD(e){return e[Au]}var Zx=zt(function e(t){jt(this,e),this.span=t}),kD=function(e){fr(t,e);function t(n,r){var o;return jt(this,t),o=dr(this,t,[r]),se(LO(o),"type","Sym"),o.value=n,o}return zt(t,[{key:"transpile",value:function(){return this.value}}]),t}(Zx);new kD("()");var Gt="_type",rn="_ref",ik="_tag",SD=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.options=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){return this.opt&&o==null?!1:o==null?se({},r,[{message:"Non-optional file was null or undefined.",value:o}]):typeof o[rn]!="string"?se({},r,[{message:"File did not have a file reference string. Got: ".concat(ce(o[rn])),value:o}]):o[Gt]!=="file"?se({},r,[{message:"File did not have the valid file extension type. Got: ".concat(o[Gt]),value:o}]):o.metadata?se({},r,[{message:"Found metadata, but it could not be validated. File metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",value:o,fixes:["file:check-metadata"]}]):se({},r,[{message:"Missing File metadata.",value:o,fixes:["file:add-metadata"]}])}},{key:"assert",value:function(r){return this.opt&&r==null?!0:(r==null?void 0:r[rn])==="file"&&(r==null?void 0:r[Gt])==="file"}},{key:"nullable",value:function(){return new t(this.options,!0)}},{key:"serialize",value:function(){return{type:"file",options:this.options,opt:this.opt}}}]),t}(pr),ED=function(t){return new SD(t)};function jO(e){var t,n;if(!e[rn].startsWith("/public")){var r,o;return{url:e[rn]+((r=e.metadata)!==null&&r!==void 0&&r.sha256?"?sha256=".concat((o=e.metadata)===null||o===void 0?void 0:o.sha256):""),metadata:e.metadata}}return{url:e[rn].slice(7)+((t=e.metadata)!==null&&t!==void 0&&t.sha256?"?sha256=".concat((n=e.metadata)===null||n===void 0?void 0:n.sha256):""),metadata:e.metadata}}function zO(e){return ce(e)==="object"&&e!==null&&e!==void 0&&("val"in e||"valPath"in e)}function _D(e){return ce(e)==="object"&&e!==null&&e!==void 0&&wn in e&&"val"in e}function FO(e){return e[wn]}function CD(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function sk(e,t,n){return t?Bt(e(Bt(t,n))):Bt(t,n)}function ls(e){return ce(e)==="object"&&e!==null&&(Rt in e||wn in e)}function Bt(e,t,n){if(ce(e)==="object"){if(ls(e))return e;if(zO(e))return Bt(e.val,e.valPath)}if(e&&e[rn]&&e[Gt]==="file"){var r=e[rn];if(typeof r!="string")throw Error("Invalid file ref: "+r);return Bt(jO(e),t,n)}switch(ce(e)){case"function":case"symbol":throw Error("Invalid selector type: ".concat(ce(e),": ").concat(e));case"object":if(e!==null)return new Proxy(e,{has:function(i,s){return s===Rt||s===wn||s==="andThen"||s===Au?!0:s in i},get:function(i,s){if(s===Rt)return e;if(s===wn)return t;if(s===Au)return n;if(s==="andThen")return function(l){return sk(l,e,t)};if(Array.isArray(i)){if(s==="filter")return function(l){var c=i.map(function(u,d){return Bt(u,kr(t,d),n==null?void 0:n.item)}).filter(function(u){return l&&l instanceof pr?l.assert(ak(u)):ak(l(u))});return Bt(c,t,n)};if(s==="map")return function(l){var c=i.map(function(u,d){var f=l(Bt(u,kr(t,d),n==null?void 0:n.item),Bt(d));return ls(f)?f:Bt(f)});return Bt(c,t,n)}}if(Array.isArray(i)&&s==="length")return Bt(i.length);var a=Reflect.get(i,s);return CD(e,s)?Number.isNaN(Number(s))?Bt(a,kr(t,s),n==null?void 0:n.items[s]):Bt(a,kr(t,Number(s)),n==null?void 0:n.item):a}});default:return se(se(se({eq:function(i){var s=i;if(ls(i)&&(s=i[Rt],s instanceof Zx))throw Error("TODO: Cannot evaluate equality with an Expr");return Bt(e===s,void 0)},andThen:function(i){return sk(i,e===void 0?null:e,t)}},Rt,e===void 0?null:e),wn,t),Au,n)}}function kr(e,t){if(ce(t)==="symbol")throw Error("Cannot create val path of array item with symbol prop: ".concat(t.toString()));return e!==void 0?"".concat(e,".").concat(JSON.stringify(t)):void 0}function ak(e){if(ce(e)==="object"&&(Rt in e||wn in e)){var t=e[Rt];return t}return e}var Jx=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.items=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){var i=this,s=!1;return this.opt&&o==null?!1:ce(o)!=="object"?se({},r,[{message:"Expected 'object', got '".concat(ce(o),"'")}]):Array.isArray(o)?se({},r,[{message:"Expected 'object', got 'array'"}]):(Object.entries(this.items).forEach(function(a){var l=Sn(a,2),c=l[0],u=l[1],d=kr(r,c);if(!d)s=i.appendValidationError(s,r,"Internal error: could not create path at ".concat(!r&&typeof r=="string"?"<empty string>":r," at key ").concat(c),o);else{var f=u.validate(d,o[c]);f&&s?s=br(br({},f),s):f&&(s=f)}}),s)}},{key:"assert",value:function(r){if(this.opt&&r==null)return!0;if(!r)return!1;for(var o=0,i=Object.entries(this.items);o<i.length;o++){var s=Sn(i[o],2),a=s[0],l=s[1];if(!l.assert(r[a]))return!1}return ce(r)==="object"&&!Array.isArray(r)}},{key:"nullable",value:function(){return new t(this.items,!0)}},{key:"serialize",value:function(){return{type:"object",items:Object.fromEntries(Object.entries(this.items).map(function(r){var o=Sn(r,2),i=o[0],s=o[1];return[i,s.serialize()]})),opt:this.opt}}}]),t}(pr),OD=function(t){return new Jx(t)},BO=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.item=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){var i=this,s=!1;return this.opt&&o==null?!1:ce(o)!=="object"||!Array.isArray(o)?se({},r,[{message:"Expected 'array', got '".concat(ce(o),"'")}]):(o.forEach(function(a,l){var c=kr(r,l);if(!c)s=i.appendValidationError(s,r,"Internal error: could not create path at ".concat(!r&&typeof r=="string"?"<empty string>":r," at index ").concat(l),o);else{var u=i.item.validate(c,a);u&&s?s=br(br({},u),s):u&&(s=u)}}),s)}},{key:"assert",value:function(r){if(this.opt&&r==null)return!0;if(!r)return!1;var o=bm(r),i;try{for(o.s();!(i=o.n()).done;){var s=i.value;if(!this.item.assert(s))return!1}}catch(a){o.e(a)}finally{o.f()}return ce(r)==="object"&&Array.isArray(r)}},{key:"nullable",value:function(){return new t(this.item,!0)}},{key:"serialize",value:function(){return{type:"array",item:this.item.serialize(),opt:this.opt}}}]),t}(pr),TD=function(t){return new BO(t)},Iy=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.value=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){return this.opt&&o==null?!1:typeof o!="string"?se({},r,[{message:"Expected 'string', got '".concat(ce(o),"'"),value:o}]):o!==this.value?se({},r,[{message:"Expected literal '".concat(this.value,"', got '").concat(o,"'"),value:o}]):!1}},{key:"assert",value:function(r){return this.opt&&r==null?!0:typeof r=="string"}},{key:"nullable",value:function(){return new t(this.value,!0)}},{key:"serialize",value:function(){return{type:"literal",value:this.value,opt:this.opt}}}]),t}(pr),PD=function(t){return new Iy(t)},VO=function(e){fr(t,e);function t(n,r){var o,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return jt(this,t),o=dr(this,t),o.key=n,o.items=r,o.opt=i,o}return zt(t,[{key:"validate",value:function(r,o){var i=o,s=!1;if(this.opt&&i==null)return!1;if(!this.key)return se({},r,[{message:"Missing required first argument in union"}]);var a=this.key;if(!Array.isArray(this.items))return se({},r,[{message:"A union schema must take more than 1 schema arguments",fatal:!0}]);if(typeof a=="string"){if(this.items.some(function(P){return!(P instanceof Jx)}))return se({},r,[{message:"Key is a string, so all schema items must be objects",fatal:!0}]);var l=this.items,c=l.map(function(P){return P.serialize()}),u=c.filter(function(P){return P.type!=="object"||P.items[a].type!=="literal"});if(u.length>0)return se({},r,[{message:"All schema items must be objects with a key: ".concat(a," that is a literal schema. Found: ").concat(JSON.stringify(u,null,2)),fatal:!0}]);var d=c,f=d.filter(function(P){return P.items[a].opt});if(f.length>1)return se({},r,[{message:"Schema cannot have an optional keys: ".concat(a),fatal:!0}]);if(ce(i)!=="object")return se({},r,[{message:"Expected an object"}]);var p=i;if(p[a]===void 0)return se({},r,[{message:"Missing required key: ".concat(a)}]);var h=[],g=bm(d),b;try{for(g.s();!(b=g.n()).done;){var y=b.value,x=y.items[a];if(x.type==="literal")if(!h.includes(x.value))h.push(x.value);else return se({},r,[{message:"Found duplicate key in schema: ".concat(x.value),fatal:!0}])}}catch(P){g.e(P)}finally{g.f()}var w=l.find(function(P){return!P.items[a].validate(r,p[a])});if(!w){var k=kr(r,a);if(!k)throw new Error("Internal error: could not create path at ".concat(!r&&typeof r=="string"?"<empty string>":r," at key ").concat(a));return se({},k,[{message:'Invalid key: "'.concat(a,'". Value was: "').concat(p[a],'". Valid values: ').concat(d.map(function(P){var N=P.items[a];if(N.type==="literal"&&N.value)return'"'.concat(N.value,'"');throw new Error("Expected literal schema, got ".concat(JSON.stringify(N,null,2)))}).join(", "))}])}var S=w.validate(r,p);if(S)return S}else if(a instanceof Iy){if(this.items.some(function(P){return!(P instanceof Iy)}))return se({},r,[{message:"Key is a literal schema, so all schema items must be literals",fatal:!0}]);var O=[a].concat(AO(this.items));if(typeof i=="string"){var E=O.some(function(P){return!P.validate(r,i)});if(!E)return se({},r,[{message:"Union must match one of the following: ".concat(O.map(function(P){return'"'.concat(P.value,'"')}).join(", "))}])}}else return se({},r,[{message:"Expected a string or literal"}]);return s}},{key:"assert",value:function(r){return!0}},{key:"nullable",value:function(){return new t(this.key,this.items,!0)}},{key:"serialize",value:function(){return typeof this.key=="string"?{type:"union",key:this.key,items:this.items.map(function(r){return r.serialize()}),opt:this.opt}:{type:"union",key:this.key.serialize(),items:this.items.map(function(r){return r.serialize()}),opt:this.opt}}}]),t}(pr),MD=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new VO(t,r)},UO=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.options=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){return!1}},{key:"assert",value:function(r){return!0}},{key:"nullable",value:function(){return new t(this.options,!0)}},{key:"serialize",value:function(){return{type:"richtext",opt:this.opt,options:this.options}}}]),t}(pr),ND=function(t){return new UO(t??{})},HO=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.options=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){return this.opt&&o==null?!1:o==null?se({},r,[{message:"Non-optional image was null or undefined.",value:o}]):typeof o[rn]!="string"?se({},r,[{message:"Image did not have a file reference string. Got: ".concat(ce(o[rn])),value:o}]):o[Gt]!=="file"?se({},r,[{message:"Image did not have the valid file extension type. Got: ".concat(o[Gt]),value:o}]):o.metadata?se({},r,[{message:"Found metadata, but it could not be validated. Image metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",value:o,fixes:["image:replace-metadata"]}]):se({},r,[{message:"Could not validate Image metadata.",value:o,fixes:["image:add-metadata"]}])}},{key:"assert",value:function(r){return this.opt&&r==null?!0:(r==null?void 0:r[rn])==="image"&&(r==null?void 0:r[Gt])==="file"}},{key:"nullable",value:function(){return new t(this.options,!0)}},{key:"serialize",value:function(){return{type:"image",options:this.options,opt:this.opt}}}]),t}(pr),RD=function(t){return new HO(t)},WO=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.item=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){var i=this,s=!1;return this.opt&&o==null?!1:ce(o)!=="object"?se({},r,[{message:"Expected 'object', got '".concat(ce(o),"'")}]):Array.isArray(o)?se({},r,[{message:"Expected 'object', got 'array'"}]):(Object.entries(o).forEach(function(a){var l=Sn(a,2),c=l[0],u=l[1],d=kr(r,c);if(!d)s=i.appendValidationError(s,r,"Internal error: could not create path at ".concat(!r&&typeof r=="string"?"<empty string>":r," at key ").concat(u),o);else{var f=i.item.validate(d,u);f&&s?s=br(br({},f),s):f&&(s=f)}}),s)}},{key:"assert",value:function(r){if(this.opt&&r==null)return!0;if(!r)return!1;for(var o=0,i=Object.entries(r);o<i.length;o++){var s=Sn(i[o],2),a=s[1];if(!this.item.assert(a))return!1}return ce(r)==="object"&&!Array.isArray(r)}},{key:"nullable",value:function(){return new t(this.item,!0)}},{key:"serialize",value:function(){return{type:"record",item:this.item.serialize(),opt:this.opt}}}]),t}(pr),$D=function(t){return new WO(t)};function AD(e){var t=e[Rt];if(t instanceof Zx)throw Error("Cannot get raw source of an Expr");var n=t;return n}function ID(e){return e.indexOf(".")===-1?[e,""]:[e.slice(0,e.indexOf(".")),e.slice(e.indexOf(".")+1)]}function DD(e){return e instanceof Jx||ce(e)==="object"&&"type"in e&&e.type==="object"}function LD(e){return e instanceof WO||ce(e)==="object"&&"type"in e&&e.type==="record"}function jD(e){return e instanceof BO||ce(e)==="object"&&"type"in e&&e.type==="array"}function zD(e){return e instanceof VO||ce(e)==="object"&&"type"in e&&e.type==="union"}function FD(e){return e instanceof UO||ce(e)==="object"&&"type"in e&&e.type==="richtext"}function BD(e){return e instanceof HO||ce(e)==="object"&&"type"in e&&e.type==="image"}function VD(e,t,n){for(var r=KO(e),o=AO(r),i=n,s=t,a=function(){var u=r.shift();if(u===void 0)throw Error("Unexpected undefined part");if(jD(i)){if(Number.isNaN(Number(u)))throw Error("Invalid path: array schema ".concat(JSON.stringify(i)," must have a number as path, but got ").concat(u,". Path: ").concat(e));if(ce(s)!=="object"&&!Array.isArray(s))throw Error("Schema type error: expected source to be type of array, but got ".concat(ce(s)));if(s[u]===void 0){var d;throw Error("Invalid path: array source (length: ".concat((d=s)===null||d===void 0?void 0:d.length,") did not have index ").concat(u," from path: ").concat(e))}s=s[u],i=i.item}else if(LD(i)){if(typeof u!="string")throw Error("Invalid path: record schema ".concat(i," must have path: ").concat(u," as string"));if(ce(s)!=="object"&&!Array.isArray(s))throw Error("Schema type error: expected source to be type of record, but got ".concat(ce(s)));if(!s[u])throw Error("Invalid path: record source did not have key ".concat(u," from path: ").concat(e));s=s[u],i=i.item}else if(DD(i)){if(ce(s)!=="object")throw Error("Schema type error: expected source to be type of object, but got ".concat(ce(s)));if(!s[u])throw Error("Invalid path: object source did not have key ".concat(u," from path: ").concat(e));s=s[u],i=i.items[u]}else{if(BD(i))return{v:{path:o.slice(0,o.length-r.length-1).map(function(g){return JSON.stringify(g)}).join("."),schema:i,source:s}};if(zD(i)){var f=i.key;if(typeof f!="string")return{v:{path:o.map(function(g){return Number.isNaN(Number(g))?JSON.stringify(g):g}).join("."),schema:i,source:s}};var p=s[f];if(!p)throw Error("Invalid path: union source ".concat(i," did not have required key ").concat(f," in path: ").concat(e));var h=i.items.find(function(g){var b;return(g==null||(b=g.items)===null||b===void 0||(b=b[f])===null||b===void 0?void 0:b.value)===p});if(!h)throw Error("Invalid path: union schema ".concat(i," did not have a child object with ").concat(f," of value ").concat(p," in path: ").concat(e));i=h.items[u],s=s[u]}else{if(FD(i))return{v:{path:o.slice(0,o.length-r.length-1).map(function(g){return JSON.stringify(g)}).join("."),schema:i,source:s}};throw Error("Invalid path: ".concat(u," resolved to an unexpected schema ").concat(JSON.stringify(i)))}}},l;r.length>0;)if(l=a(),l)return l.v;if(r.length>0)throw Error("Invalid path: ".concat(r.join(".")," is not a valid path"));return{path:o.map(function(c){return Number.isNaN(Number(c))?JSON.stringify(c):c}).join("."),schema:i,source:s}}function KO(e){for(var t=[],n=0;n<e.length;){var r="";if(e[n]==='"'){for(n++;n<e.length&&e[n]!=='"';)e[n]==="\\"&&e[n+1]==='"'?(r+='"',n++):r+=e[n],n++;if(e[n]!=='"'){var o;throw new Error("Invalid input (".concat(JSON.stringify(e),"): Missing closing double quote: ").concat((o=e[n])!==null&&o!==void 0?o:"at end of string"," (char: ").concat(n,"; length: ").concat(e.length,")"))}}else for(;n<e.length&&e[n]!==".";)r+=e[n],n++;r!==""&&t.push(r),n++}return t}var sr=zt(function e(t){jt(this,e),this.message=t}),UD=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jt(this,t),r=dr(this,t),r.options=n,r.opt=o,r}return zt(t,[{key:"validate",value:function(r,o){return this.opt&&o==null?!1:typeof o!="number"?se({},r,[{message:"Expected 'number', got '".concat(ce(o),"'"),value:o}]):!1}},{key:"assert",value:function(r){return this.opt&&r==null?!0:typeof r=="number"}},{key:"nullable",value:function(){return new t(this.options,!0)}},{key:"serialize",value:function(){return{type:"number",options:this.options,opt:this.opt}}}]),t}(pr),HD=function(t){return new UD(t)},qO=function(e){fr(t,e);function t(n){var r,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return jt(this,t),r=dr(this,t),r.options=n,r.opt=o,r.isRaw=i,r}return zt(t,[{key:"min",value:function(r){return new t(br(br({},this.options),{},{minLength:r}),this.opt,this.isRaw)}},{key:"max",value:function(r){return new t(br(br({},this.options),{},{maxLength:r}),this.opt,this.isRaw)}},{key:"regexp",value:function(r){return new t(br(br({},this.options),{},{regexp:r}),this.opt,this.isRaw)}},{key:"validate",value:function(r,o){var i,s,a;if(this.opt&&o==null)return!1;if(typeof o!="string")return se({},r,[{message:"Expected 'string', got '".concat(ce(o),"'"),value:o}]);var l=[];return(i=this.options)!==null&&i!==void 0&&i.maxLength&&o.length>this.options.maxLength&&l.push({message:"Expected string to be at most ".concat(this.options.maxLength," characters long, got ").concat(o.length),value:o}),(s=this.options)!==null&&s!==void 0&&s.minLength&&o.length<this.options.minLength&&l.push({message:"Expected string to be at least ".concat(this.options.minLength," characters long, got ").concat(o.length),value:o}),(a=this.options)!==null&&a!==void 0&&a.regexp&&!this.options.regexp.test(o)&&l.push({message:"Expected string to match reg exp: ".concat(this.options.regexp.toString(),", got '").concat(o,"'"),value:o}),l.length>0?se({},r,l):!1}},{key:"assert",value:function(r){return this.opt&&r==null?!0:typeof r=="string"}},{key:"nullable",value:function(){return new t(this.options,!0,this.isRaw)}},{key:"raw",value:function(){return new t(this.options,this.opt,!0)}},{key:"serialize",value:function(){var r,o,i;return{type:"string",options:{maxLength:(r=this.options)===null||r===void 0?void 0:r.maxLength,minLength:(o=this.options)===null||o===void 0?void 0:o.minLength,regexp:((i=this.options)===null||i===void 0?void 0:i.regexp)&&{source:this.options.regexp.source,flags:this.options.regexp.flags}},opt:this.opt,raw:this.isRaw}}}]),t}(pr),WD=function(t){return new qO(t)},KD=function(e){fr(t,e);function t(){var n,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return jt(this,t),n=dr(this,t),n.opt=r,n}return zt(t,[{key:"validate",value:function(r,o){return this.opt&&o==null?!1:typeof o!="boolean"?se({},r,[{message:"Expected 'boolean', got '".concat(ce(o),"'"),value:o}]):!1}},{key:"assert",value:function(r){return this.opt&&r==null?!0:typeof r=="boolean"}},{key:"nullable",value:function(){return new t(!0)}},{key:"serialize",value:function(){return{type:"boolean",opt:this.opt}}}]),t}(pr),qD=function(){return new KD},GD=function(e){fr(t,e);function t(n,r){var o,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return jt(this,t),o=dr(this,t),o.schema=n,o.sourcePath=r,o.opt=i,o}return zt(t,[{key:"validate",value:function(r,o){if(this.opt&&o==null)return!1;if(!this.schema)return se({},r,[{message:"Schema not found for module. keyOf must be used with a Val Module"}]);var i=this.schema;if(!(i.type==="array"||i.type==="object"||i.type==="record"))return se({},r,[{message:"Schema in keyOf must be an 'array', 'object' or 'record'. Found '".concat(i.type,"'")}]);if(i.opt&&o==null)return!1;if(i.type==="array"&&typeof o!="number")return se({},r,[{message:"Type of value in keyof (array) must be 'number'"}]);if(i.type==="record"&&typeof o!="string")return se({},r,[{message:"Type of value in keyof (record) must be 'string'"}]);if(i.type==="object"){var s=Object.keys(i.items);if(!s.includes(o))return se({},r,[{message:"Value of keyOf (object) must be: ".concat(s.join(", "),". Found: ").concat(o)}])}return!1}},{key:"assert",value:function(r){if(this.opt&&r==null)return!0;var o=this.schema;if(!o)return!1;var i=o;if(!(i.type==="array"||i.type==="object"||i.type==="record"))return!1;if(i.opt&&r==null)return!0;if(i.type==="array"&&typeof r!="number"||i.type==="record"&&typeof r!="string")return!1;if(i.type==="object"){var s=Object.keys(i.items);if(!s.includes(r))return!1}return!0}},{key:"nullable",value:function(){return new t(this.schema,this.sourcePath,!0)}},{key:"serialize",value:function(){var r=this.sourcePath;if(!r)throw new Error("Cannot serialize keyOf schema with empty selector. TIP: keyOf must be used with a Val Module.");var o=this.schema;if(!o)throw new Error("Cannot serialize keyOf schema with empty selector.");var i;switch(o.type){case"array":i="number";break;case"record":i="string";break;case"object":i=Object.keys(o.items);break;default:throw new Error("Cannot serialize keyOf schema with selector of type '".concat(o.type,"'. keyOf must be used with a Val Module."))}return{type:"keyOf",path:r,schema:o,opt:this.opt,values:i}}}]),t}(pr),YD=function(t){var n;return new GD(t==null||(n=t[Au])===null||n===void 0?void 0:n.serialize(),FO(t))};function XD(){return{string:WD,boolean:qD,array:TD,object:OD,number:HD,union:MD,richtext:ND,image:RD,literal:PD,keyOf:YD,record:$D,file:ED}}var lk="rt_image";function ZD(e){return GO(e3(e))}function JD(e){return ls(e)?ce(e[Rt])==="object"&&e[Rt]!==null&&Array.isArray(e[Rt]):Array.isArray(e)}function QD(e){return ls(e)?ce(e[Rt])==="object"&&e[Rt]!==null&&!Array.isArray(e[Rt]):ce(e)==="object"}function e3(e){var t=Bt(e);function n(r){var o=JD(r),i=QD(r);if(o){var s=Rt in r?r[Rt]:r,a=wn in r?r[wn]:void 0;return{val:s.map(function(u,d){return n(ls(u)?u:Bt(u,kr(a,d)))}),valPath:a}}else if(i){var l=Rt in r?r[Rt]:r,c=wn in r?r[wn]:void 0;return{val:l!==null&&Object.fromEntries(Object.entries(l).map(function(u){var d=Sn(u,2),f=d[0],p=d[1];return[f,n(ls(p)?p:Bt(p,kr(c,f)))]})),valPath:c}}else return ls(r)?{val:n(r[Rt]),valPath:r[wn]}:r}return n(t)}function Dy(e){var t=zO(e)?e.val:e;switch(ce(t)){case"function":case"symbol":throw Error("Invalid val type: ".concat(ce(t)));case"object":return t===null?null:Array.isArray(t)?t.map(Dy):Object.fromEntries(Object.entries(t).map(function(n){var r=Sn(n,2),o=r[0],i=r[1];return[o,i&&Dy(i)]}));default:return t}}function GO(e){var t=e.val;switch(ce(t)){case"function":case"symbol":throw Error("Invalid val type: ".concat(ce(t)));case"object":if(t!==null)return new Proxy(t,{has:function(r,o){return o==="val"||o===wn?!0:ck(r,o)},get:function(r,o){if(o===wn)return e.valPath;if(o==="val")return Dy(e);if(Array.isArray(r)&&o==="length")return r.length;if(ck(t,o)){var i,s;return GO({val:Reflect.get(r,o).val,valPath:(i=(s=Reflect.get(r,o))===null||s===void 0?void 0:s.valPath)!==null&&i!==void 0?i:kr(e.valPath,Array.isArray(r)?Number(o):o)})}return Reflect.get(r,o)}});default:return se(se({},wn,e.valPath),"val",e.val)}}function ck(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var t3=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998],Qe=function(e){return e[e.inputBytes=64]="inputBytes",e[e.inputWords=16]="inputWords",e[e.highIndex=14]="highIndex",e[e.lowIndex=15]="lowIndex",e[e.workWords=64]="workWords",e[e.allocBytes=80]="allocBytes",e[e.allocWords=20]="allocWords",e[e.allocTotal=8e3]="allocTotal",e}(Qe||{}),uk={sha256:1};function n3(e){if(e&&!uk[e]&&!uk[e.toLowerCase()])throw new Error("Digest method not supported");return new r3}var r3=function(){function e(){jt(this,e),se(this,"A",1779033703),se(this,"B",-1150833019),se(this,"C",1013904242),se(this,"D",-1521486534),se(this,"E",1359893119),se(this,"F",-1694144372),se(this,"G",528734635),se(this,"H",1541459225),se(this,"_size",0),se(this,"_sp",0),(!Lf||Fc>=Qe.allocTotal)&&(Lf=new ArrayBuffer(Qe.allocTotal),Fc=0),this._byte=new Uint8Array(Lf,Fc,Qe.allocBytes),this._word=new Int32Array(Lf,Fc,Qe.allocWords),Fc+=Qe.allocBytes}return zt(e,[{key:"update",value:function(n){if(typeof n=="string")return this._utf8(n);if(n==null)throw new TypeError("Invalid type: "+ce(n));var r=n.byteOffset,o=n.byteLength,i=o/Qe.inputBytes|0,s=0;if(i&&!(r&3)&&!(this._size%Qe.inputBytes)){for(var a=new Int32Array(n.buffer,r,i*Qe.inputWords);i--;)this._int32(a,s>>2),s+=Qe.inputBytes;this._size+=s}var l=n.BYTES_PER_ELEMENT;if(l!==1&&n.buffer){var c=new Uint8Array(n.buffer,r+s,o-s);return this._uint8(c)}return s===o?this:this._uint8(n,s)}},{key:"_uint8",value:function(n,r){var o=this._byte,i=this._word,s=n.length;for(r=r|0;r<s;){for(var a=this._size%Qe.inputBytes,l=a;r<s&&l<Qe.inputBytes;)o[l++]=n[r++];l>=Qe.inputBytes&&this._int32(i),this._size+=l-a}return this}},{key:"_utf8",value:function(n){for(var r=this._byte,o=this._word,i=n.length,s=this._sp,a=0;a<i;){for(var l=this._size%Qe.inputBytes,c=l;a<i&&c<Qe.inputBytes;){var u=n.charCodeAt(a++)|0;u<128?r[c++]=u:u<2048?(r[c++]=192|u>>>6,r[c++]=128|u&63):u<55296||u>57343?(r[c++]=224|u>>>12,r[c++]=128|u>>>6&63,r[c++]=128|u&63):s?(u=((s&1023)<<10)+(u&1023)+65536,r[c++]=240|u>>>18,r[c++]=128|u>>>12&63,r[c++]=128|u>>>6&63,r[c++]=128|u&63,s=0):s=u}c>=Qe.inputBytes&&(this._int32(o),o[0]=o[Qe.inputWords]),this._size+=c-l}return this._sp=s,this}},{key:"_int32",value:function(n,r){var o=this.A,i=this.B,s=this.C,a=this.D,l=this.E,c=this.F,u=this.G,d=this.H,f=0;for(r=r|0;f<Qe.inputWords;)Is[f++]=zr(n[r++]);for(f=Qe.inputWords;f<Qe.workWords;f++)Is[f]=d3(Is[f-2])+Is[f-7]+u3(Is[f-15])+Is[f-16]|0;for(f=0;f<Qe.workWords;f++){var p=d+c3(l)+s3(l,c,u)+t3[f]+Is[f]|0,h=l3(o)+a3(o,i,s)|0;d=u,u=c,c=l,l=a+p|0,a=s,s=i,i=o,o=p+h|0}this.A=o+this.A|0,this.B=i+this.B|0,this.C=s+this.C|0,this.D=a+this.D|0,this.E=l+this.E|0,this.F=c+this.F|0,this.G=u+this.G|0,this.H=d+this.H|0}},{key:"digest",value:function(n){var r=this._byte,o=this._word,i=this._size%Qe.inputBytes|0;for(r[i++]=128;i&3;)r[i++]=0;if(i>>=2,i>Qe.highIndex){for(;i<Qe.inputWords;)o[i++]=0;i=0,this._int32(o)}for(;i<Qe.inputWords;)o[i++]=0;var s=this._size*8,a=(s&4294967295)>>>0,l=(s-a)/4294967296;return l&&(o[Qe.highIndex]=zr(l)),a&&(o[Qe.lowIndex]=zr(a)),this._int32(o),n==="hex"?this._hex():this._bin()}},{key:"_hex",value:function(){var n=this.A,r=this.B,o=this.C,i=this.D,s=this.E,a=this.F,l=this.G,c=this.H;return ki(n)+ki(r)+ki(o)+ki(i)+ki(s)+ki(a)+ki(l)+ki(c)}},{key:"_bin",value:function(){var n=this.A,r=this.B,o=this.C,i=this.D,s=this.E,a=this.F,l=this.G,c=this.H,u=this._byte,d=this._word;return d[0]=zr(n),d[1]=zr(r),d[2]=zr(o),d[3]=zr(i),d[4]=zr(s),d[5]=zr(a),d[6]=zr(l),d[7]=zr(c),u.slice(0,32)}}]),e}(),Is=new Int32Array(Qe.workWords),Lf,Fc=0,ki=function(t){return(t+4294967296).toString(16).substr(-8)},o3=function(t){return t<<24&4278190080|t<<8&16711680|t>>8&65280|t>>24&255},i3=function(t){return t},zr=f3()?i3:o3,s3=function(t,n,r){return r^t&(n^r)},a3=function(t,n,r){return t&n|r&(t|n)},l3=function(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)},c3=function(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)},u3=function(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3},d3=function(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10};function f3(){var e=new Uint8Array(new Uint16Array([65279]).buffer);return e[0]===254}var p3=function(t){return n3().update(t).digest("hex")};function Yn(){Yn=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(_,T,C){_[T]=C.value},i=typeof Symbol=="function"?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function c(_,T,C){return Object.defineProperty(_,T,{value:C,enumerable:!0,configurable:!0,writable:!0}),_[T]}try{c({},"")}catch{c=function(T,C,M){return T[C]=M}}function u(_,T,C,M){var R=T&&T.prototype instanceof y?T:y,L=Object.create(R.prototype),G=new U(M||[]);return o(L,"_invoke",{value:$(_,C,G)}),L}function d(_,T,C){try{return{type:"normal",arg:_.call(T,C)}}catch(M){return{type:"throw",arg:M}}}t.wrap=u;var f="suspendedStart",p="suspendedYield",h="executing",g="completed",b={};function y(){}function x(){}function w(){}var k={};c(k,s,function(){return this});var S=Object.getPrototypeOf,O=S&&S(S(K([])));O&&O!==n&&r.call(O,s)&&(k=O);var E=w.prototype=y.prototype=Object.create(k);function P(_){["next","throw","return"].forEach(function(T){c(_,T,function(C){return this._invoke(T,C)})})}function N(_,T){function C(R,L,G,ve){var me=d(_[R],_,L);if(me.type!=="throw"){var Be=me.arg,Te=Be.value;return Te&&typeof Te=="object"&&r.call(Te,"__await")?T.resolve(Te.__await).then(function(J){C("next",J,G,ve)},function(J){C("throw",J,G,ve)}):T.resolve(Te).then(function(J){Be.value=J,G(Be)},function(J){return C("throw",J,G,ve)})}ve(me.arg)}var M;o(this,"_invoke",{value:function(R,L){function G(){return new T(function(ve,me){C(R,L,ve,me)})}return M=M?M.then(G,G):G()}})}function $(_,T,C){var M=f;return function(R,L){if(M===h)throw new Error("Generator is already running");if(M===g){if(R==="throw")throw L;return{value:e,done:!0}}for(C.method=R,C.arg=L;;){var G=C.delegate;if(G){var ve=z(G,C);if(ve){if(ve===b)continue;return ve}}if(C.method==="next")C.sent=C._sent=C.arg;else if(C.method==="throw"){if(M===f)throw M=g,C.arg;C.dispatchException(C.arg)}else C.method==="return"&&C.abrupt("return",C.arg);M=h;var me=d(_,T,C);if(me.type==="normal"){if(M=C.done?g:p,me.arg===b)continue;return{value:me.arg,done:C.done}}me.type==="throw"&&(M=g,C.method="throw",C.arg=me.arg)}}}function z(_,T){var C=T.method,M=_.iterator[C];if(M===e)return T.delegate=null,C==="throw"&&_.iterator.return&&(T.method="return",T.arg=e,z(_,T),T.method==="throw")||C!=="return"&&(T.method="throw",T.arg=new TypeError("The iterator does not provide a '"+C+"' method")),b;var R=d(M,_.iterator,T.arg);if(R.type==="throw")return T.method="throw",T.arg=R.arg,T.delegate=null,b;var L=R.arg;return L?L.done?(T[_.resultName]=L.value,T.next=_.nextLoc,T.method!=="return"&&(T.method="next",T.arg=e),T.delegate=null,b):L:(T.method="throw",T.arg=new TypeError("iterator result is not an object"),T.delegate=null,b)}function j(_){var T={tryLoc:_[0]};1 in _&&(T.catchLoc=_[1]),2 in _&&(T.finallyLoc=_[2],T.afterLoc=_[3]),this.tryEntries.push(T)}function le(_){var T=_.completion||{};T.type="normal",delete T.arg,_.completion=T}function U(_){this.tryEntries=[{tryLoc:"root"}],_.forEach(j,this),this.reset(!0)}function K(_){if(_||_===""){var T=_[s];if(T)return T.call(_);if(typeof _.next=="function")return _;if(!isNaN(_.length)){var C=-1,M=function R(){for(;++C<_.length;)if(r.call(_,C))return R.value=_[C],R.done=!1,R;return R.value=e,R.done=!0,R};return M.next=M}}throw new TypeError(typeof _+" is not iterable")}return x.prototype=w,o(E,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:x,configurable:!0}),x.displayName=c(w,l,"GeneratorFunction"),t.isGeneratorFunction=function(_){var T=typeof _=="function"&&_.constructor;return!!T&&(T===x||(T.displayName||T.name)==="GeneratorFunction")},t.mark=function(_){return Object.setPrototypeOf?Object.setPrototypeOf(_,w):(_.__proto__=w,c(_,l,"GeneratorFunction")),_.prototype=Object.create(E),_},t.awrap=function(_){return{__await:_}},P(N.prototype),c(N.prototype,a,function(){return this}),t.AsyncIterator=N,t.async=function(_,T,C,M,R){R===void 0&&(R=Promise);var L=new N(u(_,T,C,M),R);return t.isGeneratorFunction(T)?L:L.next().then(function(G){return G.done?G.value:L.next()})},P(E),c(E,l,"Generator"),c(E,s,function(){return this}),c(E,"toString",function(){return"[object Generator]"}),t.keys=function(_){var T=Object(_),C=[];for(var M in T)C.push(M);return C.reverse(),function R(){for(;C.length;){var L=C.pop();if(L in T)return R.value=L,R.done=!1,R}return R.done=!0,R}},t.values=K,U.prototype={constructor:U,reset:function(_){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(le),!_)for(var T in this)T.charAt(0)==="t"&&r.call(this,T)&&!isNaN(+T.slice(1))&&(this[T]=e)},stop:function(){this.done=!0;var _=this.tryEntries[0].completion;if(_.type==="throw")throw _.arg;return this.rval},dispatchException:function(_){if(this.done)throw _;var T=this;function C(me,Be){return L.type="throw",L.arg=_,T.next=me,Be&&(T.method="next",T.arg=e),!!Be}for(var M=this.tryEntries.length-1;M>=0;--M){var R=this.tryEntries[M],L=R.completion;if(R.tryLoc==="root")return C("end");if(R.tryLoc<=this.prev){var G=r.call(R,"catchLoc"),ve=r.call(R,"finallyLoc");if(G&&ve){if(this.prev<R.catchLoc)return C(R.catchLoc,!0);if(this.prev<R.finallyLoc)return C(R.finallyLoc)}else if(G){if(this.prev<R.catchLoc)return C(R.catchLoc,!0)}else{if(!ve)throw new Error("try statement without catch or finally");if(this.prev<R.finallyLoc)return C(R.finallyLoc)}}}},abrupt:function(_,T){for(var C=this.tryEntries.length-1;C>=0;--C){var M=this.tryEntries[C];if(M.tryLoc<=this.prev&&r.call(M,"finallyLoc")&&this.prev<M.finallyLoc){var R=M;break}}R&&(_==="break"||_==="continue")&&R.tryLoc<=T&&T<=R.finallyLoc&&(R=null);var L=R?R.completion:{};return L.type=_,L.arg=T,R?(this.method="next",this.next=R.finallyLoc,b):this.complete(L)},complete:function(_,T){if(_.type==="throw")throw _.arg;return _.type==="break"||_.type==="continue"?this.next=_.arg:_.type==="return"?(this.rval=this.arg=_.arg,this.method="return",this.next="end"):_.type==="normal"&&T&&(this.next=T),b},finish:function(_){for(var T=this.tryEntries.length-1;T>=0;--T){var C=this.tryEntries[T];if(C.finallyLoc===_)return this.complete(C.completion,C.afterLoc),le(C),b}},catch:function(_){for(var T=this.tryEntries.length-1;T>=0;--T){var C=this.tryEntries[T];if(C.tryLoc===_){var M=C.completion;if(M.type==="throw"){var R=M.arg;le(C)}return R}}throw new Error("illegal catch attempt")},delegateYield:function(_,T,C){return this.delegate={iterator:K(_),resultName:T,nextLoc:C},this.method==="next"&&(this.arg=e),b}},t}function dk(e,t,n,r,o,i,s){try{var a=e[i](s),l=a.value}catch(c){n(c);return}a.done?t(l):Promise.resolve(l).then(r,o)}function ol(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function s(l){dk(i,r,o,s,a,"next",l)}function a(l){dk(i,r,o,s,a,"throw",l)}s(void 0)})}}var Qx=function(){function e(t){jt(this,e),this.host=t}return zt(e,[{key:"getDisableUrl",value:function(n){return"".concat(this.host,"/disable?redirect_to=").concat(encodeURIComponent(n))}},{key:"getLoginUrl",value:function(n){return"".concat(this.host,"/authorize?redirect_to=").concat(encodeURIComponent(n))}},{key:"getEnableUrl",value:function(n){return"".concat(this.host,"/enable?redirect_to=").concat(encodeURIComponent(n))}},{key:"getPatches",value:function(){var t=ol(Yn().mark(function r(o){var i,s,a;return Yn().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return i=o.patchIds,s=o.headers,a=i?"?".concat(i.map(function(u){return"".concat(u,"=").concat(encodeURIComponent(u))}).join("&")):"",c.abrupt("return",fetch("".concat(this.host,"/patches/~").concat(a),{headers:s||{"Content-Type":"application/json"}}).then(function(u){return Si(u)}).catch(Ds));case 3:case"end":return c.stop()}},r,this)}));function n(r){return t.apply(this,arguments)}return n}()},{key:"deletePatches",value:function(){var t=ol(Yn().mark(function r(o,i){var s;return Yn().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return s=new URLSearchParams,o.forEach(function(c){return s.append("id",c)}),l.abrupt("return",fetch("".concat(this.host,"/patches/~?").concat(s),{method:"DELETE",headers:i||{"Content-Type":"application/json"}}).then(function(c){return Si(c)}).catch(Ds));case 3:case"end":return l.stop()}},r,this)}));function n(r,o){return t.apply(this,arguments)}return n}()},{key:"getEditUrl",value:function(){return"/val"}},{key:"postPatches",value:function(n,r,o){return fetch("".concat(this.host,"/patches/~"),{headers:o||{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(se({},n,r))}).then(function(){var i=ol(Yn().mark(function s(a){return Yn().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.abrupt("return",Si(a));case 1:case"end":return c.stop()}},s)}));return function(s){return i.apply(this,arguments)}}()).catch(Ds)}},{key:"getSession",value:function(){return fetch("".concat(this.host,"/session")).then(function(n){return Si(n).catch(Ds)})}},{key:"getTree",value:function(n){var r=n.patch,o=r===void 0?!1:r,i=n.includeSchema,s=i===void 0?!1:i,a=n.includeSource,l=a===void 0?!1:a,c=n.treePath,u=c===void 0?"/":c,d=n.headers,f=new URLSearchParams;return f.set("patch",o.toString()),f.set("schema",s.toString()),f.set("source",l.toString()),fetch("".concat(this.host,"/tree/~").concat(u,"?").concat(f.toString()),{headers:d}).then(function(p){return Si(p)}).catch(Ds)}},{key:"postCommit",value:function(n){var r=n.patches,o=n.headers;return fetch("".concat(this.host,"/commit"),{method:"POST",body:JSON.stringify({patches:r}),headers:o||{"Content-Type":"application/json"}}).then(function(){var i=ol(Yn().mark(function s(a){var l;return Yn().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!a.ok){u.next=4;break}return u.abrupt("return",Si(a));case 4:if(!(a.status===400&&a.headers.get("content-type")==="application/json")){u.next=13;break}return u.next=7,a.json();case 7:if(l=u.sent,!("validationErrors"in l)){u.next=12;break}return u.abrupt("return",_t(l));case 12:return u.abrupt("return",YO(a.status,l,a.statusText));case 13:return u.abrupt("return",Si(a));case 14:case"end":return u.stop()}},s)}));return function(s){return i.apply(this,arguments)}}()).catch(Ds)}},{key:"postValidate",value:function(n){var r=n.patches,o=n.headers;return fetch("".concat(this.host,"/validate"),{method:"POST",body:JSON.stringify({patches:r}),headers:o||{"Content-Type":"application/json"}}).then(function(){var i=ol(Yn().mark(function s(a){return Yn().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.abrupt("return",Si(a));case 1:case"end":return c.stop()}},s)}));return function(s){return i.apply(this,arguments)}}()).catch(Ds)}}]),e}();function Ds(e){return _t({statusCode:500,message:e instanceof Error||ce(e)==="object"&&e&&"message"in e&&typeof e.message=="string"?e.message:"Unknown error",details:ce(e)==="object"&&e&&"details"in e?e.details:void 0})}function YO(e,t,n){return _t({statusCode:e,message:t.message||n,details:t.details||Object.fromEntries(Object.entries(t).filter(function(r){var o=Sn(r,1),i=o[0];return i!=="message"}))})}function Si(e){return Ly.apply(this,arguments)}function Ly(){return Ly=ol(Yn().mark(function e(t){var n;return Yn().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(o.prev=0,!t.ok){o.next=9;break}return o.t0=He,o.next=5,t.json();case 5:return o.t1=o.sent,o.abrupt("return",o.t0.ok.call(o.t0,o.t1));case 9:return o.prev=9,o.next=12,t.json();case 12:return n=o.sent,o.abrupt("return",YO(t.status,n,t.statusText));case 16:return o.prev=16,o.t2=o.catch(9),o.abrupt("return",_t({statusCode:t.status,message:t.statusText}));case 19:o.next=24;break;case 21:return o.prev=21,o.t3=o.catch(0),o.abrupt("return",_t({message:o.t3 instanceof Error?o.t3.message:"Unknown error"}));case 24:case"end":return o.stop()}},e,null,[[0,21],[9,16]])})),Ly.apply(this,arguments)}var Fe={VERSION:{core:function(){try{return require("../package.json").version}catch{return null}}()},convertFileSource:jO,getSchema:wD,getValPath:FO,getVal:ZD,getSource:AD,resolvePath:VD,splitModuleIdAndModulePath:ID,isVal:_D,createValPathOfItem:kr,getSHA256Hash:p3,initSchema:XD,notFileOp:function(t){return t.op!=="file"},isFileOp:function(t){return t.op==="file"&&typeof t.filePath=="string"},createPatchJSONPath:function(t){return"/".concat(t.split(".").map(function(n){return n&&h3(n)}).join("/"))},createPatchPath:function(t){return KO(t)},patchPathToModulePath:function(t){return t.map(function(n){return Number.isInteger(Number(n))?n:JSON.stringify(n)}).join(".")},VAL_ENABLE_COOKIE_NAME:"val_enable",VAL_STATE_COOKIE:"val_state",VAL_SESSION_COOKIE:"val_session"};function h3(e){try{return JSON.parse(e)}catch{return e}}var XO={exports:{}};/*!
44
44
  Copyright (c) 2018 Jed Watson.
45
45
  Licensed under the MIT License (MIT), see
46
46
  http://jedwatson.github.io/classnames
@@ -100,7 +100,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
100
100
  `}return Ot(Ot(Ot(Ot({},Gt,"richtext"),"templateStrings",n),"exprs",r),"files",t)}function Ak(e){var t,n=((t=e.marks)===null||t===void 0?void 0:t.flatMap(function(s){return s.type==="bold"?["bold"]:s.type==="italic"?["italic"]:s.type==="strike"?["line-through"]:[]}))||[],r=e.text.trimStart(),o=e.text.length-r.length;r=r.trimEnd();var i=e.text.length-r.length-o;return n.includes("bold")&&n.includes("italic")?r="***".concat(r,"***"):n.includes("bold")?r="**".concat(r,"**"):n.includes("italic")&&(r="_".concat(r,"_")),n.includes("line-through")&&(r="~~".concat(r,"~~")),"".concat(" ".repeat(o)).concat(r).concat(" ".repeat(i))}function e0(e,t){if(e.type==="text"){var n,r=(n=e.marks)===null||n===void 0?void 0:n.find(function(i){return i.type==="link"});return(r==null?void 0:r.type)==="link"?{_type:"link",href:r.attrs.href,children:[Ak(e)]}:Ak(e)}else{if(e.type==="hardBreak")return"<br />";if(e.type==="image")return Cj(e,t);var o=e;throw new Error("Unexpected node type: ".concat(JSON.stringify(o)))}}function s2(e,t,n,r){var o,i,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1,a=s?"":`
101
101
  `,l=["".concat(a).concat(" ".repeat(n)).concat(e)];return((o=t.content)===null||o===void 0||(o=o[0])===null||o===void 0?void 0:o.type)==="bulletList"||((i=t.content)===null||i===void 0||(i=i[0])===null||i===void 0?void 0:i.type)==="orderedList"||l.push(" "),l.concat((t.content||[]).flatMap(function(c,u){return c.type==="bulletList"||c.type==="orderedList"?(c.content||[]).flatMap(function(d){return s2(a2(c),d,n+4,r)}):(c.content||[]).flatMap(function(d){var f,p,h=[];return(f=c.content)!==null&&f!==void 0&&f.length&&((p=c.content)===null||p===void 0?void 0:p.length)>0&&u>0&&h.push(`<br />
102
102
  `),h.push(e0(d,r)),h})}))}function a2(e){if(e.type==="bulletList")return"-";if(e.type==="orderedList")return"1.";var t=e;throw new Error("Unhandled list node: ".concat(JSON.stringify(t)))}var _j=new TextEncoder;function Cj(e,t){if(e.attrs&&e.attrs.src.startsWith("data:")){var n=Fe.getSHA256Hash(_j.encode(e.attrs.src)),r=Dm(e.attrs.src);if(r===void 0)throw new Error("Could not detect Mime Type for image: ".concat(e.attrs.src));var o=Lm(r),i=e.attrs.fileName||"".concat(n,".").concat(o),s="/public/".concat(i);return t[s]=e.attrs.src,Ot(Ot(Ot(Ot({},Gt,"file"),rn,s),ik,lk),"metadata",{width:typeof e.attrs.width=="number"?e.attrs.width:0,height:typeof e.attrs.height=="number"?e.attrs.height:0,sha256:n||"",mimeType:r})}else if(e.attrs){var a=Oj("sha256",e.attrs.src),l=e.attrs.src.split("?")[0];return Ot(Ot(Ot(Ot({},Gt,"file"),rn,"/public".concat(e.attrs.src.split("?")[0])),ik,lk),"metadata",{width:typeof e.attrs.width=="number"?e.attrs.width:0,height:typeof e.attrs.height=="number"?e.attrs.height:0,sha256:a||"",mimeType:l&&wj(l)||""})}else throw new Error("Invalid image node (no attrs): "+JSON.stringify(e))}function Oj(e,t){var n=t.split("?");if(!(n.length<2)){var r=n[1],o=new URLSearchParams(r);if(o.has(e))return o.get(e)}}var vh='<val value="',t0='">',n0="</val>";function Vo(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,o=[];function i(l,c){var u=Vo(l.tokens?l.tokens:[],t,0);o.push({tag:"span",classes:[c].concat(u.children.flatMap(function(d){return typeof d=="string"?[]:d.classes})),children:u.children.flatMap(function(d){return typeof d=="string"?d:d.children})})}for(var s=function(){var c=e[n];if(c.type==="heading")o.push({tag:"h".concat(c.depth),children:Vo(c.tokens?c.tokens:[],t,0).children});else if(c.type==="paragraph")o.push({tag:"p",children:Vo(c.tokens?c.tokens:[],t,0).children});else if(c.type==="strong")i(c,"bold");else if(c.type==="em")i(c,"italic");else if(c.type==="del")i(c,"line-through");else if(c.type==="text")if("tokens"in c&&Array.isArray(c.tokens))o.push.apply(o,yd(Vo(c.tokens,t,n,r).children));else if(r&&typeof c.raw=="string"){var u=c.raw.split(`
103
- `),d=u.flatMap(function(E,P){return P===u.length-1?[E]:P===u.length-1&&E===""?[]:E===""?{tag:"br"}:[E,{tag:"br"}]});o.push.apply(o,yd(d))}else o.push(c.raw);else if(c.type==="list")o.push({tag:c.ordered?"ol":"ul",children:Vo(c.items,t,0).children});else if(c.type==="list_item")o.push({tag:"li",children:Vo(c.tokens?c.tokens:[],t,0,!0).children});else if(c.type!=="space")if(c.type==="html"){if(c.text===n0)return{v:{children:o,cursor:n}};var f=c.text.indexOf(t0);if(c.text.startsWith(vh)&&f>-1){var p=Number(c.text.slice(vh.length,f));if(Number.isNaN(p))throw Error("Illegal val intermediate node: ".concat(JSON.stringify(c)));var h=Vo(e.map(function(E){return E.type==="link"||E.type==="list"?{type:"text",raw:E.raw,text:E.raw}:E}),t,n+1),g=h.children,b=h.cursor,y=t[p];if(y._type==="link")o.push({tag:"a",href:y.href,children:g});else if(y._type==="file"){var x,w,k;o.push({tag:"img",src:Fe.convertFileSource(y).url,width:(x=y.metadata)===null||x===void 0?void 0:x.width,height:(w=y.metadata)===null||w===void 0?void 0:w.height,mimeType:(k=y.metadata)===null||k===void 0?void 0:k.mimeType})}n=b}var S=/<br\s*\/?>/gi;if(c.text.trim().match(S)){var O;o.push({tag:"br"}),((O=e[n+1])===null||O===void 0?void 0:O.raw.trim())===""&&n++}}else c.type==="link"?c.raw===c.href?o.push(c.raw):o.push({tag:"a",href:c.href,children:Vo(c.tokens?c.tokens:[],t,0).children}):c.type==="br"?o.push({tag:"br"}):console.error("Could not parse markdown: unsupported token type: ".concat(c.type,". Found: ").concat(c.raw));n++},a;n<e.length;)if(a=s(),a)return a.v;return{children:o,cursor:n}}function l2(e){var t=e.templateStrings,n=e.exprs,r=t.flatMap(function(l,c){var u=n[c];return u?u[Gt]==="link"?l.concat("".concat(vh).concat(c).concat(t0).concat(u.children[0]).concat(n0)):l.concat("".concat(vh).concat(c).concat(t0).concat(n0)):l}).join(""),o=rj(r,{gfm:!0}),i=Vo(o,n,0),s=i.children,a=i.cursor;if(a!==o.length)throw Error("Unexpectedly terminated markdown parsing. Possible reason: unclosed html tag?");return Ot(Ot({},Gt,"richtext"),"children",s)}var c2=I.object({type:I.union([I.literal("bold"),I.literal("strike"),I.literal("italic")])}),Tj=I.object({type:I.literal("link"),attrs:I.object({href:I.string(),target:I.union([I.literal("_blank"),I.null()]),auto:I.boolean()})}),u2=I.intersection(I.object({type:I.literal("text"),text:I.string()}),I.object({marks:I.array(I.union([c2,Tj]))}).partial()),d2=I.intersection(I.object({type:I.literal("hardBreak")}),I.object({marks:I.array(c2)}).partial()),Pj=I.intersection(I.object({type:I.literal("image")}),I.object({attrs:I.intersection(I.object({src:I.string()}),I.object({align:I.union([I.literal("center"),I.literal("end"),I.literal("justify"),I.literal("left"),I.literal("match-parent"),I.literal("right"),I.literal("start"),I.null()]),alt:I.union([I.string(),I.null()]),height:I.union([I.string(),I.number(),I.null()]),width:I.union([I.string(),I.number(),I.null()]),rotate:I.union([I.string(),I.null()]),title:I.union([I.string(),I.null()]),fileName:I.union([I.string(),I.null()])}).partial())}).partial()),Mj=I.intersection(I.object({type:I.literal("heading")}),I.object({attrs:I.object({level:I.number()}),content:I.array(I.union([u2,d2]))}).partial()),f2=I.lazy(function(){return I.intersection(I.object({type:I.literal("bulletList")}),I.object({content:I.array(h2)}).partial())}),p2=I.lazy(function(){return I.intersection(I.object({type:I.literal("orderedList")}),I.object({content:I.array(h2)}).partial())}),h2=I.lazy(function(){return I.intersection(I.object({type:I.literal("listItem")}),I.object({content:I.array(I.union([m2,f2,p2]))}).partial())}),m2=I.intersection(I.object({type:I.literal("paragraph")}),I.object({content:I.array(I.union([u2,Pj,d2]))}).partial()),Nj=I.object({type:I.literal("doc"),content:I.array(I.union([m2,Mj,f2,p2]))});function Ik(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function yh(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ik(Object(n),!0).forEach(function(r){Ot(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ik(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Rj(e){return{type:"doc",content:e.children.map(function(t){return $j(t)})}}function $j(e){switch(e.tag){case"h1":return qa(1,e.children);case"h2":return qa(2,e.children);case"h3":return qa(3,e.children);case"h4":return qa(4,e.children);case"h5":return qa(5,e.children);case"h6":return qa(6,e.children);case"p":return Dk(e.children);case"ul":return y2(e);case"ol":return x2(e);case"br":return Dk([e]);default:{var t=e;throw Error("Unexpected child node: "+JSON.stringify(t))}}}function qa(e,t){return{type:"heading",attrs:{level:e},content:t.flatMap(g2)}}function jm(e){return{type:"text",text:e}}function g2(e){return typeof e=="string"?[jm(e)]:y1(e)}function y1(e){if(e.classes.length===0&&e.children.length===1){if(typeof e.children[0]=="string")return[jm(e.children[0])];throw Error("Unexpected amount of children in span node: "+JSON.stringify(e,null,2))}return e.children.map(function(t){return{type:"text",text:t,marks:e.classes.map(function(n){switch(n){case"bold":return{type:"bold"};case"italic":return{type:"italic"};case"line-through":return{type:"strike"};default:{var r=n;throw Error("Unexpected span class: "+r)}}})}})}function Dk(e){return{type:"paragraph",content:e.flatMap(function(t){if(typeof t=="string")return[jm(t)];switch(t.tag){case"span":return y1(t);case"a":return v2(t);case"img":return[Ij(t)];case"br":return[Aj()];default:{var n=t;throw Error("Unexpected paragraph child: "+JSON.stringify(n))}}})}}function Aj(){return{type:"hardBreak",marks:[]}}function v2(e){return e.children.flatMap(g2).map(function(t){return yh(yh({},t),{},{marks:(t.marks||[]).concat({type:"link",attrs:{href:e.href,auto:!1,target:null}})})})}function Ij(e){return{type:"image",attrs:{height:e.height,width:e.width,src:e.src}}}function y2(e){return{type:"bulletList",content:e.children.map(b2)}}function x2(e){return{type:"orderedList",content:e.children.map(b2)}}function b2(e){return{type:"listItem",content:Dj(e.children)}}function Dj(e){var t=[],n=v1(e),r;try{for(n.s();!(r=n.n()).done;){var o=r.value,i=t[t.length-1];i||(i={type:"paragraph",content:[]},t.push(i));var s=i.content;if(typeof o=="string")s.push(jm(o));else switch(o.tag){case"a":{s.push.apply(s,yd(v2(o)));break}case"br":{t.push({type:"paragraph",content:[]});break}case"span":{s.push.apply(s,yd(y1(o)));break}case"ol":{t.push(x2(o));break}case"ul":{t.push(y2(o));break}default:{var a=o;throw Error("Unexpected list item child: "+JSON.stringify(a))}}}}catch(l){n.e(l)}finally{n.f()}return t}function gn(){gn=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(_,T,C){_[T]=C.value},i=typeof Symbol=="function"?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function c(_,T,C){return Object.defineProperty(_,T,{value:C,enumerable:!0,configurable:!0,writable:!0}),_[T]}try{c({},"")}catch{c=function(T,C,M){return T[C]=M}}function u(_,T,C,M){var R=T&&T.prototype instanceof y?T:y,L=Object.create(R.prototype),G=new U(M||[]);return o(L,"_invoke",{value:$(_,C,G)}),L}function d(_,T,C){try{return{type:"normal",arg:_.call(T,C)}}catch(M){return{type:"throw",arg:M}}}t.wrap=u;var f="suspendedStart",p="suspendedYield",h="executing",g="completed",b={};function y(){}function x(){}function w(){}var k={};c(k,s,function(){return this});var S=Object.getPrototypeOf,O=S&&S(S(K([])));O&&O!==n&&r.call(O,s)&&(k=O);var E=w.prototype=y.prototype=Object.create(k);function P(_){["next","throw","return"].forEach(function(T){c(_,T,function(C){return this._invoke(T,C)})})}function N(_,T){function C(R,L,G,ve){var me=d(_[R],_,L);if(me.type!=="throw"){var Be=me.arg,Te=Be.value;return Te&&typeof Te=="object"&&r.call(Te,"__await")?T.resolve(Te.__await).then(function(J){C("next",J,G,ve)},function(J){C("throw",J,G,ve)}):T.resolve(Te).then(function(J){Be.value=J,G(Be)},function(J){return C("throw",J,G,ve)})}ve(me.arg)}var M;o(this,"_invoke",{value:function(R,L){function G(){return new T(function(ve,me){C(R,L,ve,me)})}return M=M?M.then(G,G):G()}})}function $(_,T,C){var M=f;return function(R,L){if(M===h)throw new Error("Generator is already running");if(M===g){if(R==="throw")throw L;return{value:e,done:!0}}for(C.method=R,C.arg=L;;){var G=C.delegate;if(G){var ve=z(G,C);if(ve){if(ve===b)continue;return ve}}if(C.method==="next")C.sent=C._sent=C.arg;else if(C.method==="throw"){if(M===f)throw M=g,C.arg;C.dispatchException(C.arg)}else C.method==="return"&&C.abrupt("return",C.arg);M=h;var me=d(_,T,C);if(me.type==="normal"){if(M=C.done?g:p,me.arg===b)continue;return{value:me.arg,done:C.done}}me.type==="throw"&&(M=g,C.method="throw",C.arg=me.arg)}}}function z(_,T){var C=T.method,M=_.iterator[C];if(M===e)return T.delegate=null,C==="throw"&&_.iterator.return&&(T.method="return",T.arg=e,z(_,T),T.method==="throw")||C!=="return"&&(T.method="throw",T.arg=new TypeError("The iterator does not provide a '"+C+"' method")),b;var R=d(M,_.iterator,T.arg);if(R.type==="throw")return T.method="throw",T.arg=R.arg,T.delegate=null,b;var L=R.arg;return L?L.done?(T[_.resultName]=L.value,T.next=_.nextLoc,T.method!=="return"&&(T.method="next",T.arg=e),T.delegate=null,b):L:(T.method="throw",T.arg=new TypeError("iterator result is not an object"),T.delegate=null,b)}function j(_){var T={tryLoc:_[0]};1 in _&&(T.catchLoc=_[1]),2 in _&&(T.finallyLoc=_[2],T.afterLoc=_[3]),this.tryEntries.push(T)}function le(_){var T=_.completion||{};T.type="normal",delete T.arg,_.completion=T}function U(_){this.tryEntries=[{tryLoc:"root"}],_.forEach(j,this),this.reset(!0)}function K(_){if(_||_===""){var T=_[s];if(T)return T.call(_);if(typeof _.next=="function")return _;if(!isNaN(_.length)){var C=-1,M=function R(){for(;++C<_.length;)if(r.call(_,C))return R.value=_[C],R.done=!1,R;return R.value=e,R.done=!0,R};return M.next=M}}throw new TypeError(typeof _+" is not iterable")}return x.prototype=w,o(E,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:x,configurable:!0}),x.displayName=c(w,l,"GeneratorFunction"),t.isGeneratorFunction=function(_){var T=typeof _=="function"&&_.constructor;return!!T&&(T===x||(T.displayName||T.name)==="GeneratorFunction")},t.mark=function(_){return Object.setPrototypeOf?Object.setPrototypeOf(_,w):(_.__proto__=w,c(_,l,"GeneratorFunction")),_.prototype=Object.create(E),_},t.awrap=function(_){return{__await:_}},P(N.prototype),c(N.prototype,a,function(){return this}),t.AsyncIterator=N,t.async=function(_,T,C,M,R){R===void 0&&(R=Promise);var L=new N(u(_,T,C,M),R);return t.isGeneratorFunction(T)?L:L.next().then(function(G){return G.done?G.value:L.next()})},P(E),c(E,l,"Generator"),c(E,s,function(){return this}),c(E,"toString",function(){return"[object Generator]"}),t.keys=function(_){var T=Object(_),C=[];for(var M in T)C.push(M);return C.reverse(),function R(){for(;C.length;){var L=C.pop();if(L in T)return R.value=L,R.done=!1,R}return R.done=!0,R}},t.values=K,U.prototype={constructor:U,reset:function(_){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(le),!_)for(var T in this)T.charAt(0)==="t"&&r.call(this,T)&&!isNaN(+T.slice(1))&&(this[T]=e)},stop:function(){this.done=!0;var _=this.tryEntries[0].completion;if(_.type==="throw")throw _.arg;return this.rval},dispatchException:function(_){if(this.done)throw _;var T=this;function C(me,Be){return L.type="throw",L.arg=_,T.next=me,Be&&(T.method="next",T.arg=e),!!Be}for(var M=this.tryEntries.length-1;M>=0;--M){var R=this.tryEntries[M],L=R.completion;if(R.tryLoc==="root")return C("end");if(R.tryLoc<=this.prev){var G=r.call(R,"catchLoc"),ve=r.call(R,"finallyLoc");if(G&&ve){if(this.prev<R.catchLoc)return C(R.catchLoc,!0);if(this.prev<R.finallyLoc)return C(R.finallyLoc)}else if(G){if(this.prev<R.catchLoc)return C(R.catchLoc,!0)}else{if(!ve)throw new Error("try statement without catch or finally");if(this.prev<R.finallyLoc)return C(R.finallyLoc)}}}},abrupt:function(_,T){for(var C=this.tryEntries.length-1;C>=0;--C){var M=this.tryEntries[C];if(M.tryLoc<=this.prev&&r.call(M,"finallyLoc")&&this.prev<M.finallyLoc){var R=M;break}}R&&(_==="break"||_==="continue")&&R.tryLoc<=T&&T<=R.finallyLoc&&(R=null);var L=R?R.completion:{};return L.type=_,L.arg=T,R?(this.method="next",this.next=R.finallyLoc,b):this.complete(L)},complete:function(_,T){if(_.type==="throw")throw _.arg;return _.type==="break"||_.type==="continue"?this.next=_.arg:_.type==="return"?(this.rval=this.arg=_.arg,this.method="return",this.next="end"):_.type==="normal"&&T&&(this.next=T),b},finish:function(_){for(var T=this.tryEntries.length-1;T>=0;--T){var C=this.tryEntries[T];if(C.finallyLoc===_)return this.complete(C.completion,C.afterLoc),le(C),b}},catch:function(_){for(var T=this.tryEntries.length-1;T>=0;--T){var C=this.tryEntries[T];if(C.tryLoc===_){var M=C.completion;if(M.type==="throw"){var R=M.arg;le(C)}return R}}throw new Error("illegal catch attempt")},delegateYield:function(_,T,C){return this.delegate={iterator:K(_),resultName:T,nextLoc:C},this.method==="next"&&(this.arg=e),b}},t}function Lk(e,t,n,r,o,i,s){try{var a=e[i](s),l=a.value}catch(c){n(c);return}a.done?t(l):Promise.resolve(l).then(r,o)}function Ga(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function s(l){Lk(i,r,o,s,a,"next",l)}function a(l){Lk(i,r,o,s,a,"throw",l)}s(void 0)})}}function Lj(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function jk(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,o2(r.key),r)}}function jj(e,t,n){return t&&jk(e.prototype,t),n&&jk(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var zj=new cj,x1=function(){function e(t){var n=this;Lj(this,e),Ot(this,"subscribe",function(r){return function(o){var i=zk(r);return n.listeners[i]||(n.listeners[i]=[],n.subscribers.set(i,{})),n.listeners[i].push(o),function(){n.listeners[i].splice(n.listeners[i].indexOf(o),1)}}}),Ot(this,"getSnapshot",function(r){return function(){return n.get(r)}}),Ot(this,"getServerSnapshot",function(r){return function(){return n.get(r)}}),Ot(this,"get",function(r){var o=zk(r);return n.subscribers.get(o)}),this.api=t,this.subscribers=new Map,this.listeners={},this.drafts={},this.schema={}}return jj(e,[{key:"getModule",value:function(){var t=Ga(gn().mark(function r(o){var i,s,a,l,c=arguments;return gn().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(i=c.length>1&&c[1]!==void 0?c[1]:!1,!(!i&&this.drafts[o]&&this.schema[o])){d.next=3;break}return d.abrupt("return",He.ok({source:this.drafts[o],schema:this.schema[o]}));case 3:return d.next=5,this.api.getTree({patch:!0,treePath:o,includeSource:!0,includeSchema:!0});case 5:if(s=d.sent,!He.isOk(s)){d.next=22;break}if(s.value.modules[o]){d.next=10;break}return console.error("Val: could not find the module",{moduleIds:Object.keys(s.value.modules),moduleId:o,data:s}),d.abrupt("return",He.err({message:"Could not fetch data. Could not find the module: "+o+". Verify that the module id and file name is correct."}));case 10:if(a=s.value.modules[o].source,l=s.value.modules[o].schema,!(a!==void 0&&l!==void 0)){d.next=18;break}return this.drafts[o]=a,this.schema[o]=l,d.abrupt("return",He.ok({source:a,schema:l}));case 18:return console.error("Val: could not find the module source"),d.abrupt("return",He.err({message:"Could not fetch data. Verify that the module exists."}));case 20:d.next=29;break;case 22:if(s.error.statusCode!==504){d.next=27;break}return console.error("Val: timeout",s.error),d.abrupt("return",He.err({message:"Timed out while fetching data. Try again later."}));case 27:return console.error("Val: failed to get module",s.error),d.abrupt("return",He.err({message:"Could not fetch data. Verify that Val is correctly configured."}));case 29:case"end":return d.stop()}},r,this)}));function n(r){return t.apply(this,arguments)}return n}()},{key:"applyPatch",value:function(){var t=Ga(gn().mark(function r(o,i){var s,a,l,c,u,d,f,p,h,g,b,y;return gn().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(s=this.drafts[o],a=this.schema[o],!(!s||!a)){w.next=21;break}return w.next=5,this.api.getTree({patch:!0,treePath:o,includeSource:!0,includeSchema:!0});case 5:if(l=w.sent,!He.isOk(l)){w.next=19;break}if(c=l.value.modules[o].source,u=l.value.modules[o].schema,!(c!==void 0&&u!==void 0)){w.next=15;break}s=c,this.drafts[o]=c,this.schema[o]=u,w.next=17;break;case 15:return console.error("Val: could not find the module source"),w.abrupt("return",He.err({message:"Val: could not fetch data. Verify that the module exists."}));case 17:w.next=21;break;case 19:return console.error("Val: failed to get module",l.error),w.abrupt("return",He.err({message:"Val: could not fetch data. Verify that Val is correctly configured."}));case 21:return w.next=23,this.api.postPatches(o,i);case 23:if(d=w.sent,!He.isErr(d)){w.next=27;break}return console.error("Val: failed to post patch",d.error),w.abrupt("return",d);case 27:if(f=dj(s,zj,i.filter(Fe.notFileOp)),!He.isOk(f)){w.next=35;break}for(this.drafts[o]=f.value,this.emitEvent(o,f.value),p=0,h=Array.from(this.subscribers.entries());p<h.length;p++)g=Qy(h[p],2),b=g[0],y=g[1],y[o]&&(this.subscribers.set(b,yh(yh({},y),{},Ot({},o,this.drafts[o]))),this.emitChange(b));return w.abrupt("return",d);case 35:return console.error("Val: failed to apply patch",f.error),w.abrupt("return",f);case 37:case"end":return w.stop()}},r,this)}));function n(r,o){return t.apply(this,arguments)}return n}()},{key:"emitEvent",value:function(n,r){var o=new CustomEvent("val-event",{detail:{type:"module-update",moduleId:n,source:r}});window.dispatchEvent(o)}},{key:"update",value:function(){var t=Ga(gn().mark(function r(o){var i=this;return gn().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,Promise.all(o.map(function(l){return i.updateTree(l)}));case 2:case"end":return a.stop()}},r)}));function n(r){return t.apply(this,arguments)}return n}()},{key:"reset",value:function(){var t=Ga(gn().mark(function r(){return gn().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.abrupt("return",this.updateTree());case 1:case"end":return i.stop()}},r,this)}));function n(){return t.apply(this,arguments)}return n}()},{key:"initialize",value:function(){var t=Ga(gn().mark(function r(){var o,i,s,a,l,c,u;return gn().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this.api.getTree({patch:!1,includeSource:!1,includeSchema:!0});case 2:if(o=f.sent,!He.isOk(o)){f.next=9;break}for(i=[],s=0,a=Object.keys(o.value.modules);s<a.length;s++)l=a[s],c=o.value.modules[l].schema,c&&(i.push(l),this.schema[l]=c);return f.abrupt("return",He.ok(i));case 9:return u="Failed to fetch content. ",o.error.statusCode===401?u+="Authorization failed - check that you are logged in.":u+="Get a developer to verify that Val is correctly setup.",f.abrupt("return",He.err({message:u,details:{fetchError:o.error}}));case 12:case"end":return f.stop()}},r,this)}));function n(){return t.apply(this,arguments)}return n}()},{key:"updateTree",value:function(){var t=Ga(gn().mark(function r(o){var i=this,s,a,l,c,u,d,f,p,h,g,b,y,x,w;return gn().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this.api.getTree({patch:!0,treePath:o,includeSource:!0,includeSchema:!0});case 2:if(s=S.sent,a=[],!He.isOk(s)){S.next=18;break}l=new Map,c=Array.from(this.subscribers.keys()),u=gn().mark(function O(){var E,P,N;return gn().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:E=f[d],P=s.value.modules[E].source,typeof P<"u"&&(a.push(E),i.emitEvent(E,P),N=c.find(function(j){return j.includes(E)}),N&&l.set(N,(l.get(N)||[]).concat(E)));case 3:case"end":return z.stop()}},O)}),d=0,f=Object.keys(s.value.modules);case 9:if(!(d<f.length)){S.next=14;break}return S.delegateYield(u(),"t0",11);case 11:d++,S.next=9;break;case 14:for(p=0,h=Array.from(l.entries());p<h.length;p++)g=Qy(h[p],2),b=g[0],y=g[1],x=Object.fromEntries(y.flatMap(function(O){var E=s.value.modules[O].source;return E?[[O,E]]:[]})),this.subscribers.set(b,x),this.emitChange(b);return S.abrupt("return",He.ok(a));case 18:return w="Failed to fetch content. ",s.error.statusCode===401?w+="Authorization failed - check that you are logged in.":w+="Get a developer to verify that Val is correctly setup.",S.abrupt("return",He.err({message:w,details:{fetchError:s.error}}));case 21:case"end":return S.stop()}},r,this)}));function n(r){return t.apply(this,arguments)}return n}()},{key:"emitChange",value:function(n){var r=v1(this.listeners[n]),o;try{for(r.s();!(o=r.n()).done;){var i=o.value;i()}}catch(s){r.e(s)}finally{r.f()}}}]),e}();function zk(e){return e.slice().sort().join("&")}const Fj=new TextEncoder;function w2(e){return new Promise((t,n)=>{var i;const r=(i=e.currentTarget.files)==null?void 0:i[0],o=new FileReader;o.addEventListener("load",()=>{const s=o.result;if(typeof s=="string"){const a=new Image;a.addEventListener("load",()=>{const l=Fe.getSHA256Hash(Fj.encode(s));if(a.naturalWidth&&a.naturalHeight){const c=Dm(s);t({src:s,width:a.naturalWidth,height:a.naturalHeight,filename:r==null?void 0:r.name,sha256:l,mimeType:c,fileExt:c&&Lm(c)})}else t({src:s,filename:r==null?void 0:r.name,sha256:l})}),a.src=s}else n(s?{message:"Unexpected image result type",result:s}:{message:"Empty result"})}),r&&o.readAsDataURL(r)})}function k2(e,t,n){if(!n||!e)return t;const r=n.sha256.slice(0,5),o=Dm(e)??"unknown",i=Lm(o)??"unknown";if(t){let s=t.split(".").slice(0,-1).join(".")||t;const a=s.lastIndexOf("_");return s.slice(a+1,s.length)===r&&(s=s.slice(0,a)),`${encodeURIComponent(s).replace(/%[0-9A-Fa-f]{2}/g,"").toLowerCase()}_${r}.${i}`}return`${n.sha256}.${i}`}const b1=m.forwardRef(({className:e,type:t,...n},r)=>v.jsx("input",{type:t,className:Me("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));b1.displayName="Input";let zm=()=>({events:{},emit(e,...t){(this.events[e]||[]).forEach(n=>n(...t))},on(e,t){return(this.events[e]=this.events[e]||[]).push(t),()=>this.events[e]=(this.events[e]||[]).filter(n=>n!==t)}});var r0={exports:{}};(function(e,t){var n=typeof Reflect<"u"?Reflect.construct:void 0,r=Object.defineProperty,o=Error.captureStackTrace;o===void 0&&(o=function(c){var u=new Error;r(c,"stack",{configurable:!0,get:function(){var f=u.stack;return r(this,"stack",{configurable:!0,value:f,writable:!0}),f},set:function(f){r(c,"stack",{configurable:!0,value:f,writable:!0})}})});function i(l){l!==void 0&&r(this,"message",{configurable:!0,value:l,writable:!0});var c=this.constructor.name;c!==void 0&&c!==this.name&&r(this,"name",{configurable:!0,value:c,writable:!0}),o(this,this.constructor)}i.prototype=Object.create(Error.prototype,{constructor:{configurable:!0,value:i,writable:!0}});var s=function(){function l(u,d){return r(u,"name",{configurable:!0,value:d})}try{var c=function(){};if(l(c,"foo"),c.name==="foo")return l}catch{}}();function a(l,c){if(c==null||c===Error)c=i;else if(typeof c!="function")throw new TypeError("super_ should be a function");var u;if(typeof l=="string")u=l,l=n!==void 0?function(){return n(c,arguments,this.constructor)}:function(){c.apply(this,arguments)},s!==void 0&&(s(l,u),u=void 0);else if(typeof l!="function")throw new TypeError("constructor should be either a string or a function");l.super_=l.super=c;var d={constructor:{configurable:!0,value:l,writable:!0}};return u!==void 0&&(d.name={configurable:!0,value:u,writable:!0}),l.prototype=Object.create(c.prototype,d),l}t=e.exports=a,t.BaseError=i})(r0,r0.exports);var S2=r0.exports,Fk="ProseMirror-selectednode",E2="",Xi="\0",Bk="__state_override__",Bj={LastNodeCompatible:"lastNodeCompatible",FormattingMark:"formattingMark",FormattingNode:"formattingNode",NodeCursor:"nodeCursor",FontStyle:"fontStyle",Link:"link",Color:"color",Alignment:"alignment",Indentation:"indentation",Behavior:"behavior",Code:"code",InlineNode:"inline",ListContainerNode:"listContainer",ListItemNode:"listItemNode",Block:"block",BlockNode:"block",TextBlock:"textBlock",ExcludeInputRules:"excludeFromInputRules",PreventExits:"preventsExits",Media:"media"},Ce=Bj,di=Symbol.for("__remirror__"),Yt=(e=>(e.PlainExtension="RemirrorPlainExtension",e.NodeExtension="RemirrorNodeExtension",e.MarkExtension="RemirrorMarkExtension",e.PlainExtensionConstructor="RemirrorPlainExtensionConstructor",e.NodeExtensionConstructor="RemirrorNodeExtensionConstructor",e.MarkExtensionConstructor="RemirrorMarkExtensionConstructor",e.Manager="RemirrorManager",e.Preset="RemirrorPreset",e.PresetConstructor="RemirrorPresetConstructor",e))(Yt||{}),qe=(e=>(e[e.Critical=1e6]="Critical",e[e.Highest=1e5]="Highest",e[e.High=1e4]="High",e[e.Medium=1e3]="Medium",e[e.Default=100]="Default",e[e.Low=10]="Low",e[e.Lowest=0]="Lowest",e))(qe||{}),An=(e=>(e[e.None=0]="None",e[e.Create=1]="Create",e[e.EditorView=2]="EditorView",e[e.Runtime=3]="Runtime",e[e.Destroy=4]="Destroy",e))(An||{}),H=(e=>(e.Undo="_|undo|_",e.Redo="_|redo|_",e.Bold="_|bold|_",e.Italic="_|italic|_",e.Underline="_|underline|_",e.Strike="_|strike|_",e.Code="_|code|_",e.Paragraph="_|paragraph|_",e.H1="_|h1|_",e.H2="_|h2|_",e.H3="_|h3|_",e.H4="_|h4|_",e.H5="_|h5|_",e.H6="_|h6|_",e.TaskList="_|task|_",e.BulletList="_|bullet|_",e.OrderedList="_|number|_",e.Quote="_|quote|_",e.Divider="_|divider|_",e.Codeblock="_|codeblock|_",e.ClearFormatting="_|clear|_",e.Superscript="_|sup|_",e.Subscript="_|sub|_",e.LeftAlignment="_|left-align|_",e.CenterAlignment="_|center-align|_",e.RightAlignment="_|right-align|_",e.JustifyAlignment="_|justify-align|_",e.InsertLink="_|link|_",e.Find="_|find|_",e.FindBackwards="_|find-backwards|_",e.FindReplace="_|find-replace|_",e.AddFootnote="_|footnote|_",e.AddComment="_|comment|_",e.ContextMenu="_|context-menu|_",e.IncreaseFontSize="_|inc-font-size|_",e.DecreaseFontSize="_|dec-font-size|_",e.IncreaseIndent="_|indent|_",e.DecreaseIndent="_|dedent|_",e.Shortcuts="_|shortcuts|_",e.Copy="_|copy|_",e.Cut="_|cut|_",e.Paste="_|paste|_",e.PastePlain="_|paste-plain|_",e.SelectAll="_|select-all|_",e.Format="_|format|_",e))(H||{}),V=(e=>(e.PROD="RMR0000",e.UNKNOWN="RMR0001",e.INVALID_COMMAND_ARGUMENTS="RMR0002",e.CUSTOM="RMR0003",e.CORE_HELPERS="RMR0004",e.MUTATION="RMR0005",e.INTERNAL="RMR0006",e.MISSING_REQUIRED_EXTENSION="RMR0007",e.MANAGER_PHASE_ERROR="RMR0008",e.INVALID_GET_EXTENSION="RMR0010",e.INVALID_MANAGER_ARGUMENTS="RMR0011",e.SCHEMA="RMR0012",e.HELPERS_CALLED_IN_OUTER_SCOPE="RMR0013",e.INVALID_MANAGER_EXTENSION="RMR0014",e.DUPLICATE_COMMAND_NAMES="RMR0016",e.DUPLICATE_HELPER_NAMES="RMR0017",e.NON_CHAINABLE_COMMAND="RMR0018",e.INVALID_EXTENSION="RMR0019",e.INVALID_CONTENT="RMR0021",e.INVALID_NAME="RMR0050",e.EXTENSION="RMR0100",e.EXTENSION_SPEC="RMR0101",e.EXTENSION_EXTRA_ATTRIBUTES="RMR0102",e.INVALID_SET_EXTENSION_OPTIONS="RMR0103",e.REACT_PROVIDER_CONTEXT="RMR0200",e.REACT_GET_ROOT_PROPS="RMR0201",e.REACT_EDITOR_VIEW="RMR0202",e.REACT_CONTROLLED="RMR0203",e.REACT_NODE_VIEW="RMR0204",e.REACT_GET_CONTEXT="RMR0205",e.REACT_COMPONENTS="RMR0206",e.REACT_HOOKS="RMR0207",e.I18N_CONTEXT="RMR0300",e))(V||{}),Vj=function(t){return Uj(t)&&!Hj(t)};function Uj(e){return!!e&&typeof e=="object"}function Hj(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||qj(e)}var Wj=typeof Symbol=="function"&&Symbol.for,Kj=Wj?Symbol.for("react.element"):60103;function qj(e){return e.$$typeof===Kj}function Gj(e){return Array.isArray(e)?[]:{}}function xd(e,t){return t.clone!==!1&&t.isMergeableObject(e)?tc(Gj(e),e,t):e}function Yj(e,t,n){return e.concat(t).map(function(r){return xd(r,n)})}function Xj(e,t){if(!t.customMerge)return tc;var n=t.customMerge(e);return typeof n=="function"?n:tc}function Zj(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function Vk(e){return Object.keys(e).concat(Zj(e))}function _2(e,t){try{return t in e}catch{return!1}}function Jj(e,t){return _2(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function Qj(e,t,n){var r={};return n.isMergeableObject(e)&&Vk(e).forEach(function(o){r[o]=xd(e[o],n)}),Vk(t).forEach(function(o){Jj(e,o)||(_2(e,o)&&n.isMergeableObject(t[o])?r[o]=Xj(o,n)(e[o],t[o],n):r[o]=xd(t[o],n))}),r}function tc(e,t,n){n=n||{},n.arrayMerge=n.arrayMerge||Yj,n.isMergeableObject=n.isMergeableObject||Vj,n.cloneUnlessOtherwiseSpecified=xd;var r=Array.isArray(t),o=Array.isArray(e),i=r===o;return i?r?n.arrayMerge(e,t,n):Qj(e,t,n):xd(t,n)}tc.all=function(t,n){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(r,o){return tc(r,o,n)},{})};var e6=tc,t6=e6;const n6=Ao(t6);/*!
103
+ `),d=u.flatMap(function(E,P){return P===u.length-1?[E]:P===u.length-1&&E===""?[]:E===""?{tag:"br"}:[E,{tag:"br"}]});o.push.apply(o,yd(d))}else o.push(c.raw);else if(c.type==="list")o.push({tag:c.ordered?"ol":"ul",children:Vo(c.items,t,0).children});else if(c.type==="list_item")o.push({tag:"li",children:Vo(c.tokens?c.tokens:[],t,0,!0).children});else if(c.type!=="space")if(c.type==="html"){if(c.text===n0)return{v:{children:o,cursor:n}};var f=c.text.indexOf(t0);if(c.text.startsWith(vh)&&f>-1){var p=Number(c.text.slice(vh.length,f));if(Number.isNaN(p))throw Error("Illegal val intermediate node: ".concat(JSON.stringify(c)));var h=Vo(e.map(function(E){return E.type==="link"||E.type==="list"?{type:"text",raw:E.raw,text:E.raw}:E}),t,n+1),g=h.children,b=h.cursor,y=t[p];if(y._type==="link")o.push({tag:"a",href:y.href,children:g});else if(y._type==="file"){var x,w,k;o.push({tag:"img",src:Fe.convertFileSource(y).url,width:(x=y.metadata)===null||x===void 0?void 0:x.width,height:(w=y.metadata)===null||w===void 0?void 0:w.height,mimeType:(k=y.metadata)===null||k===void 0?void 0:k.mimeType})}n=b}var S=/<br\s*\/?>/gi;if(c.text.trim().match(S)){var O;o.push({tag:"br"}),((O=e[n+1])===null||O===void 0?void 0:O.raw.trim())===""&&n++}}else c.type==="link"?c.raw===c.href?o.push(c.raw):o.push({tag:"a",href:c.href,children:Vo(c.tokens?c.tokens:[],t,0).children}):c.type==="br"?o.push({tag:"br"}):console.error("Could not parse markdown: unsupported token type: ".concat(c.type,". Found: ").concat(c.raw));n++},a;n<e.length;)if(a=s(),a)return a.v;return{children:o,cursor:n}}function l2(e){var t=e.templateStrings,n=e.exprs,r=t.flatMap(function(l,c){var u=n[c];return u?u[Gt]==="link"?l.concat("".concat(vh).concat(c).concat(t0).concat(u.children[0]).concat(n0)):l.concat("".concat(vh).concat(c).concat(t0).concat(n0)):l}).join(""),o=rj(r,{gfm:!0}),i=Vo(o,n,0),s=i.children,a=i.cursor;if(a!==o.length)throw Error("Unexpectedly terminated markdown parsing. Possible reason: unclosed html tag?");return Ot(Ot({},Gt,"richtext"),"children",s)}var c2=I.object({type:I.union([I.literal("bold"),I.literal("strike"),I.literal("italic")])}),Tj=I.object({type:I.literal("link"),attrs:I.object({href:I.string(),target:I.union([I.literal("_blank"),I.null()]),auto:I.boolean()})}),u2=I.intersection(I.object({type:I.literal("text"),text:I.string()}),I.object({marks:I.array(I.union([c2,Tj]))}).partial()),d2=I.intersection(I.object({type:I.literal("hardBreak")}),I.object({marks:I.array(c2)}).partial()),Pj=I.intersection(I.object({type:I.literal("image")}),I.object({attrs:I.intersection(I.object({src:I.string()}),I.object({align:I.union([I.literal("center"),I.literal("end"),I.literal("justify"),I.literal("left"),I.literal("match-parent"),I.literal("right"),I.literal("start"),I.null()]),alt:I.union([I.string(),I.null()]),height:I.union([I.string(),I.number(),I.null()]),width:I.union([I.string(),I.number(),I.null()]),rotate:I.union([I.string(),I.null()]),title:I.union([I.string(),I.null()]),fileName:I.union([I.string(),I.null()])}).partial())}).partial()),Mj=I.intersection(I.object({type:I.literal("heading")}),I.object({attrs:I.object({level:I.number()}),content:I.array(I.union([u2,d2]))}).partial()),f2=I.lazy(function(){return I.intersection(I.object({type:I.literal("bulletList")}),I.object({content:I.array(h2)}).partial())}),p2=I.lazy(function(){return I.intersection(I.object({type:I.literal("orderedList")}),I.object({content:I.array(h2)}).partial())}),h2=I.lazy(function(){return I.intersection(I.object({type:I.literal("listItem")}),I.object({content:I.array(I.union([m2,f2,p2]))}).partial())}),m2=I.intersection(I.object({type:I.literal("paragraph")}),I.object({content:I.array(I.union([u2,Pj,d2]))}).partial()),Nj=I.object({type:I.literal("doc"),content:I.array(I.union([m2,Mj,f2,p2]))});function Ik(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function yh(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ik(Object(n),!0).forEach(function(r){Ot(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ik(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Rj(e){return{type:"doc",content:e.children.map(function(t){return $j(t)})}}function $j(e){switch(e.tag){case"h1":return qa(1,e.children);case"h2":return qa(2,e.children);case"h3":return qa(3,e.children);case"h4":return qa(4,e.children);case"h5":return qa(5,e.children);case"h6":return qa(6,e.children);case"p":return Dk(e.children);case"ul":return y2(e);case"ol":return x2(e);case"br":return Dk([e]);default:{var t=e;throw Error("Unexpected child node: "+JSON.stringify(t))}}}function qa(e,t){return{type:"heading",attrs:{level:e},content:t.flatMap(g2)}}function jm(e){return{type:"text",text:e}}function g2(e){return typeof e=="string"?[jm(e)]:y1(e)}function y1(e){if(e.classes.length===0&&e.children.length===1){if(typeof e.children[0]=="string")return[jm(e.children[0])];throw Error("Unexpected amount of children in span node: "+JSON.stringify(e,null,2))}return e.children.map(function(t){return{type:"text",text:t,marks:e.classes.map(function(n){switch(n){case"bold":return{type:"bold"};case"italic":return{type:"italic"};case"line-through":return{type:"strike"};default:{var r=n;throw Error("Unexpected span class: "+r)}}})}})}function Dk(e){return{type:"paragraph",content:e.flatMap(function(t){if(typeof t=="string")return[jm(t)];switch(t.tag){case"span":return y1(t);case"a":return v2(t);case"img":return[Ij(t)];case"br":return[Aj()];default:{var n=t;throw Error("Unexpected paragraph child: "+JSON.stringify(n))}}})}}function Aj(){return{type:"hardBreak",marks:[]}}function v2(e){return e.children.flatMap(g2).map(function(t){return yh(yh({},t),{},{marks:(t.marks||[]).concat({type:"link",attrs:{href:e.href,auto:!1,target:null}})})})}function Ij(e){return{type:"image",attrs:{height:e.height,width:e.width,src:e.src}}}function y2(e){return{type:"bulletList",content:e.children.map(b2)}}function x2(e){return{type:"orderedList",content:e.children.map(b2)}}function b2(e){return{type:"listItem",content:Dj(e.children)}}function Dj(e){var t=[],n=v1(e),r;try{for(n.s();!(r=n.n()).done;){var o=r.value,i=t[t.length-1];i||(i={type:"paragraph",content:[]},t.push(i));var s=i.content;if(typeof o=="string")s.push(jm(o));else switch(o.tag){case"a":{s.push.apply(s,yd(v2(o)));break}case"br":{t.push({type:"paragraph",content:[]});break}case"span":{s.push.apply(s,yd(y1(o)));break}case"ol":{t.push(x2(o));break}case"ul":{t.push(y2(o));break}default:{var a=o;throw Error("Unexpected list item child: "+JSON.stringify(a))}}}}catch(l){n.e(l)}finally{n.f()}return t}function gn(){gn=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(_,T,C){_[T]=C.value},i=typeof Symbol=="function"?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function c(_,T,C){return Object.defineProperty(_,T,{value:C,enumerable:!0,configurable:!0,writable:!0}),_[T]}try{c({},"")}catch{c=function(T,C,M){return T[C]=M}}function u(_,T,C,M){var R=T&&T.prototype instanceof y?T:y,L=Object.create(R.prototype),G=new U(M||[]);return o(L,"_invoke",{value:$(_,C,G)}),L}function d(_,T,C){try{return{type:"normal",arg:_.call(T,C)}}catch(M){return{type:"throw",arg:M}}}t.wrap=u;var f="suspendedStart",p="suspendedYield",h="executing",g="completed",b={};function y(){}function x(){}function w(){}var k={};c(k,s,function(){return this});var S=Object.getPrototypeOf,O=S&&S(S(K([])));O&&O!==n&&r.call(O,s)&&(k=O);var E=w.prototype=y.prototype=Object.create(k);function P(_){["next","throw","return"].forEach(function(T){c(_,T,function(C){return this._invoke(T,C)})})}function N(_,T){function C(R,L,G,ve){var me=d(_[R],_,L);if(me.type!=="throw"){var Be=me.arg,Te=Be.value;return Te&&typeof Te=="object"&&r.call(Te,"__await")?T.resolve(Te.__await).then(function(J){C("next",J,G,ve)},function(J){C("throw",J,G,ve)}):T.resolve(Te).then(function(J){Be.value=J,G(Be)},function(J){return C("throw",J,G,ve)})}ve(me.arg)}var M;o(this,"_invoke",{value:function(R,L){function G(){return new T(function(ve,me){C(R,L,ve,me)})}return M=M?M.then(G,G):G()}})}function $(_,T,C){var M=f;return function(R,L){if(M===h)throw new Error("Generator is already running");if(M===g){if(R==="throw")throw L;return{value:e,done:!0}}for(C.method=R,C.arg=L;;){var G=C.delegate;if(G){var ve=z(G,C);if(ve){if(ve===b)continue;return ve}}if(C.method==="next")C.sent=C._sent=C.arg;else if(C.method==="throw"){if(M===f)throw M=g,C.arg;C.dispatchException(C.arg)}else C.method==="return"&&C.abrupt("return",C.arg);M=h;var me=d(_,T,C);if(me.type==="normal"){if(M=C.done?g:p,me.arg===b)continue;return{value:me.arg,done:C.done}}me.type==="throw"&&(M=g,C.method="throw",C.arg=me.arg)}}}function z(_,T){var C=T.method,M=_.iterator[C];if(M===e)return T.delegate=null,C==="throw"&&_.iterator.return&&(T.method="return",T.arg=e,z(_,T),T.method==="throw")||C!=="return"&&(T.method="throw",T.arg=new TypeError("The iterator does not provide a '"+C+"' method")),b;var R=d(M,_.iterator,T.arg);if(R.type==="throw")return T.method="throw",T.arg=R.arg,T.delegate=null,b;var L=R.arg;return L?L.done?(T[_.resultName]=L.value,T.next=_.nextLoc,T.method!=="return"&&(T.method="next",T.arg=e),T.delegate=null,b):L:(T.method="throw",T.arg=new TypeError("iterator result is not an object"),T.delegate=null,b)}function j(_){var T={tryLoc:_[0]};1 in _&&(T.catchLoc=_[1]),2 in _&&(T.finallyLoc=_[2],T.afterLoc=_[3]),this.tryEntries.push(T)}function le(_){var T=_.completion||{};T.type="normal",delete T.arg,_.completion=T}function U(_){this.tryEntries=[{tryLoc:"root"}],_.forEach(j,this),this.reset(!0)}function K(_){if(_||_===""){var T=_[s];if(T)return T.call(_);if(typeof _.next=="function")return _;if(!isNaN(_.length)){var C=-1,M=function R(){for(;++C<_.length;)if(r.call(_,C))return R.value=_[C],R.done=!1,R;return R.value=e,R.done=!0,R};return M.next=M}}throw new TypeError(typeof _+" is not iterable")}return x.prototype=w,o(E,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:x,configurable:!0}),x.displayName=c(w,l,"GeneratorFunction"),t.isGeneratorFunction=function(_){var T=typeof _=="function"&&_.constructor;return!!T&&(T===x||(T.displayName||T.name)==="GeneratorFunction")},t.mark=function(_){return Object.setPrototypeOf?Object.setPrototypeOf(_,w):(_.__proto__=w,c(_,l,"GeneratorFunction")),_.prototype=Object.create(E),_},t.awrap=function(_){return{__await:_}},P(N.prototype),c(N.prototype,a,function(){return this}),t.AsyncIterator=N,t.async=function(_,T,C,M,R){R===void 0&&(R=Promise);var L=new N(u(_,T,C,M),R);return t.isGeneratorFunction(T)?L:L.next().then(function(G){return G.done?G.value:L.next()})},P(E),c(E,l,"Generator"),c(E,s,function(){return this}),c(E,"toString",function(){return"[object Generator]"}),t.keys=function(_){var T=Object(_),C=[];for(var M in T)C.push(M);return C.reverse(),function R(){for(;C.length;){var L=C.pop();if(L in T)return R.value=L,R.done=!1,R}return R.done=!0,R}},t.values=K,U.prototype={constructor:U,reset:function(_){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(le),!_)for(var T in this)T.charAt(0)==="t"&&r.call(this,T)&&!isNaN(+T.slice(1))&&(this[T]=e)},stop:function(){this.done=!0;var _=this.tryEntries[0].completion;if(_.type==="throw")throw _.arg;return this.rval},dispatchException:function(_){if(this.done)throw _;var T=this;function C(me,Be){return L.type="throw",L.arg=_,T.next=me,Be&&(T.method="next",T.arg=e),!!Be}for(var M=this.tryEntries.length-1;M>=0;--M){var R=this.tryEntries[M],L=R.completion;if(R.tryLoc==="root")return C("end");if(R.tryLoc<=this.prev){var G=r.call(R,"catchLoc"),ve=r.call(R,"finallyLoc");if(G&&ve){if(this.prev<R.catchLoc)return C(R.catchLoc,!0);if(this.prev<R.finallyLoc)return C(R.finallyLoc)}else if(G){if(this.prev<R.catchLoc)return C(R.catchLoc,!0)}else{if(!ve)throw new Error("try statement without catch or finally");if(this.prev<R.finallyLoc)return C(R.finallyLoc)}}}},abrupt:function(_,T){for(var C=this.tryEntries.length-1;C>=0;--C){var M=this.tryEntries[C];if(M.tryLoc<=this.prev&&r.call(M,"finallyLoc")&&this.prev<M.finallyLoc){var R=M;break}}R&&(_==="break"||_==="continue")&&R.tryLoc<=T&&T<=R.finallyLoc&&(R=null);var L=R?R.completion:{};return L.type=_,L.arg=T,R?(this.method="next",this.next=R.finallyLoc,b):this.complete(L)},complete:function(_,T){if(_.type==="throw")throw _.arg;return _.type==="break"||_.type==="continue"?this.next=_.arg:_.type==="return"?(this.rval=this.arg=_.arg,this.method="return",this.next="end"):_.type==="normal"&&T&&(this.next=T),b},finish:function(_){for(var T=this.tryEntries.length-1;T>=0;--T){var C=this.tryEntries[T];if(C.finallyLoc===_)return this.complete(C.completion,C.afterLoc),le(C),b}},catch:function(_){for(var T=this.tryEntries.length-1;T>=0;--T){var C=this.tryEntries[T];if(C.tryLoc===_){var M=C.completion;if(M.type==="throw"){var R=M.arg;le(C)}return R}}throw new Error("illegal catch attempt")},delegateYield:function(_,T,C){return this.delegate={iterator:K(_),resultName:T,nextLoc:C},this.method==="next"&&(this.arg=e),b}},t}function Lk(e,t,n,r,o,i,s){try{var a=e[i](s),l=a.value}catch(c){n(c);return}a.done?t(l):Promise.resolve(l).then(r,o)}function Ga(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function s(l){Lk(i,r,o,s,a,"next",l)}function a(l){Lk(i,r,o,s,a,"throw",l)}s(void 0)})}}function Lj(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function jk(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,o2(r.key),r)}}function jj(e,t,n){return t&&jk(e.prototype,t),n&&jk(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var zj=new cj,x1=function(){function e(t){var n=this;Lj(this,e),Ot(this,"subscribe",function(r){return function(o){var i=zk(r);return n.listeners[i]||(n.listeners[i]=[],n.subscribers.set(i,{})),n.listeners[i].push(o),function(){n.listeners[i].splice(n.listeners[i].indexOf(o),1)}}}),Ot(this,"getSnapshot",function(r){return function(){return n.get(r)}}),Ot(this,"getServerSnapshot",function(r){return function(){return n.get(r)}}),Ot(this,"get",function(r){var o=zk(r);return n.subscribers.get(o)}),this.api=t,this.subscribers=new Map,this.listeners={},this.drafts={},this.schema={}}return jj(e,[{key:"getModule",value:function(){var t=Ga(gn().mark(function r(o){var i,s,a,l,c=arguments;return gn().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(i=c.length>1&&c[1]!==void 0?c[1]:!1,!(!i&&this.drafts[o]&&this.schema[o])){d.next=3;break}return d.abrupt("return",He.ok({source:this.drafts[o],schema:this.schema[o]}));case 3:return d.next=5,this.api.getTree({patch:!0,treePath:o,includeSource:!0,includeSchema:!0});case 5:if(s=d.sent,!He.isOk(s)){d.next=22;break}if(s.value.modules[o]){d.next=10;break}return console.error("Val: could not find the module",{moduleIds:Object.keys(s.value.modules),moduleId:o,data:s}),d.abrupt("return",He.err({message:`Could not fetch data.
104
+ Could not find the module:
105
+ `+o+`
106
+
107
+ Verify that the val.modules file includes this module.`}));case 10:if(a=s.value.modules[o].source,l=s.value.modules[o].schema,!(a!==void 0&&l!==void 0)){d.next=18;break}return this.drafts[o]=a,this.schema[o]=l,d.abrupt("return",He.ok({source:a,schema:l}));case 18:return console.error("Val: could not find the module source"),d.abrupt("return",He.err({message:"Could not fetch data. Verify that the module exists."}));case 20:d.next=29;break;case 22:if(s.error.statusCode!==504){d.next=27;break}return console.error("Val: timeout",s.error),d.abrupt("return",He.err({message:"Timed out while fetching data. Try again later."}));case 27:return console.error("Val: failed to get module",s.error),d.abrupt("return",He.err({message:"Could not fetch data. Verify that Val is correctly configured."}));case 29:case"end":return d.stop()}},r,this)}));function n(r){return t.apply(this,arguments)}return n}()},{key:"applyPatch",value:function(){var t=Ga(gn().mark(function r(o,i){var s,a,l,c,u,d,f,p,h,g,b,y;return gn().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(s=this.drafts[o],a=this.schema[o],!(!s||!a)){w.next=21;break}return w.next=5,this.api.getTree({patch:!0,treePath:o,includeSource:!0,includeSchema:!0});case 5:if(l=w.sent,!He.isOk(l)){w.next=19;break}if(c=l.value.modules[o].source,u=l.value.modules[o].schema,!(c!==void 0&&u!==void 0)){w.next=15;break}s=c,this.drafts[o]=c,this.schema[o]=u,w.next=17;break;case 15:return console.error("Val: could not find the module source"),w.abrupt("return",He.err({message:"Val: could not fetch data. Verify that the module exists."}));case 17:w.next=21;break;case 19:return console.error("Val: failed to get module",l.error),w.abrupt("return",He.err({message:"Val: could not fetch data. Verify that Val is correctly configured."}));case 21:return w.next=23,this.api.postPatches(o,i);case 23:if(d=w.sent,!He.isErr(d)){w.next=27;break}return console.error("Val: failed to post patch",d.error),w.abrupt("return",d);case 27:if(f=dj(s,zj,i.filter(Fe.notFileOp)),!He.isOk(f)){w.next=35;break}for(this.drafts[o]=f.value,this.emitEvent(o,f.value),p=0,h=Array.from(this.subscribers.entries());p<h.length;p++)g=Qy(h[p],2),b=g[0],y=g[1],y[o]&&(this.subscribers.set(b,yh(yh({},y),{},Ot({},o,this.drafts[o]))),this.emitChange(b));return w.abrupt("return",d);case 35:return console.error("Val: failed to apply patch",f.error),w.abrupt("return",f);case 37:case"end":return w.stop()}},r,this)}));function n(r,o){return t.apply(this,arguments)}return n}()},{key:"emitEvent",value:function(n,r){var o=new CustomEvent("val-event",{detail:{type:"module-update",moduleId:n,source:r}});window.dispatchEvent(o)}},{key:"update",value:function(){var t=Ga(gn().mark(function r(o){var i=this;return gn().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,Promise.all(o.map(function(l){return i.updateTree(l)}));case 2:case"end":return a.stop()}},r)}));function n(r){return t.apply(this,arguments)}return n}()},{key:"reset",value:function(){var t=Ga(gn().mark(function r(){return gn().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.abrupt("return",this.updateTree());case 1:case"end":return i.stop()}},r,this)}));function n(){return t.apply(this,arguments)}return n}()},{key:"initialize",value:function(){var t=Ga(gn().mark(function r(){var o,i,s,a,l,c,u;return gn().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this.api.getTree({patch:!1,includeSource:!1,includeSchema:!0});case 2:if(o=f.sent,!He.isOk(o)){f.next=9;break}for(i=[],s=0,a=Object.keys(o.value.modules);s<a.length;s++)l=a[s],c=o.value.modules[l].schema,c&&(i.push(l),this.schema[l]=c);return f.abrupt("return",He.ok(i));case 9:return u="Failed to fetch content. ",o.error.statusCode===401?u+="Authorization failed - check that you are logged in.":u+="Get a developer to verify that Val is correctly setup.",f.abrupt("return",He.err({message:u,details:{fetchError:o.error}}));case 12:case"end":return f.stop()}},r,this)}));function n(){return t.apply(this,arguments)}return n}()},{key:"updateTree",value:function(){var t=Ga(gn().mark(function r(o){var i=this,s,a,l,c,u,d,f,p,h,g,b,y,x,w;return gn().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this.api.getTree({patch:!0,treePath:o,includeSource:!0,includeSchema:!0});case 2:if(s=S.sent,a=[],!He.isOk(s)){S.next=18;break}l=new Map,c=Array.from(this.subscribers.keys()),u=gn().mark(function O(){var E,P,N;return gn().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:E=f[d],P=s.value.modules[E].source,typeof P<"u"&&(a.push(E),i.emitEvent(E,P),N=c.find(function(j){return j.includes(E)}),N&&l.set(N,(l.get(N)||[]).concat(E)));case 3:case"end":return z.stop()}},O)}),d=0,f=Object.keys(s.value.modules);case 9:if(!(d<f.length)){S.next=14;break}return S.delegateYield(u(),"t0",11);case 11:d++,S.next=9;break;case 14:for(p=0,h=Array.from(l.entries());p<h.length;p++)g=Qy(h[p],2),b=g[0],y=g[1],x=Object.fromEntries(y.flatMap(function(O){var E=s.value.modules[O].source;return E?[[O,E]]:[]})),this.subscribers.set(b,x),this.emitChange(b);return S.abrupt("return",He.ok(a));case 18:return w="Failed to fetch content. ",s.error.statusCode===401?w+="Authorization failed - check that you are logged in.":w+="Get a developer to verify that Val is correctly setup.",S.abrupt("return",He.err({message:w,details:{fetchError:s.error}}));case 21:case"end":return S.stop()}},r,this)}));function n(r){return t.apply(this,arguments)}return n}()},{key:"emitChange",value:function(n){var r=v1(this.listeners[n]),o;try{for(r.s();!(o=r.n()).done;){var i=o.value;i()}}catch(s){r.e(s)}finally{r.f()}}}]),e}();function zk(e){return e.slice().sort().join("&")}const Fj=new TextEncoder;function w2(e){return new Promise((t,n)=>{var i;const r=(i=e.currentTarget.files)==null?void 0:i[0],o=new FileReader;o.addEventListener("load",()=>{const s=o.result;if(typeof s=="string"){const a=new Image;a.addEventListener("load",()=>{const l=Fe.getSHA256Hash(Fj.encode(s));if(a.naturalWidth&&a.naturalHeight){const c=Dm(s);t({src:s,width:a.naturalWidth,height:a.naturalHeight,filename:r==null?void 0:r.name,sha256:l,mimeType:c,fileExt:c&&Lm(c)})}else t({src:s,filename:r==null?void 0:r.name,sha256:l})}),a.src=s}else n(s?{message:"Unexpected image result type",result:s}:{message:"Empty result"})}),r&&o.readAsDataURL(r)})}function k2(e,t,n){if(!n||!e)return t;const r=n.sha256.slice(0,5),o=Dm(e)??"unknown",i=Lm(o)??"unknown";if(t){let s=t.split(".").slice(0,-1).join(".")||t;const a=s.lastIndexOf("_");return s.slice(a+1,s.length)===r&&(s=s.slice(0,a)),`${encodeURIComponent(s).replace(/%[0-9A-Fa-f]{2}/g,"").toLowerCase()}_${r}.${i}`}return`${n.sha256}.${i}`}const b1=m.forwardRef(({className:e,type:t,...n},r)=>v.jsx("input",{type:t,className:Me("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));b1.displayName="Input";let zm=()=>({events:{},emit(e,...t){(this.events[e]||[]).forEach(n=>n(...t))},on(e,t){return(this.events[e]=this.events[e]||[]).push(t),()=>this.events[e]=(this.events[e]||[]).filter(n=>n!==t)}});var r0={exports:{}};(function(e,t){var n=typeof Reflect<"u"?Reflect.construct:void 0,r=Object.defineProperty,o=Error.captureStackTrace;o===void 0&&(o=function(c){var u=new Error;r(c,"stack",{configurable:!0,get:function(){var f=u.stack;return r(this,"stack",{configurable:!0,value:f,writable:!0}),f},set:function(f){r(c,"stack",{configurable:!0,value:f,writable:!0})}})});function i(l){l!==void 0&&r(this,"message",{configurable:!0,value:l,writable:!0});var c=this.constructor.name;c!==void 0&&c!==this.name&&r(this,"name",{configurable:!0,value:c,writable:!0}),o(this,this.constructor)}i.prototype=Object.create(Error.prototype,{constructor:{configurable:!0,value:i,writable:!0}});var s=function(){function l(u,d){return r(u,"name",{configurable:!0,value:d})}try{var c=function(){};if(l(c,"foo"),c.name==="foo")return l}catch{}}();function a(l,c){if(c==null||c===Error)c=i;else if(typeof c!="function")throw new TypeError("super_ should be a function");var u;if(typeof l=="string")u=l,l=n!==void 0?function(){return n(c,arguments,this.constructor)}:function(){c.apply(this,arguments)},s!==void 0&&(s(l,u),u=void 0);else if(typeof l!="function")throw new TypeError("constructor should be either a string or a function");l.super_=l.super=c;var d={constructor:{configurable:!0,value:l,writable:!0}};return u!==void 0&&(d.name={configurable:!0,value:u,writable:!0}),l.prototype=Object.create(c.prototype,d),l}t=e.exports=a,t.BaseError=i})(r0,r0.exports);var S2=r0.exports,Fk="ProseMirror-selectednode",E2="",Xi="\0",Bk="__state_override__",Bj={LastNodeCompatible:"lastNodeCompatible",FormattingMark:"formattingMark",FormattingNode:"formattingNode",NodeCursor:"nodeCursor",FontStyle:"fontStyle",Link:"link",Color:"color",Alignment:"alignment",Indentation:"indentation",Behavior:"behavior",Code:"code",InlineNode:"inline",ListContainerNode:"listContainer",ListItemNode:"listItemNode",Block:"block",BlockNode:"block",TextBlock:"textBlock",ExcludeInputRules:"excludeFromInputRules",PreventExits:"preventsExits",Media:"media"},Ce=Bj,di=Symbol.for("__remirror__"),Yt=(e=>(e.PlainExtension="RemirrorPlainExtension",e.NodeExtension="RemirrorNodeExtension",e.MarkExtension="RemirrorMarkExtension",e.PlainExtensionConstructor="RemirrorPlainExtensionConstructor",e.NodeExtensionConstructor="RemirrorNodeExtensionConstructor",e.MarkExtensionConstructor="RemirrorMarkExtensionConstructor",e.Manager="RemirrorManager",e.Preset="RemirrorPreset",e.PresetConstructor="RemirrorPresetConstructor",e))(Yt||{}),qe=(e=>(e[e.Critical=1e6]="Critical",e[e.Highest=1e5]="Highest",e[e.High=1e4]="High",e[e.Medium=1e3]="Medium",e[e.Default=100]="Default",e[e.Low=10]="Low",e[e.Lowest=0]="Lowest",e))(qe||{}),An=(e=>(e[e.None=0]="None",e[e.Create=1]="Create",e[e.EditorView=2]="EditorView",e[e.Runtime=3]="Runtime",e[e.Destroy=4]="Destroy",e))(An||{}),H=(e=>(e.Undo="_|undo|_",e.Redo="_|redo|_",e.Bold="_|bold|_",e.Italic="_|italic|_",e.Underline="_|underline|_",e.Strike="_|strike|_",e.Code="_|code|_",e.Paragraph="_|paragraph|_",e.H1="_|h1|_",e.H2="_|h2|_",e.H3="_|h3|_",e.H4="_|h4|_",e.H5="_|h5|_",e.H6="_|h6|_",e.TaskList="_|task|_",e.BulletList="_|bullet|_",e.OrderedList="_|number|_",e.Quote="_|quote|_",e.Divider="_|divider|_",e.Codeblock="_|codeblock|_",e.ClearFormatting="_|clear|_",e.Superscript="_|sup|_",e.Subscript="_|sub|_",e.LeftAlignment="_|left-align|_",e.CenterAlignment="_|center-align|_",e.RightAlignment="_|right-align|_",e.JustifyAlignment="_|justify-align|_",e.InsertLink="_|link|_",e.Find="_|find|_",e.FindBackwards="_|find-backwards|_",e.FindReplace="_|find-replace|_",e.AddFootnote="_|footnote|_",e.AddComment="_|comment|_",e.ContextMenu="_|context-menu|_",e.IncreaseFontSize="_|inc-font-size|_",e.DecreaseFontSize="_|dec-font-size|_",e.IncreaseIndent="_|indent|_",e.DecreaseIndent="_|dedent|_",e.Shortcuts="_|shortcuts|_",e.Copy="_|copy|_",e.Cut="_|cut|_",e.Paste="_|paste|_",e.PastePlain="_|paste-plain|_",e.SelectAll="_|select-all|_",e.Format="_|format|_",e))(H||{}),V=(e=>(e.PROD="RMR0000",e.UNKNOWN="RMR0001",e.INVALID_COMMAND_ARGUMENTS="RMR0002",e.CUSTOM="RMR0003",e.CORE_HELPERS="RMR0004",e.MUTATION="RMR0005",e.INTERNAL="RMR0006",e.MISSING_REQUIRED_EXTENSION="RMR0007",e.MANAGER_PHASE_ERROR="RMR0008",e.INVALID_GET_EXTENSION="RMR0010",e.INVALID_MANAGER_ARGUMENTS="RMR0011",e.SCHEMA="RMR0012",e.HELPERS_CALLED_IN_OUTER_SCOPE="RMR0013",e.INVALID_MANAGER_EXTENSION="RMR0014",e.DUPLICATE_COMMAND_NAMES="RMR0016",e.DUPLICATE_HELPER_NAMES="RMR0017",e.NON_CHAINABLE_COMMAND="RMR0018",e.INVALID_EXTENSION="RMR0019",e.INVALID_CONTENT="RMR0021",e.INVALID_NAME="RMR0050",e.EXTENSION="RMR0100",e.EXTENSION_SPEC="RMR0101",e.EXTENSION_EXTRA_ATTRIBUTES="RMR0102",e.INVALID_SET_EXTENSION_OPTIONS="RMR0103",e.REACT_PROVIDER_CONTEXT="RMR0200",e.REACT_GET_ROOT_PROPS="RMR0201",e.REACT_EDITOR_VIEW="RMR0202",e.REACT_CONTROLLED="RMR0203",e.REACT_NODE_VIEW="RMR0204",e.REACT_GET_CONTEXT="RMR0205",e.REACT_COMPONENTS="RMR0206",e.REACT_HOOKS="RMR0207",e.I18N_CONTEXT="RMR0300",e))(V||{}),Vj=function(t){return Uj(t)&&!Hj(t)};function Uj(e){return!!e&&typeof e=="object"}function Hj(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||qj(e)}var Wj=typeof Symbol=="function"&&Symbol.for,Kj=Wj?Symbol.for("react.element"):60103;function qj(e){return e.$$typeof===Kj}function Gj(e){return Array.isArray(e)?[]:{}}function xd(e,t){return t.clone!==!1&&t.isMergeableObject(e)?tc(Gj(e),e,t):e}function Yj(e,t,n){return e.concat(t).map(function(r){return xd(r,n)})}function Xj(e,t){if(!t.customMerge)return tc;var n=t.customMerge(e);return typeof n=="function"?n:tc}function Zj(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function Vk(e){return Object.keys(e).concat(Zj(e))}function _2(e,t){try{return t in e}catch{return!1}}function Jj(e,t){return _2(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function Qj(e,t,n){var r={};return n.isMergeableObject(e)&&Vk(e).forEach(function(o){r[o]=xd(e[o],n)}),Vk(t).forEach(function(o){Jj(e,o)||(_2(e,o)&&n.isMergeableObject(t[o])?r[o]=Xj(o,n)(e[o],t[o],n):r[o]=xd(t[o],n))}),r}function tc(e,t,n){n=n||{},n.arrayMerge=n.arrayMerge||Yj,n.isMergeableObject=n.isMergeableObject||Vj,n.cloneUnlessOtherwiseSpecified=xd;var r=Array.isArray(t),o=Array.isArray(e),i=r===o;return i?r?n.arrayMerge(e,t,n):Qj(e,t,n):xd(t,n)}tc.all=function(t,n){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(r,o){return tc(r,o,n)},{})};var e6=tc,t6=e6;const n6=Ao(t6);/*!
104
108
  * isobject <https://github.com/jonschlinkert/isobject>
105
109
  *
106
110
  * Copyright (c) 2014-2017, Jon Schlinkert.
@@ -210,7 +214,7 @@ If you are using Node.js, you can install JSDOM and Remirror will try to use it
210
214
  `,...t,attrs:e.defaults(),parseDOM:[{tag:"br",getAttrs:e.parse},...t.parseDOM??[]],toDOM:n=>["br",e.dom(n)]}}createKeymap(){const e=az(Bu(kM),()=>(this.store.commands.insertHardBreak(),!0));return{"Mod-Enter":e,"Shift-Enter":e}}insertHardBreak(){return e=>{const{tr:t,dispatch:n}=e;return n==null||n(t.replaceSelectionWith(this.type.create()).scrollIntoView()),!0}}};xR([oe()],tm.prototype,"insertHardBreak",1);tm=xR([Le({defaultPriority:qe.Low})],tm);const Ste=[new Na,new Bd,new Vd,new Ud({enableResizing:!1}),new K0,new em({levels:[1,2,3,4,5,6],defaultLevel:1}),new Ld,new jd,new Ra({autoLink:!0}),new tm];function Ete(e){const{manager:t,state:n}=GG({extensions:()=>Ste.slice(),content:e,selection:"start"});return{manager:t,state:n}}function _te({state:e,manager:t,options:n,onChange:r,debug:o}){const i=n&&Object.entries(n).some(([,c])=>c),[s,a]=m.useState(i),l=It("p-4 border rounded-md outline-none appearance-none border-input bg-background",{"rounded-t-none border-t-0":s});return v.jsx("div",{className:"text-base val-rich-text-editor",children:v.jsx(ZG,{manager:t,initialContent:e,classNames:[l],children:v.jsxs(Nee,{initialProps:{mode:"default"},children:[v.jsx(Cte,{hasOptions:i,options:n,debug:o,onShowToolbar:c=>{a(c)}}),v.jsx(L0,{}),r&&v.jsx(YG,{onChange:r})]})})})}const Cte=({options:e,hasOptions:t,onShowToolbar:n,debug:r})=>{var l,c,u,d,f,p;const o=ib(),i=AG(),s=t||i.heading()||i.image()||i.link()||i.bulletList()||i.orderedList()||i.bold()||i.italic()||i.strike();m.useEffect(()=>{n(s)},[s]);const a=m.useRef(null);return v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"h-0",ref:a}),v.jsxs("div",{className:It("sticky top-0 flex flex-col py-2 z-[40] border divide-y rounded-md rounded-b-none border-input bg-background",{hidden:!s}),children:[v.jsxs("div",{className:"flex flex-row items-center justify-start px-4 py-1 gap-x-3",children:[((e==null?void 0:e.headings)||i.heading())&&v.jsxs(BJ,{children:[v.jsx(VJ,{asChild:!0,className:"pr-4",children:v.jsxs("button",{children:[i.heading({level:1})&&v.jsx(mk,{size:22}),i.heading({level:2})&&v.jsx(gk,{size:22}),i.heading({level:3})&&v.jsx(vk,{size:22}),i.heading({level:4})&&v.jsx(yk,{size:22}),i.heading({level:5})&&v.jsx(xk,{size:22}),i.heading({level:6})&&v.jsx(bk,{size:22}),!i.heading()&&"Normal"]})}),v.jsxs(aR,{container:a.current,children:[v.jsx(Li,{onClick:()=>{o.setBlockNodeType("paragraph").focus().run()},children:"Normal"}),((l=e==null?void 0:e.headings)==null?void 0:l.includes("h1"))&&v.jsx(Li,{onClick:()=>{o.setBlockNodeType("heading",{level:1}).focus().run()},children:v.jsx(mk,{size:16})}),((c=e==null?void 0:e.headings)==null?void 0:c.includes("h2"))&&v.jsx(Li,{onClick:()=>{o.setBlockNodeType("heading",{level:2}).focus().run()},children:v.jsx(gk,{size:16})}),((u=e==null?void 0:e.headings)==null?void 0:u.includes("h3"))&&v.jsx(Li,{onClick:()=>{o.setBlockNodeType("heading",{level:3}).focus().run()},children:v.jsx(vk,{size:16})}),((d=e==null?void 0:e.headings)==null?void 0:d.includes("h4"))&&v.jsx(Li,{onClick:()=>{o.setBlockNodeType("heading",{level:4}).focus().run()},children:v.jsx(yk,{size:16})}),((f=e==null?void 0:e.headings)==null?void 0:f.includes("h5"))&&v.jsx(Li,{onClick:()=>{o.setBlockNodeType("heading",{level:5}).focus().run()},children:v.jsx(xk,{size:16})}),((p=e==null?void 0:e.headings)==null?void 0:p.includes("h5"))&&v.jsx(Li,{onClick:()=>{o.setBlockNodeType("heading",{level:6}).focus().run()},children:v.jsx(bk,{size:16})})]})]}),v.jsx(rl,{icon:v.jsx(E5,{size:18}),stroke:3,mark:"bold",isOption:e==null?void 0:e.bold,isActive:i.bold(),onToggle:h=>h.toggleBold().focus().run()}),v.jsx(rl,{icon:v.jsx(H5,{size:18}),stroke:3,mark:"strike",isOption:e==null?void 0:e.lineThrough,isActive:i.strike(),onToggle:h=>h.toggleStrike().focus().run()}),v.jsx(rl,{icon:v.jsx(N5,{size:18}),stroke:3,mark:"italic",isOption:e==null?void 0:e.italic,isActive:i.italic(),onToggle:h=>h.toggleItalic().focus().run()}),v.jsx(rl,{icon:v.jsx(I5,{size:18}),stroke:3,mark:"bulletList",isOption:e==null?void 0:e.ul,isActive:i.bulletList(),onToggle:h=>h.toggleBulletList().focus().run()}),v.jsx(rl,{icon:v.jsx(A5,{size:18}),stroke:3,mark:"list",isOption:e==null?void 0:e.ol,isActive:i.orderedList(),onToggle:h=>h.toggleOrderedList().focus().run()}),v.jsx(rl,{icon:v.jsx($5,{size:18}),stroke:3,mark:"link",isOption:e==null?void 0:e.ol,isActive:i.link(),onToggle:h=>h.selectMark("link").updateLink({href:""}).focus().run()}),((e==null?void 0:e.img)||i.image())&&v.jsxs("label",{className:"cursor-pointer",htmlFor:"val-toolbar-image-select",children:[v.jsx("input",{hidden:!0,id:"val-toolbar-image-select",accept:"image/*",type:"file",onChange:h=>{w2(h).then(g=>{o.insertImage({src:g.src,width:g.width,height:g.height,fileName:k2(g.src,g.filename??null,{width:g.width,height:g.height,sha256:g.sha256,mimeType:g.mimeType})??void 0}).focus().run()})}}),v.jsx(M5,{size:18,className:`${i.image()&&"stroke-[3px]"}`})]}),r&&v.jsx("button",{onMouseDown:h=>h.preventDefault(),onClick:()=>o.insertHardBreak().run(),children:"Br"})]}),v.jsx(Ote,{})]})]})};function Ote(){const e=ib(),[t,n]=m.useState(),r=IG().link();return m.useEffect(()=>{const i=typeof r=="object"&&"href"in r&&typeof r.href=="string"?r.href:void 0;n(i)},[r==null?void 0:r.href]),r!==void 0?v.jsxs("div",{className:"flex items-center justify-start px-4 pt-1 gap-x-2",children:[v.jsx("input",{className:"bg-transparent text-accent",onChange:i=>{n(i.target.value)},defaultValue:t,placeholder:"https://"}),v.jsx("button",{className:"p-2",title:"Update",disabled:t===void 0,onClick:()=>{t!==void 0&&e.selectMark("link").updateLink({href:t}).focus().run()},children:v.jsx(n1,{size:14})}),v.jsx("button",{className:"p-2",title:"Remove",onClick:()=>{e.removeLink().focus().run()},children:v.jsx(q5,{size:13})})]}):null}function rl({stroke:e,mark:t,isOption:n,isActive:r,onToggle:o,icon:i}){const s=ib();return!n&&!r?null:v.jsx("button",{className:It({"text-accent":r,"stroke-[2px]":r&&e===2,"stroke-[3px]":r&&e===3}),onClick:a=>{a.preventDefault(),o(n?s:s.selectMark(t))},children:i})}function bR(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}const Tte=m.forwardRef((e,t)=>m.createElement(we.span,A({},e,{ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}))),Pte=[" ","Enter","ArrowUp","ArrowDown"],Mte=[" ","Enter"],mg="Select",[gg,_b,Nte]=Mm(mg),[Pc,Eie]=Rr(mg,[Nte,Tc]),Cb=Tc(),[Rte,Va]=Pc(mg),[$te,Ate]=Pc(mg),Ite=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:i,value:s,defaultValue:a,onValueChange:l,dir:c,name:u,autoComplete:d,disabled:f,required:p}=e,h=Cb(t),[g,b]=m.useState(null),[y,x]=m.useState(null),[w,k]=m.useState(!1),S=ef(c),[O=!1,E]=Oo({prop:r,defaultProp:o,onChange:i}),[P,N]=Oo({prop:s,defaultProp:a,onChange:l}),$=m.useRef(null),z=g?!!g.closest("form"):!0,[j,le]=m.useState(new Set),U=Array.from(j).map(K=>K.props.value).join(";");return m.createElement(pb,h,m.createElement(Rte,{required:p,scope:t,trigger:g,onTriggerChange:b,valueNode:y,onValueNodeChange:x,valueNodeHasChildren:w,onValueNodeHasChildrenChange:k,contentId:Er(),value:P,onValueChange:N,open:O,onOpenChange:E,dir:S,triggerPointerDownPosRef:$,disabled:f},m.createElement(gg.Provider,{scope:t},m.createElement($te,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(K=>{le(_=>new Set(_).add(K))},[]),onNativeOptionRemove:m.useCallback(K=>{le(_=>{const T=new Set(_);return T.delete(K),T})},[])},n)),z?m.createElement(ER,{key:U,"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:P,onChange:K=>N(K.target.value),disabled:f},P===void 0?m.createElement("option",{value:""}):null,Array.from(j)):null))},Dte="SelectTrigger",Lte=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,i=Cb(n),s=Va(Dte,n),a=s.disabled||r,l=$e(t,s.onTriggerChange),c=_b(n),[u,d,f]=_R(h=>{const g=c().filter(x=>!x.disabled),b=g.find(x=>x.value===s.value),y=CR(g,h,b);y!==void 0&&s.onValueChange(y.value)}),p=()=>{a||(s.onOpenChange(!0),f())};return m.createElement(hb,A({asChild:!0},i),m.createElement(we.button,A({type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":SR(s.value)?"":void 0},o,{ref:l,onClick:ne(o.onClick,h=>{h.currentTarget.focus()}),onPointerDown:ne(o.onPointerDown,h=>{const g=h.target;g.hasPointerCapture(h.pointerId)&&g.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&(p(),s.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)},h.preventDefault())}),onKeyDown:ne(o.onKeyDown,h=>{const g=u.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&d(h.key),!(g&&h.key===" ")&&Pte.includes(h.key)&&(p(),h.preventDefault())})})))}),jte="SelectValue",zte=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:i,placeholder:s="",...a}=e,l=Va(jte,n),{onValueNodeHasChildrenChange:c}=l,u=i!==void 0,d=$e(t,l.onValueNodeChange);return ar(()=>{c(u)},[c,u]),m.createElement(we.span,A({},a,{ref:d,style:{pointerEvents:"none"}}),SR(l.value)?m.createElement(m.Fragment,null,s):i)}),Fte=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return m.createElement(we.span,A({"aria-hidden":!0},o,{ref:t}),r||"▼")}),Bte=e=>m.createElement(ug,A({asChild:!0},e)),pc="SelectContent",Vte=m.forwardRef((e,t)=>{const n=Va(pc,e.__scopeSelect),[r,o]=m.useState();if(ar(()=>{o(new DocumentFragment)},[]),!n.open){const i=r;return i?Nr.createPortal(m.createElement(wR,{scope:e.__scopeSelect},m.createElement(gg.Slot,{scope:e.__scopeSelect},m.createElement("div",null,e.children))),i):null}return m.createElement(Ute,A({},e,{ref:t}))}),Go=10,[wR,vg]=Pc(pc),Ute=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:s,side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:h,hideWhenDetached:g,avoidCollisions:b,...y}=e,x=Va(pc,n),[w,k]=m.useState(null),[S,O]=m.useState(null),E=$e(t,J=>k(J)),[P,N]=m.useState(null),[$,z]=m.useState(null),j=_b(n),[le,U]=m.useState(!1),K=m.useRef(!1);m.useEffect(()=>{if(w)return sg(w)},[w]),lg();const _=m.useCallback(J=>{const[Ge,...Ye]=j().map(Je=>Je.ref.current),[Xe]=Ye.slice(-1),Ze=document.activeElement;for(const Je of J)if(Je===Ze||(Je==null||Je.scrollIntoView({block:"nearest"}),Je===Ge&&S&&(S.scrollTop=0),Je===Xe&&S&&(S.scrollTop=S.scrollHeight),Je==null||Je.focus(),document.activeElement!==Ze))return},[j,S]),T=m.useCallback(()=>_([P,w]),[_,P,w]);m.useEffect(()=>{le&&T()},[le,T]);const{onOpenChange:C,triggerPointerDownPosRef:M}=x;m.useEffect(()=>{if(w){let J={x:0,y:0};const Ge=Xe=>{var Ze,Je,Un,Hn;J={x:Math.abs(Math.round(Xe.pageX)-((Ze=(Je=M.current)===null||Je===void 0?void 0:Je.x)!==null&&Ze!==void 0?Ze:0)),y:Math.abs(Math.round(Xe.pageY)-((Un=(Hn=M.current)===null||Hn===void 0?void 0:Hn.y)!==null&&Un!==void 0?Un:0))}},Ye=Xe=>{J.x<=10&&J.y<=10?Xe.preventDefault():w.contains(Xe.target)||C(!1),document.removeEventListener("pointermove",Ge),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",Ge),document.addEventListener("pointerup",Ye,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Ge),document.removeEventListener("pointerup",Ye,{capture:!0})}}},[w,C,M]),m.useEffect(()=>{const J=()=>C(!1);return window.addEventListener("blur",J),window.addEventListener("resize",J),()=>{window.removeEventListener("blur",J),window.removeEventListener("resize",J)}},[C]);const[R,L]=_R(J=>{const Ge=j().filter(Ze=>!Ze.disabled),Ye=Ge.find(Ze=>Ze.ref.current===document.activeElement),Xe=CR(Ge,J,Ye);Xe&&setTimeout(()=>Xe.ref.current.focus())}),G=m.useCallback((J,Ge,Ye)=>{const Xe=!K.current&&!Ye;(x.value!==void 0&&x.value===Ge||Xe)&&(N(J),Xe&&(K.current=!0))},[x.value]),ve=m.useCallback(()=>w==null?void 0:w.focus(),[w]),me=m.useCallback((J,Ge,Ye)=>{const Xe=!K.current&&!Ye;(x.value!==void 0&&x.value===Ge||Xe)&&z(J)},[x.value]),Be=r==="popper"?n_:Hte,Te=Be===n_?{side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:h,hideWhenDetached:g,avoidCollisions:b}:{};return m.createElement(wR,{scope:n,content:w,viewport:S,onViewportChange:O,itemRefCallback:G,selectedItem:P,onItemLeave:ve,itemTextRefCallback:me,focusSelectedItem:T,selectedItemText:$,position:r,isPositioned:le,searchRef:R},m.createElement(fg,{as:ci,allowPinchZoom:!0},m.createElement(cg,{asChild:!0,trapped:x.open,onMountAutoFocus:J=>{J.preventDefault()},onUnmountAutoFocus:ne(o,J=>{var Ge;(Ge=x.trigger)===null||Ge===void 0||Ge.focus({preventScroll:!0}),J.preventDefault()})},m.createElement(ag,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:J=>J.preventDefault(),onDismiss:()=>x.onOpenChange(!1)},m.createElement(Be,A({role:"listbox",id:x.contentId,"data-state":x.open?"open":"closed",dir:x.dir,onContextMenu:J=>J.preventDefault()},y,Te,{onPlaced:()=>U(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ne(y.onKeyDown,J=>{const Ge=J.ctrlKey||J.altKey||J.metaKey;if(J.key==="Tab"&&J.preventDefault(),!Ge&&J.key.length===1&&L(J.key),["ArrowUp","ArrowDown","Home","End"].includes(J.key)){let Xe=j().filter(Ze=>!Ze.disabled).map(Ze=>Ze.ref.current);if(["ArrowUp","End"].includes(J.key)&&(Xe=Xe.slice().reverse()),["ArrowUp","ArrowDown"].includes(J.key)){const Ze=J.target,Je=Xe.indexOf(Ze);Xe=Xe.slice(Je+1)}setTimeout(()=>_(Xe)),J.preventDefault()}})}))))))}),Hte=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,i=Va(pc,n),s=vg(pc,n),[a,l]=m.useState(null),[c,u]=m.useState(null),d=$e(t,E=>u(E)),f=_b(n),p=m.useRef(!1),h=m.useRef(!0),{viewport:g,selectedItem:b,selectedItemText:y,focusSelectedItem:x}=s,w=m.useCallback(()=>{if(i.trigger&&i.valueNode&&a&&c&&g&&b&&y){const E=i.trigger.getBoundingClientRect(),P=c.getBoundingClientRect(),N=i.valueNode.getBoundingClientRect(),$=y.getBoundingClientRect();if(i.dir!=="rtl"){const Ze=$.left-P.left,Je=N.left-Ze,Un=E.left-Je,Hn=E.width+Un,Lo=Math.max(Hn,P.width),Wa=window.innerWidth-Go,Nc=zy(Je,[Go,Wa-Lo]);a.style.minWidth=Hn+"px",a.style.left=Nc+"px"}else{const Ze=P.right-$.right,Je=window.innerWidth-N.right-Ze,Un=window.innerWidth-E.right-Je,Hn=E.width+Un,Lo=Math.max(Hn,P.width),Wa=window.innerWidth-Go,Nc=zy(Je,[Go,Wa-Lo]);a.style.minWidth=Hn+"px",a.style.right=Nc+"px"}const z=f(),j=window.innerHeight-Go*2,le=g.scrollHeight,U=window.getComputedStyle(c),K=parseInt(U.borderTopWidth,10),_=parseInt(U.paddingTop,10),T=parseInt(U.borderBottomWidth,10),C=parseInt(U.paddingBottom,10),M=K+_+le+C+T,R=Math.min(b.offsetHeight*5,M),L=window.getComputedStyle(g),G=parseInt(L.paddingTop,10),ve=parseInt(L.paddingBottom,10),me=E.top+E.height/2-Go,Be=j-me,Te=b.offsetHeight/2,J=b.offsetTop+Te,Ge=K+_+J,Ye=M-Ge;if(Ge<=me){const Ze=b===z[z.length-1].ref.current;a.style.bottom="0px";const Je=c.clientHeight-g.offsetTop-g.offsetHeight,Un=Math.max(Be,Te+(Ze?ve:0)+Je+T),Hn=Ge+Un;a.style.height=Hn+"px"}else{const Ze=b===z[0].ref.current;a.style.top="0px";const Un=Math.max(me,K+g.offsetTop+(Ze?G:0)+Te)+Ye;a.style.height=Un+"px",g.scrollTop=Ge-me+g.offsetTop}a.style.margin=`${Go}px 0`,a.style.minHeight=R+"px",a.style.maxHeight=j+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[f,i.trigger,i.valueNode,a,c,g,b,y,i.dir,r]);ar(()=>w(),[w]);const[k,S]=m.useState();ar(()=>{c&&S(window.getComputedStyle(c).zIndex)},[c]);const O=m.useCallback(E=>{E&&h.current===!0&&(w(),x==null||x(),h.current=!1)},[w,x]);return m.createElement(Wte,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:O},m.createElement("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k}},m.createElement(we.div,A({},o,{ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}}))))}),n_=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Go,...i}=e,s=Cb(n);return m.createElement(mb,A({},s,i,{ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}}))}),[Wte,Kte]=Pc(pc,{}),r_="SelectViewport",qte=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=vg(r_,n),i=Kte(r_,n),s=$e(t,o.onViewportChange),a=m.useRef(0);return m.createElement(m.Fragment,null,m.createElement("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"}}),m.createElement(gg.Slot,{scope:n},m.createElement(we.div,A({"data-radix-select-viewport":"",role:"presentation"},r,{ref:s,style:{position:"relative",flex:1,overflow:"auto",...r.style},onScroll:ne(r.onScroll,l=>{const c=l.currentTarget,{contentWrapper:u,shouldExpandOnScrollRef:d}=i;if(d!=null&&d.current&&u){const f=Math.abs(a.current-c.scrollTop);if(f>0){const p=window.innerHeight-Go*2,h=parseFloat(u.style.minHeight),g=parseFloat(u.style.height),b=Math.max(h,g);if(b<p){const y=b+f,x=Math.min(p,y),w=y-x;u.style.height=x+"px",u.style.bottom==="0px"&&(c.scrollTop=w>0?w:0,u.style.justifyContent="flex-end")}}}a.current=c.scrollTop})}))))}),Gte="SelectGroup",[Yte,Xte]=Pc(Gte),Zte=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Er();return m.createElement(Yte,{scope:n,id:o},m.createElement(we.div,A({role:"group","aria-labelledby":o},r,{ref:t})))}),Jte="SelectLabel",Qte=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Xte(Jte,n);return m.createElement(we.div,A({id:o.id},r,{ref:t}))}),q0="SelectItem",[ene,kR]=Pc(q0),tne=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:i,...s}=e,a=Va(q0,n),l=vg(q0,n),c=a.value===r,[u,d]=m.useState(i??""),[f,p]=m.useState(!1),h=$e(t,y=>{var x;return(x=l.itemRefCallback)===null||x===void 0?void 0:x.call(l,y,r,o)}),g=Er(),b=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return m.createElement(ene,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:m.useCallback(y=>{d(x=>{var w;return x||((w=y==null?void 0:y.textContent)!==null&&w!==void 0?w:"").trim()})},[])},m.createElement(gg.ItemSlot,{scope:n,value:r,disabled:o,textValue:u},m.createElement(we.div,A({role:"option","aria-labelledby":g,"data-highlighted":f?"":void 0,"aria-selected":c&&f,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1},s,{ref:h,onFocus:ne(s.onFocus,()=>p(!0)),onBlur:ne(s.onBlur,()=>p(!1)),onPointerUp:ne(s.onPointerUp,b),onPointerMove:ne(s.onPointerMove,y=>{if(o){var x;(x=l.onItemLeave)===null||x===void 0||x.call(l)}else y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ne(s.onPointerLeave,y=>{if(y.currentTarget===document.activeElement){var x;(x=l.onItemLeave)===null||x===void 0||x.call(l)}}),onKeyDown:ne(s.onKeyDown,y=>{var x;((x=l.searchRef)===null||x===void 0?void 0:x.current)!==""&&y.key===" "||(Mte.includes(y.key)&&b(),y.key===" "&&y.preventDefault())})}))))}),Qf="SelectItemText",nne=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...i}=e,s=Va(Qf,n),a=vg(Qf,n),l=kR(Qf,n),c=Ate(Qf,n),[u,d]=m.useState(null),f=$e(t,y=>d(y),l.onItemTextChange,y=>{var x;return(x=a.itemTextRefCallback)===null||x===void 0?void 0:x.call(a,y,l.value,l.disabled)}),p=u==null?void 0:u.textContent,h=m.useMemo(()=>m.createElement("option",{key:l.value,value:l.value,disabled:l.disabled},p),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:b}=c;return ar(()=>(g(h),()=>b(h)),[g,b,h]),m.createElement(m.Fragment,null,m.createElement(we.span,A({id:l.textId},i,{ref:f})),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren?Nr.createPortal(i.children,s.valueNode):null)}),rne="SelectItemIndicator",one=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return kR(rne,n).isSelected?m.createElement(we.span,A({"aria-hidden":!0},r,{ref:t})):null}),ine=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return m.createElement(we.div,A({"aria-hidden":!0},r,{ref:t}))});function SR(e){return e===""||e===void 0}const ER=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=m.useRef(null),i=$e(t,o),s=bR(n);return m.useEffect(()=>{const a=o.current,l=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(s!==n&&u){const d=new Event("change",{bubbles:!0});u.call(a,n),a.dispatchEvent(d)}},[s,n]),m.createElement(Tte,{asChild:!0},m.createElement("select",A({},r,{ref:i,defaultValue:n})))});ER.displayName="BubbleSelect";function _R(e){const t=Kt(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(s=>{const a=n.current+s;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),i=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,i]}function CR(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let s=sne(e,Math.max(i,0));o.length===1&&(s=s.filter(c=>c!==n));const l=s.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function sne(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const ane=Ite,OR=Lte,lne=zte,cne=Fte,une=Bte,TR=Vte,dne=qte,fne=Zte,PR=Qte,MR=tne,pne=nne,hne=one,NR=ine,RR=ane,mne=fne,$R=lne,Ob=m.forwardRef(({className:e,children:t,...n},r)=>v.jsxs(OR,{ref:r,className:Me("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...n,children:[t,v.jsx(cne,{asChild:!0,children:v.jsx(Cm,{className:"w-4 h-4 opacity-50"})})]}));Ob.displayName=OR.displayName;const Tb=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>v.jsx(une,{children:v.jsx(TR,{ref:o,className:Me("relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:v.jsx(dne,{className:Me("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t})})}));Tb.displayName=TR.displayName;const gne=m.forwardRef(({className:e,...t},n)=>v.jsx(PR,{ref:n,className:Me("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));gne.displayName=PR.displayName;const Pb=m.forwardRef(({className:e,children:t,...n},r)=>v.jsxs(MR,{ref:r,className:Me("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[v.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:v.jsx(hne,{children:v.jsx(n1,{className:"w-4 h-4"})})}),v.jsx(pne,{children:t})]}));Pb.displayName=MR.displayName;const vne=m.forwardRef(({className:e,...t},n)=>v.jsx(NR,{ref:n,className:Me("-mx-1 my-1 h-px bg-muted",e),...t}));vne.displayName=NR.displayName;function AR({path:e,disabled:t,source:n,schema:r,onSubmit:o}){if((typeof n=="string"||n===null)&&(r==null?void 0:r.type)==="string")return v.jsx(Cne,{path:e,defaultValue:n,disabled:t,schema:r,onSubmit:o});if((typeof n=="number"||n===null)&&(r==null?void 0:r.type)==="number")return v.jsx(i_,{defaultValue:n,disabled:t,onSubmit:o});if((typeof n=="number"||typeof n=="string"||n===null)&&(r==null?void 0:r.type)==="keyOf")return v.jsx(o_,{defaultValue:n,disabled:t,onSubmit:o,selector:r.path});if((typeof n=="number"||n===null)&&(r==null?void 0:r.type)==="number")return v.jsx(i_,{defaultValue:n,disabled:t,onSubmit:o});if((typeof n=="number"||typeof n=="string"||n===null)&&(r==null?void 0:r.type)==="keyOf")return v.jsx(o_,{defaultValue:n,disabled:t,onSubmit:o,selector:r.path});if((typeof n=="object"||n===null)&&(r==null?void 0:r.type)==="richtext")return v.jsx(_ne,{schema:r,onSubmit:o,defaultValue:n});if((typeof n=="object"||n===null)&&(r==null?void 0:r.type)==="image")return v.jsx(Sne,{path:e,onSubmit:o,defaultValue:n});if((typeof n=="object"||n===null)&&(r==null?void 0:r.type)==="file")return v.jsx(kne,{path:e,onSubmit:o,defaultValue:n});if((typeof n=="string"||n===null)&&(r==null?void 0:r.type)==="union"&&typeof r.key!="string")if(r.key.type!=="literal")console.error("Val: found union with non-literal key type. Check schema corresponding to path:",e);else return v.jsx(yne,{path:e,options:r.items.flatMap(i=>i.type==="literal"?[i.value]:[]),onSubmit:o,defaultValue:n});return v.jsxs("div",{children:["Unsupported schema: ",r.type," (source type: ",typeof n," source:"," ",JSON.stringify(n),")"]})}function yne({onSubmit:e,options:t,defaultValue:n}){const[r,o]=m.useState();m.useEffect(()=>{n!=null&&o(n)},[n]);const[i,s]=m.useState(!1);return v.jsxs(As,{children:[v.jsxs(RR,{value:r,onValueChange:a=>o(a),children:[v.jsx(Ob,{className:"w-[180px]",children:v.jsx($R,{placeholder:"Select"})}),v.jsx(Tb,{children:v.jsx(mne,{children:t.map(a=>v.jsx(Pb,{value:a,children:a},a))})})]}),e&&v.jsx(Ua,{loading:i,enabled:!!r&&t.includes(r),onClick:()=>{r&&(s(!0),e(a=>Promise.resolve(xne(a,r))).finally(()=>{s(!1)}))}})]})}function xne(e,t){return[{value:t,op:"replace",path:e}]}function IR(e,t,n,r){const o=k2(t,n,r);return!o||!r?[]:[{value:{[rn]:`/public/${o}`,[Gt]:"file",metadata:r},op:"replace",path:e},{value:t,op:"file",path:e,filePath:`/public/${o}`}]}function DR(e,t){const n=e.concat("metadata");return[{value:t,op:"replace",path:n}]}const bne=new TextEncoder;function wne(e){return new Promise((t,n)=>{var i;const r=(i=e.currentTarget.files)==null?void 0:i[0],o=new FileReader;o.addEventListener("load",()=>{const s=o.result;if(typeof s=="string"){const a=Fe.getSHA256Hash(bne.encode(s)),l=Dm(s);t({src:s,filename:r==null?void 0:r.name,sha256:a,mimeType:l,fileExt:l&&Lm(l)})}else n(s?{message:"Unexpected file result type",result:s}:{message:"Empty result"})}),r&&o.readAsDataURL(r)})}function kne({path:e,defaultValue:t,onSubmit:n}){var d,f;const[r,o]=m.useState(null),[i,s]=m.useState(!1),[a,l]=m.useState(),[c,u]=m.useState();return m.useEffect(()=>{const p=t&&Fe.convertFileSource(t).url;u(p)},[t]),v.jsxs(As,{children:[v.jsxs("div",{className:"w-fit",children:[v.jsx("div",{className:"flex flex-col justify-start p-2 border border-b-0 rounded-sm rounded-b-none gap-y-4 bg-background text-foreground border-input",children:r||c?v.jsxs("div",{className:"relative flex flex-col justify-center items-center min-h-[100px] min-w-[200px]",children:[v.jsx("div",{children:v.jsx(P5,{})}),v.jsx("div",{children:r==null?void 0:r.filename})]}):v.jsx("div",{children:"Select file below"})},e),v.jsxs("div",{className:"p-4 border border-t-0 rounded-b-sm bg-background border-input",children:[v.jsx("label",{htmlFor:`img_input:${e}`,className:"block px-1 py-2 text-sm text-center rounded-md cursor-pointer bg-primary text-background",children:"Update"}),v.jsx("input",{hidden:!0,id:`img_input:${e}`,type:"file",onChange:p=>{wne(p).then(h=>{o({src:h.src,filename:h.filename}),h.mimeType?l({sha256:h.sha256,mimeType:h.mimeType}):l(void 0)}).catch(h=>{console.error(h.message),o(null),l(void 0)})}})]})]}),n&&v.jsx(Ua,{loading:i,enabled:!!r||((d=t==null?void 0:t.metadata)==null?void 0:d.mimeType)!==(a==null?void 0:a.mimeType)||((f=t==null?void 0:t.metadata)==null?void 0:f.sha256)!==(a==null?void 0:a.sha256),onClick:()=>{r?(s(!0),n(p=>Promise.resolve(IR(p,r.src,r.filename??null,a))).finally(()=>{s(!1),o(null),l(void 0)})):a&&(s(!0),n(p=>Promise.resolve(DR(p,a))).finally(()=>{s(!1),o(null),l(void 0)}))}})]})}function Sne({path:e,defaultValue:t,onSubmit:n}){var p,h,g,b,y,x,w,k,S,O,E,P;const[r,o]=m.useState(null),[i,s]=m.useState(!1),[a,l]=m.useState(),[c,u]=m.useState(),[d,f]=m.useState();return m.useEffect(()=>{f(t&&"/api/val/files/public"+Fe.convertFileSource(t).url)},[t]),m.useEffect(()=>{var N;if(c)if(a){const $={...a,hotspot:c};l($)}else t!=null&&t.metadata?l({...t.metadata,hotspot:c}):console.error("Neither image metadata nor value is set");else(N=t==null?void 0:t.metadata)!=null&&N.hotspot&&u(t.metadata.hotspot)},[c,t]),v.jsxs(As,{children:[v.jsxs("div",{className:"w-fit",children:[v.jsx("div",{className:"flex flex-col justify-start p-2 border border-b-0 rounded-sm rounded-b-none gap-y-4 bg-background text-foreground border-input",children:r||d?v.jsxs("div",{className:"relative",children:[c&&v.jsx("div",{className:"rounded-full h-[12px] w-[12px] bg-background mix-blend-difference border-accent border-2 absolute pointer-events-none",style:{top:`${c.y*100}%`,left:`${c.x*100}%`}}),v.jsx("img",{src:(r==null?void 0:r.src)||d,draggable:!1,className:"object-contain w-full max-h-[500px]",style:{cursor:"crosshair"},onClick:N=>{const{width:$,height:z,left:j,top:le}=N.currentTarget.getBoundingClientRect(),U=(N.clientX-6-j)/$,K=(N.clientY-6-le)/z;u({x:U,y:K,width:1,height:1})}})]}):v.jsx("div",{children:"Select image below"})},e),v.jsxs("div",{className:"p-4 border border-t-0 rounded-b-sm bg-background border-input",children:[v.jsx("label",{htmlFor:`img_input:${e}`,className:"block px-1 py-2 text-sm text-center rounded-md cursor-pointer bg-primary text-background",children:"Update"}),v.jsx("input",{hidden:!0,id:`img_input:${e}`,type:"file",onChange:N=>{w2(N).then($=>{o({src:$.src,filename:$.filename}),$.width&&$.height&&$.mimeType?l({sha256:$.sha256,width:$.width,height:$.height,mimeType:$.mimeType,hotspot:c}):(l(void 0),u(void 0))}).catch($=>{console.error($.message),o(null),u(void 0),l(void 0)})}})]})]}),n&&v.jsx(Ua,{loading:i,enabled:!!r||((h=(p=t==null?void 0:t.metadata)==null?void 0:p.hotspot)==null?void 0:h.height)!==(c==null?void 0:c.height)||((b=(g=t==null?void 0:t.metadata)==null?void 0:g.hotspot)==null?void 0:b.width)!==(c==null?void 0:c.width)||((x=(y=t==null?void 0:t.metadata)==null?void 0:y.hotspot)==null?void 0:x.x)!==(c==null?void 0:c.x)||((k=(w=t==null?void 0:t.metadata)==null?void 0:w.hotspot)==null?void 0:k.y)!==(c==null?void 0:c.y)||((S=t==null?void 0:t.metadata)==null?void 0:S.width)!==(a==null?void 0:a.width)||((O=t==null?void 0:t.metadata)==null?void 0:O.height)!==(a==null?void 0:a.height)||((E=t==null?void 0:t.metadata)==null?void 0:E.mimeType)!==(a==null?void 0:a.mimeType)||((P=t==null?void 0:t.metadata)==null?void 0:P.sha256)!==(a==null?void 0:a.sha256),onClick:()=>{r?(s(!0),n(N=>Promise.resolve(IR(N,r.src,r.filename??null,a))).finally(()=>{s(!1)})):a&&(s(!0),n(N=>Promise.resolve(DR(N,a))).finally(()=>{s(!1)}))}})]})}function Ene(e,t){const{templateStrings:n,exprs:r,files:o}=t?kj(t):{[Gt]:"richtext",templateStrings:[""],exprs:[],files:{}};return[{op:"replace",path:e,value:{templateStrings:n,exprs:r,[Gt]:"richtext"}},...Object.entries(o).map(([i,s])=>({op:"file",path:e,filePath:i,value:s}))]}function _ne({defaultValue:e,schema:t,onSubmit:n}){const[r,o]=m.useState(!1),[i,s]=m.useState(!1),[a,l]=m.useState();m.useEffect(()=>{o(!0),l(void 0)},[e]);const{state:c,manager:u}=Ete(e&&Rj(l2(e)));return v.jsxs(As,{children:[v.jsx(_te,{options:t.options,onChange:d=>{o(!0),l(d)},state:c,manager:u}),n&&v.jsx(Ua,{loading:i,enabled:r,onClick:()=>{if(a){s(!0);const d=Nj.safeParse(a);d.success?n(async f=>Ene(f,d.data)).finally(()=>{s(!1),o(!1)}):(s(!1),alert(`Could not parse Rich Text
211
215
  `+JSON.stringify(d.error,null,2)))}}})]})}function o_({disabled:e,defaultValue:t,onSubmit:n,selector:r}){return v.jsx("div",{children:"TODO"})}function i_({disabled:e,defaultValue:t,onSubmit:n}){const[r,o]=m.useState(t||0),[i,s]=m.useState(!1);m.useEffect(()=>{s(e)},[e]);const a=m.useRef(null);return v.jsxs(As,{children:[v.jsx(b1,{ref:a,disabled:i,defaultValue:r??0,onChange:l=>o(Number(l.target.value)),type:"number"}),n&&v.jsx(Ua,{loading:i,enabled:t!==r,onClick:()=>{s(!0),n(async l=>{var c;return[{op:"replace",path:l,value:Number((c=a.current)==null?void 0:c.value)||0}]}).finally(()=>{s(!1)})}})]})}function Cne({disabled:e,defaultValue:t,path:n,schema:r,onSubmit:o}){const[i,s]=m.useState(t||""),[a,l]=m.useState(!1);m.useEffect(()=>{l(e)},[e]);const c=m.useRef(null),d=new qO(r.options?{...r.options,regexp:r.options.regexp?new RegExp(r.options.regexp.source,r.options.regexp.flags):void 0}:void 0).validate(n,i);return v.jsxs(As,{children:[v.jsx(b1,{ref:c,disabled:a,defaultValue:i??"",onChange:f=>s(f.target.value)}),o&&v.jsx(Ua,{validationErrors:d&&d[n],loading:a,enabled:!0,onClick:()=>{l(!0),o(async f=>{var p;return[{op:"replace",path:f,value:((p=c.current)==null?void 0:p.value)||""}]}).finally(()=>{l(!1)})}})]})}function One({errors:e}){return v.jsx("div",{className:"flex flex-col p-2 text-sm rounded-md gap-y-1 text-destructive-foreground bg-destructive",children:e.map((t,n)=>v.jsx("div",{children:t.message},n))})}function As({children:e,className:t}){return v.jsx("div",{className:It("relative max-w-lg px-4 pt-4",t),children:e})}function Ua({loading:e,enabled:t,validationErrors:n,onClick:r}){const{session:o}=Tm(),i=o.status==="success"&&o.data.mode==="proxy";return v.jsx("div",{className:"sticky bottom-0 m-4 mt-2 ml-0",children:v.jsxs("div",{className:"grid justify-start gap-2 text",children:[n?v.jsx(One,{errors:n||[]}):v.jsx("span",{}),v.jsx(ec,{disabled:e||!t,onClick:r,children:e?i?"Staging...":"Saving...":i?"Stage":"Save"})," "]})})}const Mb=m.forwardRef(({className:e,...t},n)=>v.jsx("div",{ref:n,className:Me("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Mb.displayName="Card";const Tne=m.forwardRef(({className:e,...t},n)=>v.jsx("div",{ref:n,className:Me("flex flex-col space-y-1.5 p-6",e),...t}));Tne.displayName="CardHeader";const Pne=m.forwardRef(({className:e,...t},n)=>v.jsx("h3",{ref:n,className:Me("text-2xl font-semibold leading-none tracking-tight",e),...t}));Pne.displayName="CardTitle";const Mne=m.forwardRef(({className:e,...t},n)=>v.jsx("p",{ref:n,className:Me("text-sm text-muted-foreground",e),...t}));Mne.displayName="CardDescription";const Nne=m.forwardRef(({className:e,...t},n)=>v.jsx("div",{ref:n,className:Me("p-6 pt-0",e),...t}));Nne.displayName="CardContent";const Rne=m.forwardRef(({className:e,...t},n)=>v.jsx("div",{ref:n,className:Me("flex items-center p-6 pt-0",e),...t}));Rne.displayName="CardFooter";const LR="Switch",[$ne,_ie]=Rr(LR),[Ane,Ine]=$ne(LR),Dne=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:c,...u}=e,[d,f]=m.useState(null),p=$e(t,x=>f(x)),h=m.useRef(!1),g=d?!!d.closest("form"):!0,[b=!1,y]=Oo({prop:o,defaultProp:i,onChange:c});return m.createElement(Ane,{scope:n,checked:b,disabled:a},m.createElement(we.button,A({type:"button",role:"switch","aria-checked":b,"aria-required":s,"data-state":zR(b),"data-disabled":a?"":void 0,disabled:a,value:l},u,{ref:p,onClick:ne(e.onClick,x=>{y(w=>!w),g&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})})),g&&m.createElement(jne,{control:d,bubbles:!h.current,name:r,value:l,checked:b,required:s,disabled:a,style:{transform:"translateX(-100%)"}}))}),Lne="SwitchThumb",jR=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Ine(Lne,n);return m.createElement(we.span,A({"data-state":zR(o.checked),"data-disabled":o.disabled?"":void 0},r,{ref:t}))}),jne=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,i=m.useRef(null),s=bR(n),a=kN(t);return m.useEffect(()=>{const l=i.current,c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&d){const f=new Event("click",{bubbles:r});d.call(l,n),l.dispatchEvent(f)}},[s,n,r]),m.createElement("input",A({type:"checkbox","aria-hidden":!0,defaultChecked:n},o,{tabIndex:-1,ref:i,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function zR(e){return e?"checked":"unchecked"}const Nb=Dne,zne=jR,FR=m.forwardRef(({className:e,...t},n)=>v.jsx(Nb,{className:Me("peer inline-flex h-[22px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-accent data-[state=unchecked]:bg-primary",e),...t,ref:n,children:v.jsx(zne,{className:Me("pointer-events-none block h-[18px] w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));FR.displayName=Nb.displayName;const BR="Dialog",[VR,Cie]=Rr(BR),[Fne,fo]=VR(BR),Bne=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!0}=e,a=m.useRef(null),l=m.useRef(null),[c=!1,u]=Oo({prop:r,defaultProp:o,onChange:i});return m.createElement(Fne,{scope:t,triggerRef:a,contentRef:l,contentId:Er(),titleId:Er(),descriptionId:Er(),open:c,onOpenChange:u,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),modal:s},n)},Vne="DialogTrigger",Une=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fo(Vne,n),i=$e(t,o.triggerRef);return m.createElement(we.button,A({type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Rb(o.open)},r,{ref:i,onClick:ne(e.onClick,o.onOpenToggle)}))}),UR="DialogPortal",[Hne,HR]=VR(UR,{forceMount:void 0}),Wne=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,i=fo(UR,t);return m.createElement(Hne,{scope:t,forceMount:n},m.Children.map(r,s=>m.createElement(Nn,{present:n||i.open},m.createElement(ug,{asChild:!0,container:o},s))))},G0="DialogOverlay",Kne=m.forwardRef((e,t)=>{const n=HR(G0,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=fo(G0,e.__scopeDialog);return i.modal?m.createElement(Nn,{present:r||i.open},m.createElement(qne,A({},o,{ref:t}))):null}),qne=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fo(G0,n);return m.createElement(fg,{as:ci,allowPinchZoom:!0,shards:[o.contentRef]},m.createElement(we.div,A({"data-state":Rb(o.open)},r,{ref:t,style:{pointerEvents:"auto",...r.style}})))}),Hd="DialogContent",Gne=m.forwardRef((e,t)=>{const n=HR(Hd,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=fo(Hd,e.__scopeDialog);return m.createElement(Nn,{present:r||i.open},i.modal?m.createElement(Yne,A({},o,{ref:t})):m.createElement(Xne,A({},o,{ref:t})))}),Yne=m.forwardRef((e,t)=>{const n=fo(Hd,e.__scopeDialog),r=m.useRef(null),o=$e(t,n.contentRef,r);return m.useEffect(()=>{const i=r.current;if(i)return sg(i)},[]),m.createElement(WR,A({},e,{ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ne(e.onCloseAutoFocus,i=>{var s;i.preventDefault(),(s=n.triggerRef.current)===null||s===void 0||s.focus()}),onPointerDownOutside:ne(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&i.preventDefault()}),onFocusOutside:ne(e.onFocusOutside,i=>i.preventDefault())}))}),Xne=m.forwardRef((e,t)=>{const n=fo(Hd,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return m.createElement(WR,A({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var s;if((s=e.onCloseAutoFocus)===null||s===void 0||s.call(e,i),!i.defaultPrevented){var a;r.current||(a=n.triggerRef.current)===null||a===void 0||a.focus(),i.preventDefault()}r.current=!1,o.current=!1},onInteractOutside:i=>{var s,a;(s=e.onInteractOutside)===null||s===void 0||s.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const l=i.target;((a=n.triggerRef.current)===null||a===void 0?void 0:a.contains(l))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}}))}),WR=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,...s}=e,a=fo(Hd,n),l=m.useRef(null),c=$e(t,l);return lg(),m.createElement(m.Fragment,null,m.createElement(cg,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i},m.createElement(ag,A({role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Rb(a.open)},s,{ref:c,onDismiss:()=>a.onOpenChange(!1)}))),!1)}),Zne="DialogTitle",Jne=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fo(Zne,n);return m.createElement(we.h2,A({id:o.titleId},r,{ref:t}))}),Qne="DialogDescription",ere=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fo(Qne,n);return m.createElement(we.p,A({id:o.descriptionId},r,{ref:t}))}),tre="DialogClose",nre=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fo(tre,n);return m.createElement(we.button,A({type:"button"},r,{ref:t,onClick:ne(e.onClick,()=>o.onOpenChange(!1))}))});function Rb(e){return e?"open":"closed"}const rre=Bne,ore=Une,ire=Wne,KR=Kne,qR=Gne,GR=Jne,YR=ere,XR=nre,sre=rre,are=ore,lre=ire,s_=XR,ZR=m.forwardRef(({className:e,...t},n)=>v.jsx(KR,{ref:n,className:Me("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));ZR.displayName=KR.displayName;const JR=m.forwardRef(({className:e,children:t,...n},r)=>v.jsxs(lre,{children:[v.jsx(ZR,{}),v.jsxs(qR,{ref:r,className:Me("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full",e),...n,children:[t,v.jsxs(XR,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[v.jsx(Om,{className:"w-4 h-4"}),v.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));JR.displayName=qR.displayName;const QR=({className:e,...t})=>v.jsx("div",{className:Me("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});QR.displayName="DialogHeader";const e$=({className:e,...t})=>v.jsx("div",{className:Me("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});e$.displayName="DialogFooter";const t$=m.forwardRef(({className:e,...t},n)=>v.jsx(GR,{ref:n,className:Me("text-lg font-semibold leading-none tracking-tight",e),...t}));t$.displayName=GR.displayName;const cre=m.forwardRef(({className:e,...t},n)=>v.jsx(YR,{ref:n,className:Me("text-sm text-muted-foreground",e),...t}));cre.displayName=YR.displayName;const $b=W.createContext({hardLink:!1,useNavigate:yg,basePath:"",sourcePath:"",moduleId:"",modulePath:""});function Rv(e){return e?`/${decodeURIComponent(e)}`:""}function Ab({children:e,overlay:t}){const[n,r]=W.useState(""),[o,i]=W.useState(Rv(n));m.useEffect(()=>{if(!t){const l=fre();l&&i(Rv(l)),window.onpopstate=()=>{const c=window.location.pathname.split("/"),u=Ib(c),d=(u===-1?c:c.slice(u+1)).join("/");i(Rv(d)),r(d)}}},[]);const[s,a]=Fe.splitModuleIdAndModulePath(o);return v.jsx($b.Provider,{value:{hardLink:!!t,useNavigate:()=>l=>{t?window.location.href=`/val${l}`:(i(l),ure(l),r(l))},basePath:n,moduleId:s,modulePath:a,sourcePath:o},children:e})}function ure(e){const t=window.location.pathname.split("/"),n=Ib(t),r=`${t.slice(0,n+1).concat(...e.split("/").slice(1)).join("/")}`;window.history.pushState(null,"",r)}function yg(){return m.useContext($b).useNavigate()}function dre(){const e=m.useContext($b);return{basePath:e.basePath,sourcePath:e.sourcePath,moduleId:e.moduleId,modulePath:e.modulePath}}function fre(){const e=window.location.pathname.split("/"),t=Ib(e);return(t===-1?e:e.slice(t+1)).join("/")}function Ib(e){const t=e.indexOf("static"),n=t===-1?e.indexOf("val"):t;return n===-1&&console.error("Router error",e,n),n}function xg({path:e,source:t,schema:n,field:r,initOnSubmit:o,top:i}){if(n.opt)return v.jsx(vre,{path:e,source:t,schema:n,field:r,initOnSubmit:o});if(t===null)return v.jsx(o$,{source:t,schema:n,path:e,initOnSubmit:o});if(n.type==="object")return typeof t!="object"||Tl(t)?v.jsxs("div",{children:["ERROR: expected object, but found ",typeof t]}):v.jsxs("div",{children:[r&&v.jsx("div",{className:"text-left",children:r}),v.jsx(n$,{source:t,path:e,schema:n,initOnSubmit:o,top:i})]});if(n.type==="array")return typeof t!="object"||!Tl(t)?v.jsxs("div",{children:["ERROR: expected array, but found ",typeof t]}):v.jsxs("div",{children:[r&&v.jsx("div",{className:"text-left",children:r}),v.jsx(r$,{source:t,path:e,schema:n,initOnSubmit:o})]});if(n.type==="record")return typeof t!="object"?v.jsxs("div",{children:["ERROR: expected object for ",n.type,", but found ",typeof t]}):Tl(t)?v.jsxs("div",{children:["ERROR: did not expect array for ",n.type]}):v.jsxs("div",{children:[r&&v.jsx("div",{className:"text-left",children:r}),v.jsx(hre,{source:t,path:e,schema:n})]});if((n==null?void 0:n.type)==="union"){if(typeof n.key=="string"&&typeof t=="object"&&!Tl(t))return v.jsx(pre,{field:r,tag:n.key,source:t,path:e,schema:n,initOnSubmit:o,top:i})}else if((n==null?void 0:n.type)==="literal")return v.jsx(v.Fragment,{});return v.jsxs("div",{className:"py-2 gap-y-4",children:[r&&v.jsx("div",{className:"text-left",children:r}),v.jsx(AR,{path:e,disabled:!1,source:t,schema:n,onSubmit:o(e)})]})}function pre({tag:e,field:t,path:n,source:r,schema:o,initOnSubmit:i,top:s}){const[a,l]=m.useState(null),[c,u]=m.useState(null),d=o.items.flatMap(h=>{if(h.type==="object"&&h.items[e]){const g=h.items[e];if(g.type==="literal")return[g.value]}return[]});m.useEffect(()=>{if(a){const h=r[e],g=o.items.find(b=>{if(b.type==="object"&&b.items[e]){const y=b.items[e];return y.type==="literal"?y.value===a:!1}});h&&typeof h=="string"&&g?u({source:r,schema:g}):g?u({schema:g}):(console.error("Could not find source or schema of key",a,r,o),u(null))}else{const h=r==null?void 0:r[e];h&&typeof h=="string"&&l(h)}},[a,r,e,o,d]),d.length!==o.items.length&&console.warn("Not all items have tag:",e);const f=!1,p=i(n);return v.jsxs(As,{className:It("flex flex-col gap-y-4",{"border-l-2 border-border pl-6":!s}),children:[(t||o.key)&&v.jsx("div",{className:"text-left",children:t||o.key}),v.jsxs(RR,{value:a??void 0,disabled:f,onValueChange:h=>{l(h)},children:[v.jsx(Ob,{children:v.jsx($R,{placeholder:"Select type"})}),v.jsx(Tb,{children:d.map(h=>v.jsx(Pb,{value:h.toString(),children:h.toString()},h))})]}),v.jsx(Ua,{loading:f,enabled:!1,onClick:()=>p(async()=>[])}),c&&v.jsx(xg,{path:n,source:c.source??null,schema:c.schema,initOnSubmit:i,top:s})]},n)}function n$({path:e,source:t,schema:n,initOnSubmit:r,top:o}){return v.jsx("div",{className:It("flex flex-col gap-y-1",{"border-l-2 border-border pl-6":!o}),children:Object.entries(n.items).map(([i,s])=>{const a=hc(e,i);return v.jsx(xg,{path:a,source:(t==null?void 0:t[i])??null,schema:s,field:i,initOnSubmit:r},a)})},e)}function hre({path:e,source:t,schema:n}){const r=yg();return v.jsx("div",{className:"flex flex-col gap-4 p-2",children:Object.entries(t).map(([o,i])=>{const s=hc(e,o);return v.jsx("button",{onClick:()=>{r(s)},children:v.jsx(mre,{recordKey:o,path:s,source:i,schema:n.item})},s)})},e)}const Y0=170;function mre({recordKey:e,path:t,source:n,schema:r}){const o=W.useRef(null),[i,s]=m.useState(!1);return m.useEffect(()=>{o.current&&o.current.getBoundingClientRect().height>=Y0&&s(!0)},[]),v.jsxs(Mb,{ref:o,className:"relative px-4 pt-2 pb-4 overflow-hidden border gap-y-2",style:{maxHeight:Y0},children:[v.jsx("div",{className:"pb-4 font-serif text-left text-accent",children:e}),v.jsx("div",{className:"text-xs",children:v.jsx(Db,{path:t,source:n,schema:r})}),i&&v.jsx("div",{className:"absolute bottom-0 left-0 w-full h-[20px] bg-gradient-to-b from-transparent to-background"})]},t)}function r$({path:e,source:t,schema:n,initOnSubmit:r}){const o=r(e),[,i]=Fe.splitModuleIdAndModulePath(e);return v.jsxs(As,{className:"flex flex-col gap-4 p-2 pb-8",children:[v.jsx("button",{onClick:()=>{o(async()=>{const s=[];return t===null&&s.push({op:"replace",path:Fe.createPatchPath(i),value:[]}),s.push({op:"add",path:Fe.createPatchPath(hc(i,t.length)),value:Wd(n.item)}),s})},children:v.jsx(V5,{})}),t.map((s,a)=>{const l=hc(e,a),c=r(l);return v.jsx(gre,{index:a,path:l,source:s,loading:!1,schema:n.item,onDelete:()=>{c(async u=>u.length>0?[{op:"remove",path:u}]:(console.error("Cannot delete a root element"),[]))}},l)})]},e)}const a_=Y0;function gre({index:e,path:t,source:n,schema:r,loading:o,onDelete:i}){const s=yg(),a=W.useRef(null),[l,c]=m.useState(!1);return m.useEffect(()=>{a.current&&a.current.getBoundingClientRect().height>=a_&&c(!0)},[]),v.jsxs(Mb,{ref:a,className:"relative px-4 pt-2 pb-4 overflow-hidden border gap-y-2",style:{maxHeight:a_},children:[v.jsx("button",{className:"block",disabled:o,onClick:i,children:o?v.jsx(U5,{className:"animate-spin"}):v.jsx(yT,{})}),v.jsxs("button",{className:"block",disabled:o,onClick:()=>{s(t)},children:[v.jsx("div",{className:"pb-4 font-serif text-left uppercase text-accent",children:e+1<10?`0${e+1}`:e+1}),v.jsx("div",{className:"text-xs",children:v.jsx(Db,{path:t,source:n,schema:r})}),l&&v.jsx("div",{className:"absolute bottom-0 left-0 w-full h-[20px] bg-gradient-to-b from-transparent to-background"})]})]})}function hc(e,t){const n=Fe.createValPathOfItem(e,t);if(!n)throw Error(`Could not create val path: ${e} of ${t==null?void 0:t.toString()}`);return n}function Db({path:e,source:t,schema:n}){var s;const[r,o]=m.useState(null),i=(s=wre())==null?void 0:s.hoverElem;if(n.type==="object")return v.jsx("div",{className:"grid grid-cols-[min-content_1fr] gap-2 text-left",children:Object.entries(n.items).map(([a])=>v.jsxs(m.Fragment,{children:[v.jsxs("span",{className:"text-muted",children:[a,":"]}),v.jsx("span",{children:v.jsx(Db,{source:(t==null?void 0:t[a])??null,schema:n.items[a],path:hc(e,a)})})]},hc(e,a)))},e);if(n.type==="array")return t===null?v.jsx("span",{className:"text-accent",children:"Empty"},e):Array.isArray(t)?v.jsxs("span",{children:[v.jsx("span",{className:"text-accent",children:t.length}),v.jsx("span",{children:t.length===1?" item":" items"})]},e):v.jsx("span",{className:"px-2 bg-destructive text-destructive-foreground",children:"Unknown length"},e);if(n.type==="richtext")return t===null?v.jsx("span",{className:"text-accent",children:"Empty"},e):typeof t!="object"?v.jsxs("div",{className:"p-4 text-destructive-foreground bg-destructive",children:["ERROR: ",typeof t," not an object"]},e):!(Gt in t)||t[Gt]!=="richtext"?v.jsx("div",{className:"p-4 text-destructive-foreground bg-destructive",children:"ERROR: object is not richtext"},e):v.jsx(bre,{children:l2(t)},e);if(n.type==="string")return t===null?v.jsx("span",{className:"text-accent",children:"Empty"},e):v.jsx("span",{children:t});if(n.type==="image"){if(t===null)return v.jsx("span",{className:"text-accent",children:"Empty"},e);if(typeof t!="object")return v.jsx("div",{className:"p-4 text-destructive-foreground bg-destructive",children:"ERROR: not an object"},e);if(!(rn in t)||typeof t[rn]!="string")return v.jsx("div",{className:"p-4 text-destructive-foreground bg-destructive",children:"ERROR: object is not an image"},e);const a=Fe.convertFileSource(t).url;return v.jsxs("span",{onMouseOver:l=>{o({x:l.clientX,y:l.clientY})},onMouseLeave:()=>{o(null)},className:"relative flex items-center justify-start gap-1",children:[v.jsx("a",{href:a,className:"overflow-hidden underline truncate ",children:t[rn]}),r&&i&&Nr.createPortal(v.jsx("img",{className:"absolute z-[5] max-w-[10vw]",style:{left:r.x+10,top:r.y+10},src:a}),i)]},e)}else{if(n.type==="boolean")return t===null?v.jsx("span",{className:"text-accent",children:"Empty"},e):v.jsx("span",{className:"text-accent",children:t?"true":"false"},e);if(n.type==="number")return t===null?v.jsx("span",{className:"text-accent",children:"Empty"},e):v.jsx("span",{className:"text-accent",children:t.toString()});if(n.type==="keyOf")return t===null?v.jsx("span",{className:"text-accent",children:"Empty"},e):v.jsx("span",{className:"text-accent",children:t.toString()},e)}return v.jsxs("div",{children:["TODO: ",n.type]},e)}function vre({path:e,source:t,schema:n,initOnSubmit:r,field:o}){const[i,s]=m.useState(t!==null),{editMode:a}=Tm(),l=r(e),[c,u]=m.useState(!1);return v.jsxs("div",{className:"flex flex-col gap-y-2",children:[v.jsxs("div",{className:"relative flex items-center justify-start gap-x-4",children:[a==="full"&&!i&&v.jsx(FR,{disabled:c,checked:i,onClick:()=>{s(d=>!d)}}),a==="full"&&i&&v.jsxs(sre,{children:[v.jsx(are,{children:v.jsx(yT,{})}),v.jsx(JR,{children:v.jsxs(QR,{children:[v.jsx(t$,{children:"About to delete. Are you sure?"}),v.jsxs(e$,{className:"sm:justify-start",children:[v.jsx(s_,{asChild:!0,children:v.jsx(ec,{type:"button",variant:"secondary",onClick:async()=>{u(!0),s(!1);const[,d]=Fe.splitModuleIdAndModulePath(e);l(async()=>[{op:"replace",path:Fe.createPatchPath(d),value:null}]).catch(f=>{console.error(f),s(!0)}).finally(()=>{u(!1)})},children:"Yes"})}),v.jsx(s_,{asChild:!0,children:v.jsx(ec,{type:"button",children:"Cancel"})})]})]})})]}),v.jsx("div",{className:"truncate max-w-[300px] text-left",title:e,dir:"rtl",children:o||v.jsx(ba,{children:e})})]}),i&&v.jsx(o$,{source:t===null?Wd(n):t,schema:n,path:e,initOnSubmit:d=>async f=>{const[,p]=Fe.splitModuleIdAndModulePath(e),[,h]=Fe.splitModuleIdAndModulePath(d),g=await f(Fe.createPatchPath(h));l(async()=>t===null?[{op:"replace",path:Fe.createPatchPath(p),value:Wd(n)}].concat(g):g)}})]},e)}function Wd(e){if(e.type==="object")return Object.fromEntries(Object.keys(e.items).map(n=>[n,Wd(e.items[n])]));if(e.type==="array")return[];if(e.type==="record")return{};if(e.opt)return null;if(e.type==="richtext")return{[Gt]:"richtext",templateStrings:[""],exprs:[]};if(e.type==="string")return"";if(e.type==="boolean")return!1;if(e.type==="number")return 0;if(e.type==="keyOf")return e.values==="number"?0:e.values==="string"?"":e.values[0];if(e.type==="file")return{_ref:"/public/",_type:"file",metadata:{sha256:""}};if(e.type==="image")return{_ref:"/public/",_type:"file",metadata:{height:0,width:0,mimeType:"application/octet-stream",sha256:""}};if(e.type==="literal")return e.value;if(e.type==="union")return Wd(e.items[0]);throw Error("Unexpected schema type: "+JSON.stringify(e))}function o$({source:e,path:t,schema:n,initOnSubmit:r}){if(n.type==="array"){if(typeof e=="object"&&(e===null||Tl(e)))return v.jsx(r$,{initOnSubmit:r,source:e===null?[]:e,path:t,schema:n})}else if(n.type==="object"){if(typeof e=="object"&&(e===null||!Tl(e)))return v.jsx(n$,{source:e,path:t,schema:n,initOnSubmit:r})}else if(n.type==="richtext"||n.type==="string"||n.type==="image"||n.type==="number"||n.type==="keyOf"||n.type==="boolean"||n.type==="literal"||n.type==="union")return v.jsx(AR,{path:t,disabled:!1,source:e,schema:n,onSubmit:r(t)},t);return v.jsxs("div",{className:"p-4 bg-destructive text-destructive-foreground",children:["ERROR: unexpected source type ",typeof e," for schema type"," ",n.type]})}function Tl(e){return Array.isArray(e)}function yre(e){const t={};return e.forEach(n=>{const r=n.split("/").filter(o=>o!=="");if(r.length===1)t[""]||(t[""]=[]),t[""].push(r[0]);else if(r.length>1){const o=r.slice(0,r.length-1).join("/"),i=r.slice(-1)[0];t[o]||(t[o]=[]),t[o].push(i)}}),t}function xre({selectedPath:e,paths:t}){const n=yre(t),r=e&&Fe.splitModuleIdAndModulePath(e)[0],o=yg();return v.jsx("div",{className:"flex flex-col w-full py-2 text-xs",children:Object.entries(n).map(([i,s])=>v.jsxs("div",{className:"px-4 py-2",children:[i&&v.jsx("div",{className:"font-bold truncate max-w-[300px] text-left",title:i,children:v.jsx(ba,{children:i})}),v.jsx("div",{className:It({"flex flex-col py-2 justify-start items-start":!!i}),children:s.map(a=>{const l=`/${i}/${a}`;return v.jsx("button",{className:It("block px-2 py-1 rounded-full",{"bg-accent text-accent-foreground":r===l}),onClick:()=>{o(l)},children:a},l)})})]},`/${i}`))})}const l_={tags:{h1:"font-bold",h2:"font-bold",h3:"font-bold",h4:"font-bold",h5:"font-bold",h6:"font-bold",p:""},classes:{bold:"font-bold",italic:"italic",lineThrough:"line-through"}};function bre({children:e}){const t=e;function n(i,s){const a=l_.tags[i];return a&&s?[s,a].join(" "):a||s}function r(i,s){const a=l_.classes[i];return a&&s?[s,a].join(" "):a||s}function o(i,s){var c,u;if(typeof i=="string")return i;if(i.tag==="p")return v.jsx("p",{className:n("p"),children:i.children.map((d,f)=>o(d,f))},s);if(i.tag==="img")return v.jsx("img",{className:n("img"),src:i.src},s);if(i.tag==="ul")return v.jsx("ul",{className:n("ul"),children:i.children.map((d,f)=>o(d,f))},s);if(i.tag==="ol")return v.jsx("ol",{className:n("ol"),children:i.children.map((d,f)=>o(d,f))},s);if(i.tag==="li")return v.jsx("li",{className:n("li"),children:i.children.map((d,f)=>o(d,f))},s);if(i.tag==="span")return v.jsx("span",{className:i.classes.map(d=>{switch(d){case"bold":return r("bold");case"line-through":return r("lineThrough");case"italic":return r("italic")}}).join(" "),children:i.children.map((d,f)=>o(d,f))},s);if(i.tag==="h1")return v.jsx("h1",{className:n("h1"),children:i.children.map((d,f)=>o(d,f))},s);if(i.tag==="h2")return v.jsx("h2",{className:n("h2"),children:i.children.map((d,f)=>o(d,f))},s);if(i.tag==="h3")return v.jsx("h3",{className:n("h3"),children:i.children.map((d,f)=>o(d,f))},s);if(i.tag==="h4")return v.jsx("h4",{className:n("h4"),children:i.children.map((d,f)=>o(d,f))},s);if(i.tag==="h5")return v.jsx("h5",{className:n("h5"),children:i.children.map((d,f)=>o(d,f))},s);if(i.tag==="h6")return v.jsx("h6",{className:n("h6"),children:i.children.map((d,f)=>o(d,f))},s);if(i.tag==="br")return v.jsx("br",{},s);if(i.tag==="a")return v.jsx("a",{href:i.href,children:i.children.map((d,f)=>o(d,f))},s);console.error("Unknown tag",i.tag);const l=i.tag;return l!=null&&l.tag?W.createElement(l.tag,{key:s,className:(c=l.class)==null?void 0:c.join(" "),children:(u=l.children)==null?void 0:u.map(o)}):null}return v.jsx("span",{"data-val-path":t.valPath,children:t.children.map((i,s)=>o(i,s))})}const i$=W.createContext({hoverElem:null}),wre=()=>W.useContext(i$),s$=({api:e,store:t})=>{const[n,r]=m.useState(null),i=dre().sourcePath||"",[s,a]=m.useState(),[l,c]=m.useState("not-asked");m.useEffect(()=>{l==="not-asked"&&(c("running"),t.initialize().then(S=>{He.isOk(S)?(a(S.value),c("complete")):(r(S.error.message),c("failed"))}))},[l]);const u=MT(e),[d,f]=bT(),{patches:p,setPatchResetId:h}=wT(u,e),g=W.useRef(null),b=m.useCallback(S=>async O=>{const[E,P]=Fe.splitModuleIdAndModulePath(S),N=await O(Fe.createPatchPath(P));t.applyPatch(E,N),h($=>$+1)},[]),[y,x]=m.useState(!1),[w,k]=m.useState();return m.useEffect(()=>{let S=!1;return s!==void 0&&(x(!0),e.postValidate({patches:p}).then(O=>{S||(He.isOk(O)?k({globalError:null,validationErrors:O.value}):k({globalError:{message:"Could not validate changes: check if Val is correctly setup.",details:O.error}}),x(!1))}).catch(O=>{S||(k({globalError:{message:"Could not validate changes: check the internet connection.",details:O}}),x(!1))})),()=>{S=!0}},[p,s]),v.jsx(r1.Provider,{value:{theme:d,setTheme:f,editMode:"full",session:u,setEditMode:()=>{},setWindowSize:()=>{}},children:v.jsxs("div",{id:"val-fullscreen-container",className:"relative w-full h-[100] overflow-hidden font-serif antialiased bg-background text-primary","data-mode":d,children:[v.jsx("div",{id:"val-fullscreen-hover",ref:g}),v.jsx(i$.Provider,{value:{hoverElem:g==null?void 0:g.current},children:v.jsx("div",{className:"text-primary",children:v.jsxs(Iu,{children:[v.jsx("div",{className:"px-4 h-[50px] flex items-center justify-center",children:v.jsx(xT,{})}),v.jsx(Dl,{className:"px-4",children:s?v.jsx(xre,{selectedPath:i,paths:s}):!n&&v.jsx("div",{className:"py-4",children:"Loading..."})}),v.jsxs("div",{className:"flex items-center justify-start h-[50px] gap-2 font-serif text-xs",children:[v.jsx("button",{onClick:()=>{history.back()},children:v.jsx(_5,{})}),v.jsx("div",{className:"truncate max-w-[300px] text-left",dir:"rtl",title:i,children:v.jsx(ba,{children:i||"/"})})]}),v.jsx(kre,{path:i,error:n,initOnSubmit:b,session:u,api:e,store:t}),v.jsxs("div",{className:"w-full flex items-center justify-end h-[50px] gap-2 font-serif text-xs px-6",children:[v.jsx("button",{className:"px-4 py-2 border rounded border-border",children:v.jsx(gT,{size:14})}),v.jsx("button",{className:"px-4 py-2 border rounded border-border",children:v.jsx(R5,{size:14})}),v.jsx("button",{className:"px-4 py-2 border rounded border-border bg-border",children:v.jsx(vT,{size:14})})]}),v.jsx(YT,{patches:p,isValidating:y,validationResponse:w,api:e,onCommit:()=>{h(S=>S+1)}})]})})})]})})};function kre({path:e,api:t,store:n,error:r,session:o,initOnSubmit:i}){var p;const[s,a]=m.useState(!1),[l,c]=m.useState(),[u,d]=m.useState(null),[f]=e?Fe.splitModuleIdAndModulePath(e):[void 0,void 0];return m.useEffect(()=>{let h=!1;return f?(d(null),a(!0),c(void 0),n.getModule(f).then(g=>{h||o.status==="success"&&o.data.enabled&&(He.isOk(g)?d(g.value):c(g.error.message))}).finally(()=>{h||a(!1)})):d(null),()=>{h=!0}},[f,e,o]),v.jsxs("div",{className:"p-4",children:[(r||l)&&v.jsxs("div",{className:"max-w-xl p-4 text-lg bg-destructive text-destructive-foreground",children:["ERROR: ",r||l]}),o.status==="success"&&o.data.mode==="unauthorized"&&v.jsx("div",{className:"max-w-xl p-4 text-lg bg-destructive text-destructive-foreground",children:"Not authorized"}),o.status==="success"&&!o.data.enabled&&v.jsxs("div",{className:"max-w-xl p-4 text-lg",children:[v.jsx("div",{children:"Val is currently not enabled"}),v.jsx("a",{href:t.getEnableUrl(((p=window==null?void 0:window.location)==null?void 0:p.href)||"/val"),children:"Enable Val"})]}),s&&v.jsx("div",{className:"flex place-content-center",children:"Loading..."}),u&&e&&v.jsx(Sre,{path:e,source:u.source,schema:u.schema,initOnSubmit:i})]})}function Sre({path:e,source:t,schema:n,initOnSubmit:r}){const[,o]=Fe.splitModuleIdAndModulePath(e),i=Fe.resolvePath(o,t,n);if(!i)throw console.error("Could not resolve module: "+e,{modulePath:o,moduleSource:t,moduleSchema:n}),Error("Could not resolve module: "+e);return v.jsx(xg,{path:e,source:i.source,schema:i.schema,initOnSubmit:r,top:!0})}const Ere=m.createContext(null),$v={didCatch:!1,error:null};class Lb extends m.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=$v}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:i,reason:"imperative-api"}),this.setState($v)}}componentDidCatch(t,n){var r,o;(r=(o=this.props).onError)===null||r===void 0||r.call(o,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:o}=this.props;if(r&&n.error!==null&&_re(t.resetKeys,o)){var i,s;(i=(s=this.props).onReset)===null||i===void 0||i.call(s,{next:o,prev:t.resetKeys,reason:"keys"}),this.setState($v)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:o}=this.props,{didCatch:i,error:s}=this.state;let a=t;if(i){const l={error:s,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(l);else if(r)a=m.createElement(r,l);else if(o===null||m.isValidElement(o))a=o;else throw s}return m.createElement(Ere.Provider,{value:{didCatch:i,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}function _re(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function jb({error:e,resetErrorBoundary:t}){return console.error(e),v.jsx("div",{className:"absolute top-0 left-0 flex items-center justify-center w-screen h-screen bg-card-foreground",children:v.jsx("div",{className:"w-full h-full p-10",children:v.jsxs("div",{className:"w-full h-full p-10 bg-card text-primary",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsxs("div",{className:"flex items-center gap-[0.5em] text-lg font-bold text-center py-2",children:[v.jsx(xT,{})," encountered an error"]}),v.jsx("button",{onClick:t,children:v.jsx(Om,{})})]}),v.jsx("div",{className:"text-4xl font-normal ",children:"Message:"}),v.jsx("pre",{children:e.message}),e.stack&&v.jsx(Im,{type:"single",className:"font-serif",collapsible:!0,defaultValue:"error",children:v.jsxs(VT,{value:"error",children:[v.jsx(UT,{children:"Stack trace:"}),v.jsx(nf,{className:"p-4 bg-popover text-popover-foreground",children:e.stack&&v.jsx("pre",{children:e.stack})})]})})]})})})}function Cre(){const{api:e,store:t}=m.useMemo(()=>{const n=new Qx("/api/val"),r=new x1(n);return{api:n,store:r}},[]);return v.jsx(Lb,{fallbackRender:jb,children:v.jsx(Ab,{children:v.jsx(s$,{api:e,store:t})})})}function Ore(){const e=new Qx("/api/val"),t=new x1(e);return v.jsx(Lb,{fallbackRender:jb,children:v.jsx(Ab,{children:v.jsx(s$,{api:e,store:t})})})}function Tre({root:e,children:t}){return Nr.createPortal(t,e)}const Pre=({children:e,style:t})=>{const n=m.useRef(null),[r,o]=m.useState(null);return m.useLayoutEffect(()=>{if(n.current)if(n.current.shadowRoot)o(n.current.shadowRoot);else{const i=n.current.attachShadow({mode:"open"});o(i)}},[]),v.jsx("div",{ref:n,style:t,id:"val-shadow-root",children:r&&v.jsx(Tre,{root:r,children:e})})},Mre="/spa/index.css",Nre="val-app",Rre="val-overlay",a$="Popover",[l$,Oie]=Rr(a$,[Tc]),zb=Tc(),[$re,Mc]=l$(a$),Are=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=zb(t),l=m.useRef(null),[c,u]=m.useState(!1),[d=!1,f]=Oo({prop:r,defaultProp:o,onChange:i});return m.createElement(pb,a,m.createElement($re,{scope:t,contentId:Er(),triggerRef:l,open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(p=>!p),[f]),hasCustomAnchor:c,onCustomAnchorAdd:m.useCallback(()=>u(!0),[]),onCustomAnchorRemove:m.useCallback(()=>u(!1),[]),modal:s},n))},Ire="PopoverTrigger",Dre=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Mc(Ire,n),i=zb(n),s=$e(t,o.triggerRef),a=m.createElement(we.button,A({type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":d$(o.open)},r,{ref:s,onClick:ne(e.onClick,o.onOpenToggle)}));return o.hasCustomAnchor?a:m.createElement(hb,A({asChild:!0},i),a)}),c$="PopoverPortal",[Lre,jre]=l$(c$,{forceMount:void 0}),zre=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Mc(c$,t);return m.createElement(Lre,{scope:t,forceMount:n},m.createElement(Nn,{present:n||i.open},m.createElement(ug,{asChild:!0,container:o},r)))},Kd="PopoverContent",Fre=m.forwardRef((e,t)=>{const n=jre(Kd,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Mc(Kd,e.__scopePopover);return m.createElement(Nn,{present:r||i.open},i.modal?m.createElement(Bre,A({},o,{ref:t})):m.createElement(Vre,A({},o,{ref:t})))}),Bre=m.forwardRef((e,t)=>{const n=Mc(Kd,e.__scopePopover),r=m.useRef(null),o=$e(t,r),i=m.useRef(!1);return m.useEffect(()=>{const s=r.current;if(s)return sg(s)},[]),m.createElement(fg,{as:ci,allowPinchZoom:!0},m.createElement(u$,A({},e,{ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ne(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),i.current||(a=n.triggerRef.current)===null||a===void 0||a.focus()}),onPointerDownOutside:ne(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:ne(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})))}),Vre=m.forwardRef((e,t)=>{const n=Mc(Kd,e.__scopePopover),r=m.useRef(!1),o=m.useRef(!1);return m.createElement(u$,A({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var s;if((s=e.onCloseAutoFocus)===null||s===void 0||s.call(e,i),!i.defaultPrevented){var a;r.current||(a=n.triggerRef.current)===null||a===void 0||a.focus(),i.preventDefault()}r.current=!1,o.current=!1},onInteractOutside:i=>{var s,a;(s=e.onInteractOutside)===null||s===void 0||s.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const l=i.target;((a=n.triggerRef.current)===null||a===void 0?void 0:a.contains(l))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}}))}),u$=m.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...d}=e,f=Mc(Kd,n),p=zb(n);return lg(),m.createElement(cg,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i},m.createElement(ag,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1)},m.createElement(mb,A({"data-state":d$(f.open),role:"dialog",id:f.contentId},p,d,{ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}}))))});function d$(e){return e?"open":"closed"}const Ure=Are,Hre=Dre,f$=zre,Fb=Fre,Wre=Ure,Kre=Hre,qre=m.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>v.jsx(f$,{children:v.jsx(Fb,{ref:o,align:t,sideOffset:n,className:Me("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));qre.displayName=Fb.displayName;const Bb="p-1 border rounded-full shadow border-accent",c_="valbuild:urlBeforeNavigation";function Gre({api:e,patches:t,direction:n,onClickPatches:r}){const{theme:o,setTheme:i,editMode:s,setEditMode:a,session:l}=Tm();if(l.status==="success"&&l.data.mode==="unauthorized")return v.jsxs(u_,{direction:n,href:e.getLoginUrl(window.location.href),children:[v.jsx("span",{children:"Login"}),v.jsx(wk,{size:18})]});if(l.status==="success"&&!l.data.enabled)return v.jsxs(u_,{direction:n,href:e.getEnableUrl(window.location.href),children:[v.jsx("span",{children:"Enable"}),v.jsx(wk,{size:18})]});const[c,u]=m.useState();return m.useEffect(()=>{let d=0;for(const f in t)d+=t[f].length;u(d)},[t]),v.jsxs(p$,{direction:n,children:[v.jsx(Av,{active:s==="hover"||s==="window",onClick:()=>{a(d=>d==="hover"||s==="window"?"off":"hover")},children:v.jsx("div",{className:"h-[24px] w-[24px] flex justify-center items-center",children:s==="hover"||s==="window"?v.jsx(F5,{size:18}):v.jsx(B5,{size:18})})}),v.jsx(Av,{active:s==="full",onClick:()=>{if(s!=="full")localStorage.setItem(c_,window.location.href),window.location.href=e.getEditUrl();else if(s==="full"){const d=localStorage.getItem(c_);window.location.href=d||"/"}},children:v.jsx("div",{className:"h-[24px] w-[24px] flex justify-center items-center",children:s==="full"?v.jsx(gT,{size:15}):v.jsx(D5,{size:15})})}),c!==void 0&&v.jsx(Av,{onClick:()=>{c>0&&r()},children:v.jsxs("div",{className:"relative h-[24px] w-[24px] flex justify-center items-center",children:[v.jsx("div",{className:"absolute -right-[10px] -top-[10px] border border-border rounded-full px-1 font-sans text-xs bg-card text-accent",children:c}),v.jsx(vT,{size:18})]})}),v.jsx(Kre,{className:Bb,children:v.jsx("div",{className:"h-[24px] w-[24px] flex justify-center items-center",children:v.jsx(z5,{size:18})})}),v.jsx(Fb,{align:"start",sideOffset:12,side:"right",className:"z-50 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",children:v.jsxs("div",{className:"flex flex-col items-start justify-center p-4 gap-x-4",children:[v.jsx("div",{className:"flex items-end justify-end w-full",children:v.jsx("div",{className:"h-[34px] w-[34px] flex justify-center items-center",children:v.jsxs(Nb,{className:"relative peer inline-flex h-[24px] w-[34px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-slate-800 data-[state=unchecked]:bg-slate-800",defaultChecked:o==="light",onClick:()=>{i(o==="dark"?"light":"dark")},children:[o==="dark"&&v.jsx(j5,{size:13,className:"absolute top-[4px] left-[17px] text-white"}),v.jsx(jR,{className:"pointer-events-none block h-[16px] w-[16px] rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-[15px] data-[state=unchecked]:translate-x-0"}),o==="light"&&v.jsx(W5,{size:13,className:"absolute top-[4px] left-[1px] text-white"})]})})}),v.jsx("div",{children:v.jsxs("a",{className:"flex items-center justify-center font-bold h-[34px] gap-x-1",href:e.getDisableUrl(window.location.href),children:[v.jsx("span",{children:"Disable"}),v.jsx(T5,{size:18})]})})]})})]})}function u_({href:e,direction:t,children:n}){return v.jsx(p$,{direction:t,border:!1,children:v.jsx("a",{className:Bb,href:e,children:v.jsx("div",{className:"flex items-center justify-center px-2 gap-y-2",children:n})})})}function p$({children:e,direction:t,border:n=!0}){return v.jsx("div",{className:It("flex justify-center w-full h-full px-2 py-2 font-sans rounded-full gap-3 text-primary border-fill bg-gradient-to-br from-background/90 from-40% to-background backdrop-blur-lg drop-shadow-2xl",{"flex-col items-start":t==="vertical","flex-row items-center":t==="horizontal"},{border:n}),children:e})}function Av({active:e,onClick:t,children:n}){return v.jsx("button",{className:It(Bb,{"bg-accent text-accent-foreground drop-shadow-[0px_0px_12px_hsl(var(--accent))]":e}),onClick:t,children:n})}var Vb={exports:{}},gf={},bg={exports:{}},h$={};function m$(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=m$(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function d_(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=m$(e))&&(r&&(r+=" "),r+=t);return r}const Yre=Object.freeze(Object.defineProperty({__proto__:null,clsx:d_,default:d_},Symbol.toStringTag,{value:"Module"})),Xre=D$(Yre);var bt={},Io={};Object.defineProperty(Io,"__esModule",{value:!0});Io.dontSetMe=toe;Io.findInArray=Zre;Io.int=eoe;Io.isFunction=Jre;Io.isNum=Qre;function Zre(e,t){for(let n=0,r=e.length;n<r;n++)if(t.apply(t,[e[n],n,e]))return e[n]}function Jre(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Function]"}function Qre(e){return typeof e=="number"&&!isNaN(e)}function eoe(e){return parseInt(e,10)}function toe(e,t,n){if(e[t])return new Error("Invalid prop ".concat(t," passed to ").concat(n," - do not set this, set it on the child."))}var Ha={};Object.defineProperty(Ha,"__esModule",{value:!0});Ha.browserPrefixToKey=v$;Ha.browserPrefixToStyle=noe;Ha.default=void 0;Ha.getPrefix=g$;const Iv=["Moz","Webkit","O","ms"];function g$(){var e;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"transform";if(typeof window>"u")return"";const n=(e=window.document)===null||e===void 0||(e=e.documentElement)===null||e===void 0?void 0:e.style;if(!n||t in n)return"";for(let r=0;r<Iv.length;r++)if(v$(t,Iv[r])in n)return Iv[r];return""}function v$(e,t){return t?"".concat(t).concat(roe(e)):e}function noe(e,t){return t?"-".concat(t.toLowerCase(),"-").concat(e):e}function roe(e){let t="",n=!0;for(let r=0;r<e.length;r++)n?(t+=e[r].toUpperCase(),n=!1):e[r]==="-"?n=!0:t+=e[r];return t}Ha.default=g$();Object.defineProperty(bt,"__esModule",{value:!0});bt.addClassName=b$;bt.addEvent=soe;bt.addUserSelectStyles=voe;bt.createCSSTransform=poe;bt.createSVGTransform=hoe;bt.getTouch=moe;bt.getTouchIdentifier=goe;bt.getTranslation=Ub;bt.innerHeight=uoe;bt.innerWidth=doe;bt.matchesSelector=x$;bt.matchesSelectorAndParentsTo=ioe;bt.offsetXYFromParent=foe;bt.outerHeight=loe;bt.outerWidth=coe;bt.removeClassName=w$;bt.removeEvent=aoe;bt.removeUserSelectStyles=yoe;var or=Io,f_=ooe(Ha);function y$(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,n=new WeakMap;return(y$=function(r){return r?n:t})(e)}function ooe(e,t){if(!t&&e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var n=y$(t);if(n&&n.has(e))return n.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)){var s=o?Object.getOwnPropertyDescriptor(e,i):null;s&&(s.get||s.set)?Object.defineProperty(r,i,s):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}let ep="";function x$(e,t){return ep||(ep=(0,or.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(n){return(0,or.isFunction)(e[n])})),(0,or.isFunction)(e[ep])?e[ep](t):!1}function ioe(e,t,n){let r=e;do{if(x$(r,t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function soe(e,t,n,r){if(!e)return;const o={capture:!0,...r};e.addEventListener?e.addEventListener(t,n,o):e.attachEvent?e.attachEvent("on"+t,n):e["on"+t]=n}function aoe(e,t,n,r){if(!e)return;const o={capture:!0,...r};e.removeEventListener?e.removeEventListener(t,n,o):e.detachEvent?e.detachEvent("on"+t,n):e["on"+t]=null}function loe(e){let t=e.clientHeight;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=(0,or.int)(n.borderTopWidth),t+=(0,or.int)(n.borderBottomWidth),t}function coe(e){let t=e.clientWidth;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=(0,or.int)(n.borderLeftWidth),t+=(0,or.int)(n.borderRightWidth),t}function uoe(e){let t=e.clientHeight;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=(0,or.int)(n.paddingTop),t-=(0,or.int)(n.paddingBottom),t}function doe(e){let t=e.clientWidth;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=(0,or.int)(n.paddingLeft),t-=(0,or.int)(n.paddingRight),t}function foe(e,t,n){const o=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect(),i=(e.clientX+t.scrollLeft-o.left)/n,s=(e.clientY+t.scrollTop-o.top)/n;return{x:i,y:s}}function poe(e,t){const n=Ub(e,t,"px");return{[(0,f_.browserPrefixToKey)("transform",f_.default)]:n}}function hoe(e,t){return Ub(e,t,"")}function Ub(e,t,n){let{x:r,y:o}=e,i="translate(".concat(r).concat(n,",").concat(o).concat(n,")");if(t){const s="".concat(typeof t.x=="string"?t.x:t.x+n),a="".concat(typeof t.y=="string"?t.y:t.y+n);i="translate(".concat(s,", ").concat(a,")")+i}return i}function moe(e,t){return e.targetTouches&&(0,or.findInArray)(e.targetTouches,n=>t===n.identifier)||e.changedTouches&&(0,or.findInArray)(e.changedTouches,n=>t===n.identifier)}function goe(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function voe(e){if(!e)return;let t=e.getElementById("react-draggable-style-el");t||(t=e.createElement("style"),t.type="text/css",t.id="react-draggable-style-el",t.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
212
216
  `,t.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
213
- `,e.getElementsByTagName("head")[0].appendChild(t)),e.body&&b$(e.body,"react-draggable-transparent-selection")}function yoe(e){if(e)try{if(e.body&&w$(e.body,"react-draggable-transparent-selection"),e.selection)e.selection.empty();else{const t=(e.defaultView||window).getSelection();t&&t.type!=="Caret"&&t.removeAllRanges()}}catch{}}function b$(e,t){e.classList?e.classList.add(t):e.className.match(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)")))||(e.className+=" ".concat(t))}function w$(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)"),"g"),"")}var Do={};Object.defineProperty(Do,"__esModule",{value:!0});Do.canDragX=woe;Do.canDragY=koe;Do.createCoreData=Eoe;Do.createDraggableData=_oe;Do.getBoundPosition=xoe;Do.getControlPosition=Soe;Do.snapToGrid=boe;var Gn=Io,Pl=bt;function xoe(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r=typeof r=="string"?r:Coe(r);const o=Hb(e);if(typeof r=="string"){const{ownerDocument:i}=o,s=i.defaultView;let a;if(r==="parent"?a=o.parentNode:a=i.querySelector(r),!(a instanceof s.HTMLElement))throw new Error('Bounds selector "'+r+'" could not find an element.');const l=a,c=s.getComputedStyle(o),u=s.getComputedStyle(l);r={left:-o.offsetLeft+(0,Gn.int)(u.paddingLeft)+(0,Gn.int)(c.marginLeft),top:-o.offsetTop+(0,Gn.int)(u.paddingTop)+(0,Gn.int)(c.marginTop),right:(0,Pl.innerWidth)(l)-(0,Pl.outerWidth)(o)-o.offsetLeft+(0,Gn.int)(u.paddingRight)-(0,Gn.int)(c.marginRight),bottom:(0,Pl.innerHeight)(l)-(0,Pl.outerHeight)(o)-o.offsetTop+(0,Gn.int)(u.paddingBottom)-(0,Gn.int)(c.marginBottom)}}return(0,Gn.isNum)(r.right)&&(t=Math.min(t,r.right)),(0,Gn.isNum)(r.bottom)&&(n=Math.min(n,r.bottom)),(0,Gn.isNum)(r.left)&&(t=Math.max(t,r.left)),(0,Gn.isNum)(r.top)&&(n=Math.max(n,r.top)),[t,n]}function boe(e,t,n){const r=Math.round(t/e[0])*e[0],o=Math.round(n/e[1])*e[1];return[r,o]}function woe(e){return e.props.axis==="both"||e.props.axis==="x"}function koe(e){return e.props.axis==="both"||e.props.axis==="y"}function Soe(e,t,n){const r=typeof t=="number"?(0,Pl.getTouch)(e,t):null;if(typeof t=="number"&&!r)return null;const o=Hb(n),i=n.props.offsetParent||o.offsetParent||o.ownerDocument.body;return(0,Pl.offsetXYFromParent)(r||e,i,n.props.scale)}function Eoe(e,t,n){const r=!(0,Gn.isNum)(e.lastX),o=Hb(e);return r?{node:o,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:o,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}}function _oe(e,t){const n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function Coe(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function Hb(e){const t=e.findDOMNode();if(!t)throw new Error("<DraggableCore>: Unmounted during event!");return t}var wg={},kg={};Object.defineProperty(kg,"__esModule",{value:!0});kg.default=Ooe;function Ooe(){}Object.defineProperty(wg,"__esModule",{value:!0});wg.default=void 0;var Dv=Poe(m),Rn=Wb(rf),Toe=Wb(Nr),ln=bt,Pi=Do,Lv=Io,Gc=Wb(kg);function Wb(e){return e&&e.__esModule?e:{default:e}}function k$(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,n=new WeakMap;return(k$=function(r){return r?n:t})(e)}function Poe(e,t){if(!t&&e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var n=k$(t);if(n&&n.has(e))return n.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)){var s=o?Object.getOwnPropertyDescriptor(e,i):null;s&&(s.get||s.set)?Object.defineProperty(r,i,s):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}function yn(e,t,n){return t=Moe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Moe(e){var t=Noe(e,"string");return typeof t=="symbol"?t:String(t)}function Noe(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}const Ur={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}};let Mi=Ur.mouse,Sg=class extends Dv.Component{constructor(){super(...arguments),yn(this,"dragging",!1),yn(this,"lastX",NaN),yn(this,"lastY",NaN),yn(this,"touchIdentifier",null),yn(this,"mounted",!1),yn(this,"handleDragStart",t=>{if(this.props.onMouseDown(t),!this.props.allowAnyClick&&typeof t.button=="number"&&t.button!==0)return!1;const n=this.findDOMNode();if(!n||!n.ownerDocument||!n.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");const{ownerDocument:r}=n;if(this.props.disabled||!(t.target instanceof r.defaultView.Node)||this.props.handle&&!(0,ln.matchesSelectorAndParentsTo)(t.target,this.props.handle,n)||this.props.cancel&&(0,ln.matchesSelectorAndParentsTo)(t.target,this.props.cancel,n))return;t.type==="touchstart"&&t.preventDefault();const o=(0,ln.getTouchIdentifier)(t);this.touchIdentifier=o;const i=(0,Pi.getControlPosition)(t,o,this);if(i==null)return;const{x:s,y:a}=i,l=(0,Pi.createCoreData)(this,s,a);(0,Gc.default)("DraggableCore: handleDragStart: %j",l),(0,Gc.default)("calling",this.props.onStart),!(this.props.onStart(t,l)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&(0,ln.addUserSelectStyles)(r),this.dragging=!0,this.lastX=s,this.lastY=a,(0,ln.addEvent)(r,Mi.move,this.handleDrag),(0,ln.addEvent)(r,Mi.stop,this.handleDragStop))}),yn(this,"handleDrag",t=>{const n=(0,Pi.getControlPosition)(t,this.touchIdentifier,this);if(n==null)return;let{x:r,y:o}=n;if(Array.isArray(this.props.grid)){let a=r-this.lastX,l=o-this.lastY;if([a,l]=(0,Pi.snapToGrid)(this.props.grid,a,l),!a&&!l)return;r=this.lastX+a,o=this.lastY+l}const i=(0,Pi.createCoreData)(this,r,o);if((0,Gc.default)("DraggableCore: handleDrag: %j",i),this.props.onDrag(t,i)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent("mouseup"))}catch{const l=document.createEvent("MouseEvents");l.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(l)}return}this.lastX=r,this.lastY=o}),yn(this,"handleDragStop",t=>{if(!this.dragging)return;const n=(0,Pi.getControlPosition)(t,this.touchIdentifier,this);if(n==null)return;let{x:r,y:o}=n;if(Array.isArray(this.props.grid)){let l=r-this.lastX||0,c=o-this.lastY||0;[l,c]=(0,Pi.snapToGrid)(this.props.grid,l,c),r=this.lastX+l,o=this.lastY+c}const i=(0,Pi.createCoreData)(this,r,o);if(this.props.onStop(t,i)===!1||this.mounted===!1)return!1;const a=this.findDOMNode();a&&this.props.enableUserSelectHack&&(0,ln.removeUserSelectStyles)(a.ownerDocument),(0,Gc.default)("DraggableCore: handleDragStop: %j",i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&((0,Gc.default)("DraggableCore: Removing handlers"),(0,ln.removeEvent)(a.ownerDocument,Mi.move,this.handleDrag),(0,ln.removeEvent)(a.ownerDocument,Mi.stop,this.handleDragStop))}),yn(this,"onMouseDown",t=>(Mi=Ur.mouse,this.handleDragStart(t))),yn(this,"onMouseUp",t=>(Mi=Ur.mouse,this.handleDragStop(t))),yn(this,"onTouchStart",t=>(Mi=Ur.touch,this.handleDragStart(t))),yn(this,"onTouchEnd",t=>(Mi=Ur.touch,this.handleDragStop(t)))}componentDidMount(){this.mounted=!0;const t=this.findDOMNode();t&&(0,ln.addEvent)(t,Ur.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const t=this.findDOMNode();if(t){const{ownerDocument:n}=t;(0,ln.removeEvent)(n,Ur.mouse.move,this.handleDrag),(0,ln.removeEvent)(n,Ur.touch.move,this.handleDrag),(0,ln.removeEvent)(n,Ur.mouse.stop,this.handleDragStop),(0,ln.removeEvent)(n,Ur.touch.stop,this.handleDragStop),(0,ln.removeEvent)(t,Ur.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,ln.removeUserSelectStyles)(n)}}findDOMNode(){var t,n;return(t=this.props)!==null&&t!==void 0&&t.nodeRef?(n=this.props)===null||n===void 0||(n=n.nodeRef)===null||n===void 0?void 0:n.current:Toe.default.findDOMNode(this)}render(){return Dv.cloneElement(Dv.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};wg.default=Sg;yn(Sg,"displayName","DraggableCore");yn(Sg,"propTypes",{allowAnyClick:Rn.default.bool,children:Rn.default.node.isRequired,disabled:Rn.default.bool,enableUserSelectHack:Rn.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:Rn.default.arrayOf(Rn.default.number),handle:Rn.default.string,cancel:Rn.default.string,nodeRef:Rn.default.object,onStart:Rn.default.func,onDrag:Rn.default.func,onStop:Rn.default.func,onMouseDown:Rn.default.func,scale:Rn.default.number,className:Lv.dontSetMe,style:Lv.dontSetMe,transform:Lv.dontSetMe});yn(Sg,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1});(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return l.default}}),e.default=void 0;var t=f(m),n=u(rf),r=u(Nr),o=u(Xre),i=bt,s=Do,a=Io,l=u(wg),c=u(kg);function u(x){return x&&x.__esModule?x:{default:x}}function d(x){if(typeof WeakMap!="function")return null;var w=new WeakMap,k=new WeakMap;return(d=function(S){return S?k:w})(x)}function f(x,w){if(!w&&x&&x.__esModule)return x;if(x===null||typeof x!="object"&&typeof x!="function")return{default:x};var k=d(w);if(k&&k.has(x))return k.get(x);var S={},O=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var E in x)if(E!=="default"&&Object.prototype.hasOwnProperty.call(x,E)){var P=O?Object.getOwnPropertyDescriptor(x,E):null;P&&(P.get||P.set)?Object.defineProperty(S,E,P):S[E]=x[E]}return S.default=x,k&&k.set(x,S),S}function p(){return p=Object.assign?Object.assign.bind():function(x){for(var w=1;w<arguments.length;w++){var k=arguments[w];for(var S in k)Object.prototype.hasOwnProperty.call(k,S)&&(x[S]=k[S])}return x},p.apply(this,arguments)}function h(x,w,k){return w=g(w),w in x?Object.defineProperty(x,w,{value:k,enumerable:!0,configurable:!0,writable:!0}):x[w]=k,x}function g(x){var w=b(x,"string");return typeof w=="symbol"?w:String(w)}function b(x,w){if(typeof x!="object"||x===null)return x;var k=x[Symbol.toPrimitive];if(k!==void 0){var S=k.call(x,w||"default");if(typeof S!="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return(w==="string"?String:Number)(x)}class y extends t.Component{static getDerivedStateFromProps(w,k){let{position:S}=w,{prevPropsPosition:O}=k;return S&&(!O||S.x!==O.x||S.y!==O.y)?((0,c.default)("Draggable: getDerivedStateFromProps %j",{position:S,prevPropsPosition:O}),{x:S.x,y:S.y,prevPropsPosition:{...S}}):null}constructor(w){super(w),h(this,"onDragStart",(k,S)=>{if((0,c.default)("Draggable: onDragStart: %j",S),this.props.onStart(k,(0,s.createDraggableData)(this,S))===!1)return!1;this.setState({dragging:!0,dragged:!0})}),h(this,"onDrag",(k,S)=>{if(!this.state.dragging)return!1;(0,c.default)("Draggable: onDrag: %j",S);const O=(0,s.createDraggableData)(this,S),E={x:O.x,y:O.y,slackX:0,slackY:0};if(this.props.bounds){const{x:N,y:$}=E;E.x+=this.state.slackX,E.y+=this.state.slackY;const[z,j]=(0,s.getBoundPosition)(this,E.x,E.y);E.x=z,E.y=j,E.slackX=this.state.slackX+(N-E.x),E.slackY=this.state.slackY+($-E.y),O.x=E.x,O.y=E.y,O.deltaX=E.x-this.state.x,O.deltaY=E.y-this.state.y}if(this.props.onDrag(k,O)===!1)return!1;this.setState(E)}),h(this,"onDragStop",(k,S)=>{if(!this.state.dragging||this.props.onStop(k,(0,s.createDraggableData)(this,S))===!1)return!1;(0,c.default)("Draggable: onDragStop: %j",S);const E={dragging:!1,slackX:0,slackY:0};if(!!this.props.position){const{x:N,y:$}=this.props.position;E.x=N,E.y=$}this.setState(E)}),this.state={dragging:!1,dragged:!1,x:w.position?w.position.x:w.defaultPosition.x,y:w.position?w.position.y:w.defaultPosition.y,prevPropsPosition:{...w.position},slackX:0,slackY:0,isElementSVG:!1},w.position&&!(w.onDrag||w.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){typeof window.SVGElement<"u"&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.setState({dragging:!1})}findDOMNode(){var w,k;return(w=(k=this.props)===null||k===void 0||(k=k.nodeRef)===null||k===void 0?void 0:k.current)!==null&&w!==void 0?w:r.default.findDOMNode(this)}render(){const{axis:w,bounds:k,children:S,defaultPosition:O,defaultClassName:E,defaultClassNameDragging:P,defaultClassNameDragged:N,position:$,positionOffset:z,scale:j,...le}=this.props;let U={},K=null;const T=!!!$||this.state.dragging,C=$||O,M={x:(0,s.canDragX)(this)&&T?this.state.x:C.x,y:(0,s.canDragY)(this)&&T?this.state.y:C.y};this.state.isElementSVG?K=(0,i.createSVGTransform)(M,z):U=(0,i.createCSSTransform)(M,z);const R=(0,o.default)(S.props.className||"",E,{[P]:this.state.dragging,[N]:this.state.dragged});return t.createElement(l.default,p({},le,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),t.cloneElement(t.Children.only(S),{className:R,style:{...S.props.style,...U},transform:K}))}}e.default=y,h(y,"displayName","Draggable"),h(y,"propTypes",{...l.default.propTypes,axis:n.default.oneOf(["both","x","y","none"]),bounds:n.default.oneOfType([n.default.shape({left:n.default.number,right:n.default.number,top:n.default.number,bottom:n.default.number}),n.default.string,n.default.oneOf([!1])]),defaultClassName:n.default.string,defaultClassNameDragging:n.default.string,defaultClassNameDragged:n.default.string,defaultPosition:n.default.shape({x:n.default.number,y:n.default.number}),positionOffset:n.default.shape({x:n.default.oneOfType([n.default.number,n.default.string]),y:n.default.oneOfType([n.default.number,n.default.string])}),position:n.default.shape({x:n.default.number,y:n.default.number}),className:a.dontSetMe,style:a.dontSetMe,transform:a.dontSetMe}),h(y,"defaultProps",{...l.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})})(h$);const{default:S$,DraggableCore:Roe}=h$;bg.exports=S$;bg.exports.default=S$;bg.exports.DraggableCore=Roe;var $oe=bg.exports,Kb={};Kb.__esModule=!0;Kb.cloneElement=zoe;var Aoe=Ioe(m);function Ioe(e){return e&&e.__esModule?e:{default:e}}function p_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function h_(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?p_(Object(n),!0).forEach(function(r){Doe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p_(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Doe(e,t,n){return t=Loe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Loe(e){var t=joe(e,"string");return typeof t=="symbol"?t:String(t)}function joe(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function zoe(e,t){return t.style&&e.props.style&&(t.style=h_(h_({},e.props.style),t.style)),t.className&&e.props.className&&(t.className=e.props.className+" "+t.className),Aoe.default.cloneElement(e,t)}var vf={};vf.__esModule=!0;vf.resizableProps=void 0;var Se=Foe(rf);function Foe(e){return e&&e.__esModule?e:{default:e}}var Boe={axis:Se.default.oneOf(["both","x","y","none"]),className:Se.default.string,children:Se.default.element.isRequired,draggableOpts:Se.default.shape({allowAnyClick:Se.default.bool,cancel:Se.default.string,children:Se.default.node,disabled:Se.default.bool,enableUserSelectHack:Se.default.bool,offsetParent:Se.default.node,grid:Se.default.arrayOf(Se.default.number),handle:Se.default.string,nodeRef:Se.default.object,onStart:Se.default.func,onDrag:Se.default.func,onStop:Se.default.func,onMouseDown:Se.default.func,scale:Se.default.number}),height:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var o=n[0];if(o.axis==="both"||o.axis==="y"){var i;return(i=Se.default.number).isRequired.apply(i,n)}return Se.default.number.apply(Se.default,n)},handle:Se.default.oneOfType([Se.default.node,Se.default.func]),handleSize:Se.default.arrayOf(Se.default.number),lockAspectRatio:Se.default.bool,maxConstraints:Se.default.arrayOf(Se.default.number),minConstraints:Se.default.arrayOf(Se.default.number),onResizeStop:Se.default.func,onResizeStart:Se.default.func,onResize:Se.default.func,resizeHandles:Se.default.arrayOf(Se.default.oneOf(["s","w","e","n","sw","nw","se","ne"])),transformScale:Se.default.number,width:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var o=n[0];if(o.axis==="both"||o.axis==="x"){var i;return(i=Se.default.number).isRequired.apply(i,n)}return Se.default.number.apply(Se.default,n)}};vf.resizableProps=Boe;gf.__esModule=!0;gf.default=void 0;var Yc=Koe(m),Voe=$oe,Uoe=Kb,Hoe=vf,Woe=["children","className","draggableOpts","width","height","handle","handleSize","lockAspectRatio","axis","minConstraints","maxConstraints","onResize","onResizeStop","onResizeStart","resizeHandles","transformScale"];function E$(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,n=new WeakMap;return(E$=function(o){return o?n:t})(e)}function Koe(e,t){if(!t&&e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var n=E$(t);if(n&&n.has(e))return n.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)){var s=o?Object.getOwnPropertyDescriptor(e,i):null;s&&(s.get||s.set)?Object.defineProperty(r,i,s):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}function X0(){return X0=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X0.apply(this,arguments)}function qoe(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,i;for(i=0;i<r.length;i++)o=r[i],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function m_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function jv(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?m_(Object(n),!0).forEach(function(r){Goe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m_(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Goe(e,t,n){return t=Yoe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Yoe(e){var t=Xoe(e,"string");return typeof t=="symbol"?t:String(t)}function Xoe(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Zoe(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Z0(e,t)}function Z0(e,t){return Z0=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Z0(e,t)}var qb=function(e){Zoe(t,e);function t(){for(var r,o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];return r=e.call.apply(e,[this].concat(i))||this,r.handleRefs={},r.lastHandleRect=null,r.slack=null,r}var n=t.prototype;return n.componentWillUnmount=function(){this.resetData()},n.resetData=function(){this.lastHandleRect=this.slack=null},n.runConstraints=function(o,i){var s=this.props,a=s.minConstraints,l=s.maxConstraints,c=s.lockAspectRatio;if(!a&&!l&&!c)return[o,i];if(c){var u=this.props.width/this.props.height,d=o-this.props.width,f=i-this.props.height;Math.abs(d)>Math.abs(f*u)?i=o/u:o=i*u}var p=o,h=i,g=this.slack||[0,0],b=g[0],y=g[1];return o+=b,i+=y,a&&(o=Math.max(a[0],o),i=Math.max(a[1],i)),l&&(o=Math.min(l[0],o),i=Math.min(l[1],i)),this.slack=[b+(p-o),y+(h-i)],[o,i]},n.resizeHandler=function(o,i){var s=this;return function(a,l){var c=l.node,u=l.deltaX,d=l.deltaY;o==="onResizeStart"&&s.resetData();var f=(s.props.axis==="both"||s.props.axis==="x")&&i!=="n"&&i!=="s",p=(s.props.axis==="both"||s.props.axis==="y")&&i!=="e"&&i!=="w";if(!(!f&&!p)){var h=i[0],g=i[i.length-1],b=c.getBoundingClientRect();if(s.lastHandleRect!=null){if(g==="w"){var y=b.left-s.lastHandleRect.left;u+=y}if(h==="n"){var x=b.top-s.lastHandleRect.top;d+=x}}s.lastHandleRect=b,g==="w"&&(u=-u),h==="n"&&(d=-d);var w=s.props.width+(f?u/s.props.transformScale:0),k=s.props.height+(p?d/s.props.transformScale:0),S=s.runConstraints(w,k);w=S[0],k=S[1];var O=w!==s.props.width||k!==s.props.height,E=typeof s.props[o]=="function"?s.props[o]:null,P=o==="onResize"&&!O;E&&!P&&(a.persist==null||a.persist(),E(a,{node:c,size:{width:w,height:k},handle:i})),o==="onResizeStop"&&s.resetData()}}},n.renderResizeHandle=function(o,i){var s=this.props.handle;if(!s)return Yc.createElement("span",{className:"react-resizable-handle react-resizable-handle-"+o,ref:i});if(typeof s=="function")return s(o,i);var a=typeof s.type=="string",l=jv({ref:i},a?{}:{handleAxis:o});return Yc.cloneElement(s,l)},n.render=function(){var o=this,i=this.props,s=i.children,a=i.className,l=i.draggableOpts;i.width,i.height,i.handle,i.handleSize,i.lockAspectRatio,i.axis,i.minConstraints,i.maxConstraints,i.onResize,i.onResizeStop,i.onResizeStart;var c=i.resizeHandles;i.transformScale;var u=qoe(i,Woe);return(0,Uoe.cloneElement)(s,jv(jv({},u),{},{className:(a?a+" ":"")+"react-resizable",children:[].concat(s.props.children,c.map(function(d){var f,p=(f=o.handleRefs[d])!=null?f:o.handleRefs[d]=Yc.createRef();return Yc.createElement(Voe.DraggableCore,X0({},l,{nodeRef:p,key:"resizableHandle-"+d,onStop:o.resizeHandler("onResizeStop",d),onStart:o.resizeHandler("onResizeStart",d),onDrag:o.resizeHandler("onResize",d)}),o.renderResizeHandle(d,p))}))}))},t}(Yc.Component);gf.default=qb;qb.propTypes=Hoe.resizableProps;qb.defaultProps={axis:"both",handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:["se"],transformScale:1};var Eg={};Eg.__esModule=!0;Eg.default=void 0;var zv=nie(m),Joe=_$(rf),Qoe=_$(gf),eie=vf,tie=["handle","handleSize","onResize","onResizeStart","onResizeStop","draggableOpts","minConstraints","maxConstraints","lockAspectRatio","axis","width","height","resizeHandles","style","transformScale"];function _$(e){return e&&e.__esModule?e:{default:e}}function C$(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,n=new WeakMap;return(C$=function(o){return o?n:t})(e)}function nie(e,t){if(!t&&e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var n=C$(t);if(n&&n.has(e))return n.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)){var s=o?Object.getOwnPropertyDescriptor(e,i):null;s&&(s.get||s.set)?Object.defineProperty(r,i,s):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}function J0(){return J0=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},J0.apply(this,arguments)}function g_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function nm(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?g_(Object(n),!0).forEach(function(r){rie(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):g_(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function rie(e,t,n){return t=oie(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oie(e){var t=iie(e,"string");return typeof t=="symbol"?t:String(t)}function iie(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function sie(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,i;for(i=0;i<r.length;i++)o=r[i],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function aie(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Q0(e,t)}function Q0(e,t){return Q0=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Q0(e,t)}var O$=function(e){aie(t,e);function t(){for(var r,o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];return r=e.call.apply(e,[this].concat(i))||this,r.state={width:r.props.width,height:r.props.height,propsWidth:r.props.width,propsHeight:r.props.height},r.onResize=function(a,l){var c=l.size;r.props.onResize?(a.persist==null||a.persist(),r.setState(c,function(){return r.props.onResize&&r.props.onResize(a,l)})):r.setState(c)},r}t.getDerivedStateFromProps=function(o,i){return i.propsWidth!==o.width||i.propsHeight!==o.height?{width:o.width,height:o.height,propsWidth:o.width,propsHeight:o.height}:null};var n=t.prototype;return n.render=function(){var o=this.props,i=o.handle,s=o.handleSize;o.onResize;var a=o.onResizeStart,l=o.onResizeStop,c=o.draggableOpts,u=o.minConstraints,d=o.maxConstraints,f=o.lockAspectRatio,p=o.axis;o.width,o.height;var h=o.resizeHandles,g=o.style,b=o.transformScale,y=sie(o,tie);return zv.createElement(Qoe.default,{axis:p,draggableOpts:c,handle:i,handleSize:s,height:this.state.height,lockAspectRatio:f,maxConstraints:d,minConstraints:u,onResizeStart:a,onResize:this.onResize,onResizeStop:l,resizeHandles:h,transformScale:b,width:this.state.width},zv.createElement("div",J0({},y,{style:nm(nm({},g),{},{width:this.state.width+"px",height:this.state.height+"px"})})))},t}(zv.Component);Eg.default=O$;O$.propTypes=nm(nm({},eie.resizableProps),{},{children:Joe.default.element});Vb.exports=function(){throw new Error("Don't instantiate Resizable directly! Use require('react-resizable').Resizable")};var lie=Vb.exports.Resizable=gf.default;Vb.exports.ResizableBox=Eg.default;const ml=400,Fv=250;function cie({position:e,onClose:t,children:n}){const[r,o]=m.useState({height:window.innerHeight,width:window.innerWidth});m.useEffect(()=>{const g=()=>{window.visualViewport?o({height:window.visualViewport.height,width:window.visualViewport.width}):o({height:window.innerHeight,width:window.innerWidth})};return window.addEventListener("resize",g),window.addEventListener("orientationchange",g),()=>{window.removeEventListener("resize",g),window.removeEventListener("orientationchange",g)}},[]);const[i,s,a,l,c]=uie({position:e,globalSize:r});m.useEffect(()=>{c({left:r.width-ml-74,top:16})},[r]),m.useEffect(()=>{const g=b=>{b.key==="Escape"&&t()};return document.addEventListener("keyup",g),()=>{document.removeEventListener("keyup",g)}},[]);const{windowSize:u,setWindowSize:d}=Tm(),f=r.width<=600||r.height<=600;m.useEffect(()=>{var g,b;d({height:window.innerHeight-30,width:ml,innerHeight:window.innerHeight-30-(64+(((b=(g=p.current)==null?void 0:g.getBoundingClientRect())==null?void 0:b.height)||0))})},[]);const p=m.useRef(null);m.useEffect(()=>{if(f){c({top:0,left:0}),d({height:window.innerHeight,width:window.innerWidth,innerHeight:window.innerHeight-64});const g=document.ownerDocument||document,b=g.body.style.overflow;return g.body.style.overflow="hidden",()=>{g.body.style.overflow=b}}},[f,r]);const h=m.useRef();return v.jsx(lie,{minConstraints:f?void 0:[ml,Fv],width:(u==null?void 0:u.width)||ml,height:(u==null?void 0:u.height)||Fv,onResize:(g,{size:b})=>{var y,x;return!f&&d({...b,innerHeight:b.height-(64+(((x=(y=p.current)==null?void 0:y.getBoundingClientRect())==null?void 0:x.height)||0))})},handle:f?null:v.jsx("div",{className:"fixed bottom-0 right-0 cursor-se-resize",children:v.jsx("svg",{height:"18",viewBox:"0 0 18 18",width:"18",xmlns:"http://www.w3.org/2000/svg",children:v.jsx("path",{d:"m14.228 16.227a1 1 0 0 1 -.707-1.707l1-1a1 1 0 0 1 1.416 1.414l-1 1a1 1 0 0 1 -.707.293zm-5.638 0a1 1 0 0 1 -.707-1.707l6.638-6.638a1 1 0 0 1 1.416 1.414l-6.638 6.638a1 1 0 0 1 -.707.293zm-5.84 0a1 1 0 0 1 -.707-1.707l12.477-12.477a1 1 0 1 1 1.415 1.414l-12.478 12.477a1 1 0 0 1 -.707.293z",fill:"currentColor"})})}),className:It("absolute inset-0 tablet:w-auto tablet:h-auto tablet:min-h-fit max-h-svh bg-gradient-to-br from-background/90 from-40% to-background backdrop-blur-lg text-primary drop-shadow-2xl min-w-[320px]",{"opacity-0":!s,"opacity-100":s,"rounded-lg":!f}),children:v.jsxs("div",{style:{width:(u==null?void 0:u.width)||ml,height:(u==null?void 0:u.height)||Fv,left:i.left,top:i.top,right:i.right,bottom:i.bottom},children:[v.jsxs("div",{ref:a,className:"relative flex items-center justify-center px-2 py-2 text-primary",onTouchStart:g=>{var y;const b=(y=g.changedTouches)==null?void 0:y[0];b&&(h.current={time:Date.now(),y:b.clientY})},onTouchEnd:g=>{var y;const b=(y=g.changedTouches)==null?void 0:y[0];b&&h.current&&b.clientY-h.current.y>20&&b.clientY-h.current.y<100&&Date.now()-h.current.time<150&&(g.preventDefault(),t())},children:[f?v.jsx("div",{className:"py-6",children:v.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 h-[8px] w-[80px] top-4 bg-primary rounded-lg"})}):v.jsx(S5,{size:16,className:"block w-full cursor-grab",onMouseDown:g=>{f||(g.preventDefault(),g.stopPropagation(),l())}}),v.jsx("button",{className:"absolute top-0 right-0 px-4 py-2 focus:outline-none focus-visible:outline-accent",onClick:t,children:v.jsx(Om,{size:f?32:16})})]}),v.jsxs("div",{children:[Array.isArray(n)&&n.slice(0,1),v.jsx(Dl,{className:"relative",style:{height:u==null?void 0:u.innerHeight},children:Array.isArray(n)?n.slice(1,-1):n}),v.jsx("div",{ref:p,className:"w-full px-4 pb-0",children:Array.isArray(n)&&n.slice(-1)})]})]})})}function uie({position:e,globalSize:t}){var c,u;const[n,r]=m.useState({left:t.width-ml-74,top:16});m.useEffect(()=>{e&&r(e)},[e]);const[o,i]=m.useState(!1),s=m.useRef(null);m.useEffect(()=>{const d=()=>{i(!1)},f=p=>{var h,g,b,y;if(o){p.preventDefault(),p.stopPropagation();const x=-((((g=(h=s==null?void 0:s.current)==null?void 0:h.getBoundingClientRect())==null?void 0:g.width)||0)/2)+p.clientX,w=-((((y=(b=s==null?void 0:s.current)==null?void 0:b.getBoundingClientRect())==null?void 0:y.height)||0)/2)+ +p.clientY;r({left:x<0?0:x,top:w<0?0:w})}};return document.addEventListener("mouseup",d),document.addEventListener("mousemove",f),()=>{document.removeEventListener("mouseup",d),document.removeEventListener("mousemove",f)}},[o]);const a=()=>i(!0),l=!!((u=(c=s==null?void 0:s.current)==null?void 0:c.getBoundingClientRect())!=null&&u.width);return[n,l,s,a,r]}function die({defaultTheme:e,api:t,store:n,onSubmit:r}){const[o,i]=bT(e),s=MT(t),[a,l]=hie(),[c,u]=pie(a),[d,f]=m.useState(null),p=d!=null&&d.path?d.path.split(","):[],[h,g]=m.useState(Object.fromEntries(p.map(z=>[z,{status:"not-asked"}])));m.useEffect(()=>{g(Object.fromEntries(p.map(j=>[j,{status:"loading"}])));async function z(){const j=await Promise.all(p.map(async le=>{const[U,K]=Fe.splitModuleIdAndModulePath(le),_=await n.getModule(U,!1);if(He.isErr(_))return[U,{status:"error",error:_.error.message}];{const{source:T,schema:C}=_.value;if(!T||!C)return[U,{status:"error",error:"Val could load this content. Please try again."}];{const M=Fe.resolvePath(K,T,C);return!M.source||!M.schema?[U,{status:"error",error:"Val could not internally resolve this content. This is possibly due to a misconfiguration or a bug in Val."}]:[le,{status:"success",data:{source:M.source,schema:M.schema}}]}}}));g(Object.fromEntries(j))}z()},[p.join(";")]);const[b,y]=m.useState();m.useEffect(()=>{n.reset()},[]);const{patches:x,setPatchResetId:w}=wT(s,t),k=m.useCallback(z=>async j=>{const[le,U]=Fe.splitModuleIdAndModulePath(z),K=await j(Fe.createPatchPath(U));n.applyPatch(le,K),w(_=>_+1),r(!0)},[]),[S,O]=m.useState(!1),[E,P]=m.useState({globalError:null}),[N,$]=m.useState(!1);return m.useEffect(()=>{let z=!1;return Object.keys(x).length>0&&($(!0),t.postValidate({patches:x}).then(j=>{z||(He.isErr(j)?P({globalError:{message:j.error.message}}):P({globalError:null,...j.value}))}).finally(()=>{z||$(!1)})),()=>{z=!0}},[x]),v.jsx(r1.Provider,{value:{theme:o,session:s,editMode:a,setEditMode:l,setTheme:i,windowSize:b,setWindowSize:y},children:v.jsxs("div",{id:"val-overlay-container","data-mode":o,className:"font-serif antialiased",style:{position:"fixed",top:0,left:0,zIndex:8999},children:[S&&v.jsx("div",{className:"fixed z-5 top-[16px] left-[16px] w-[calc(100%-32px-50px-16px)] h-[calc(100svh-32px)]",children:v.jsx(jL,{patches:x,isValidating:N,validationResponse:E,api:t,onCancel:()=>{O(!1)},onCommit:()=>{w(z=>z+1)}})}),v.jsxs(Wre,{children:[v.jsx(f$,{}),v.jsx("div",{className:"fixed -translate-y-1/2 right-4 top-1/2 z-overlay",children:v.jsx(Gre,{direction:"vertical",api:t,patches:x,onClickPatches:()=>O(z=>!z)})})]}),s.status==="success"&&s.data.enabled&&(a==="hover"||a==="window")&&c.path&&v.jsx(fie,{hoverTarget:c,setHoverTarget:u,setEditMode:l,setWindowTarget:f}),a==="window"&&d&&v.jsx(cie,{onClose:()=>{f(null),l("hover")},children:v.jsx("div",{className:"p-4",style:{maxHeight:b==null?void 0:b.innerHeight,maxWidth:b==null?void 0:b.width},children:Object.entries(h).map(([z,j])=>{if(j.status!=="success")return v.jsxs("div",{children:[v.jsxs("span",{children:[z,": ",j.status]}),j.status==="error"&&v.jsx("pre",{children:j.error})]},z);const{source:le,schema:U}=j.data;return!le||!U?v.jsxs("div",{children:["Module: ",z," is missing source or schema"]}):v.jsx(xg,{initOnSubmit:k,path:z,schema:U,source:le,top:!0},z)})})})]})})}function fie({hoverTarget:e,setEditMode:t,setWindowTarget:n,setHoverTarget:r}){var i;const o=(i=e.element)==null?void 0:i.getBoundingClientRect();return m.useEffect(()=>{if(e.path){const s=a=>{a.target&&a.target instanceof HTMLElement&&a.target.id!=="val-shadow-root"&&n({...e,path:e.path,mouse:{x:a.pageX,y:a.pageY}}),t("window"),r(null),a.stopPropagation()};return document.body.addEventListener("click",s),()=>{document.body.removeEventListener("click",s)}}},[e]),v.jsx("div",{id:"val-hover",className:"fixed border-2 cursor-pointer z-overlay-hover border-accent",style:{pointerEvents:"none",top:o==null?void 0:o.top,left:o==null?void 0:o.left,width:o==null?void 0:o.width,height:o==null?void 0:o.height},children:v.jsx("div",{className:"flex items-center justify-end w-full text-xs",children:v.jsx("div",{className:"flex items-center justify-center px-3 py-1 border-b-2 border-l-2 text-accent-foreground bg-accent border-accent",style:{maxHeight:(o==null?void 0:o.height)&&o.height-4,fontSize:o!=null&&o.height&&o.height<=16?o.height-4:void 0},children:"Edit"})})})}function pie(e){const[t,n]=m.useState(),[r,o]=m.useState(),[i,s]=m.useState();function a(l){if(l){const c=[];l.dataset.valPath&&c.push(l.dataset.valPath);for(const u of Array.from(l.querySelectorAll("*")))if(u instanceof HTMLElement){const d=u.dataset.valPath;d&&c.push(d)}c.length>0&&(n(l),o(c.join(",")),s(l.getBoundingClientRect()))}}return m.useEffect(()=>{if(e==="hover"||e==="window"){const l=c=>{a(c.target)};return document.addEventListener("mouseover",l),()=>{n(void 0),o(void 0),document.removeEventListener("mouseover",l)}}},[e]),m.useEffect(()=>{const l=()=>{t&&s(t.getBoundingClientRect())},c=new ResizeObserver(()=>{t&&s(t.getBoundingClientRect())}),u=document.getElementById("val-shadow-root");return t&&u&&c.observe(u),document.addEventListener("scroll",l,{passive:!0}),()=>{document.removeEventListener("scroll",l),c.disconnect()}},[t]),[{path:r,element:t,rect:i},l=>{var c;n(l==null?void 0:l.element),o(l==null?void 0:l.path),s((c=l==null?void 0:l.element)==null?void 0:c.getBoundingClientRect())}]}const tp="val-edit-mode";function hie(){const[e,t]=m.useState("off");m.useEffect(()=>{try{const r=localStorage.getItem(tp);r==="off"||r==="hover"||r==="window"||r==="full"?t(r==="window"?"hover":r):(localStorage.removeItem(tp),t("off"))}catch{t("off")}},[]);const n=m.useCallback(r=>{typeof r=="function"?t(o=>{const i=r(o);return localStorage.setItem(tp,i),i}):(localStorage.setItem(tp,r),t(r))},[]);return[e,n]}function mie(){const e="/api/val",t=new Qx(e),n=new x1(t);return v.jsx(Lb,{fallbackRender:jb,children:v.jsxs(Pre,{children:[v.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),v.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),v.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap",rel:"stylesheet"}),v.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;1,100;1,300;1,400;1,500;1,700&family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap",rel:"stylesheet"}),v.jsx("style",{children:`
217
+ `,e.getElementsByTagName("head")[0].appendChild(t)),e.body&&b$(e.body,"react-draggable-transparent-selection")}function yoe(e){if(e)try{if(e.body&&w$(e.body,"react-draggable-transparent-selection"),e.selection)e.selection.empty();else{const t=(e.defaultView||window).getSelection();t&&t.type!=="Caret"&&t.removeAllRanges()}}catch{}}function b$(e,t){e.classList?e.classList.add(t):e.className.match(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)")))||(e.className+=" ".concat(t))}function w$(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)"),"g"),"")}var Do={};Object.defineProperty(Do,"__esModule",{value:!0});Do.canDragX=woe;Do.canDragY=koe;Do.createCoreData=Eoe;Do.createDraggableData=_oe;Do.getBoundPosition=xoe;Do.getControlPosition=Soe;Do.snapToGrid=boe;var Gn=Io,Pl=bt;function xoe(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r=typeof r=="string"?r:Coe(r);const o=Hb(e);if(typeof r=="string"){const{ownerDocument:i}=o,s=i.defaultView;let a;if(r==="parent"?a=o.parentNode:a=i.querySelector(r),!(a instanceof s.HTMLElement))throw new Error('Bounds selector "'+r+'" could not find an element.');const l=a,c=s.getComputedStyle(o),u=s.getComputedStyle(l);r={left:-o.offsetLeft+(0,Gn.int)(u.paddingLeft)+(0,Gn.int)(c.marginLeft),top:-o.offsetTop+(0,Gn.int)(u.paddingTop)+(0,Gn.int)(c.marginTop),right:(0,Pl.innerWidth)(l)-(0,Pl.outerWidth)(o)-o.offsetLeft+(0,Gn.int)(u.paddingRight)-(0,Gn.int)(c.marginRight),bottom:(0,Pl.innerHeight)(l)-(0,Pl.outerHeight)(o)-o.offsetTop+(0,Gn.int)(u.paddingBottom)-(0,Gn.int)(c.marginBottom)}}return(0,Gn.isNum)(r.right)&&(t=Math.min(t,r.right)),(0,Gn.isNum)(r.bottom)&&(n=Math.min(n,r.bottom)),(0,Gn.isNum)(r.left)&&(t=Math.max(t,r.left)),(0,Gn.isNum)(r.top)&&(n=Math.max(n,r.top)),[t,n]}function boe(e,t,n){const r=Math.round(t/e[0])*e[0],o=Math.round(n/e[1])*e[1];return[r,o]}function woe(e){return e.props.axis==="both"||e.props.axis==="x"}function koe(e){return e.props.axis==="both"||e.props.axis==="y"}function Soe(e,t,n){const r=typeof t=="number"?(0,Pl.getTouch)(e,t):null;if(typeof t=="number"&&!r)return null;const o=Hb(n),i=n.props.offsetParent||o.offsetParent||o.ownerDocument.body;return(0,Pl.offsetXYFromParent)(r||e,i,n.props.scale)}function Eoe(e,t,n){const r=!(0,Gn.isNum)(e.lastX),o=Hb(e);return r?{node:o,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:o,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}}function _oe(e,t){const n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function Coe(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function Hb(e){const t=e.findDOMNode();if(!t)throw new Error("<DraggableCore>: Unmounted during event!");return t}var wg={},kg={};Object.defineProperty(kg,"__esModule",{value:!0});kg.default=Ooe;function Ooe(){}Object.defineProperty(wg,"__esModule",{value:!0});wg.default=void 0;var Dv=Poe(m),Rn=Wb(rf),Toe=Wb(Nr),ln=bt,Pi=Do,Lv=Io,Gc=Wb(kg);function Wb(e){return e&&e.__esModule?e:{default:e}}function k$(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,n=new WeakMap;return(k$=function(r){return r?n:t})(e)}function Poe(e,t){if(!t&&e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var n=k$(t);if(n&&n.has(e))return n.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)){var s=o?Object.getOwnPropertyDescriptor(e,i):null;s&&(s.get||s.set)?Object.defineProperty(r,i,s):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}function yn(e,t,n){return t=Moe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Moe(e){var t=Noe(e,"string");return typeof t=="symbol"?t:String(t)}function Noe(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}const Ur={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}};let Mi=Ur.mouse,Sg=class extends Dv.Component{constructor(){super(...arguments),yn(this,"dragging",!1),yn(this,"lastX",NaN),yn(this,"lastY",NaN),yn(this,"touchIdentifier",null),yn(this,"mounted",!1),yn(this,"handleDragStart",t=>{if(this.props.onMouseDown(t),!this.props.allowAnyClick&&typeof t.button=="number"&&t.button!==0)return!1;const n=this.findDOMNode();if(!n||!n.ownerDocument||!n.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");const{ownerDocument:r}=n;if(this.props.disabled||!(t.target instanceof r.defaultView.Node)||this.props.handle&&!(0,ln.matchesSelectorAndParentsTo)(t.target,this.props.handle,n)||this.props.cancel&&(0,ln.matchesSelectorAndParentsTo)(t.target,this.props.cancel,n))return;t.type==="touchstart"&&t.preventDefault();const o=(0,ln.getTouchIdentifier)(t);this.touchIdentifier=o;const i=(0,Pi.getControlPosition)(t,o,this);if(i==null)return;const{x:s,y:a}=i,l=(0,Pi.createCoreData)(this,s,a);(0,Gc.default)("DraggableCore: handleDragStart: %j",l),(0,Gc.default)("calling",this.props.onStart),!(this.props.onStart(t,l)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&(0,ln.addUserSelectStyles)(r),this.dragging=!0,this.lastX=s,this.lastY=a,(0,ln.addEvent)(r,Mi.move,this.handleDrag),(0,ln.addEvent)(r,Mi.stop,this.handleDragStop))}),yn(this,"handleDrag",t=>{const n=(0,Pi.getControlPosition)(t,this.touchIdentifier,this);if(n==null)return;let{x:r,y:o}=n;if(Array.isArray(this.props.grid)){let a=r-this.lastX,l=o-this.lastY;if([a,l]=(0,Pi.snapToGrid)(this.props.grid,a,l),!a&&!l)return;r=this.lastX+a,o=this.lastY+l}const i=(0,Pi.createCoreData)(this,r,o);if((0,Gc.default)("DraggableCore: handleDrag: %j",i),this.props.onDrag(t,i)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent("mouseup"))}catch{const l=document.createEvent("MouseEvents");l.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(l)}return}this.lastX=r,this.lastY=o}),yn(this,"handleDragStop",t=>{if(!this.dragging)return;const n=(0,Pi.getControlPosition)(t,this.touchIdentifier,this);if(n==null)return;let{x:r,y:o}=n;if(Array.isArray(this.props.grid)){let l=r-this.lastX||0,c=o-this.lastY||0;[l,c]=(0,Pi.snapToGrid)(this.props.grid,l,c),r=this.lastX+l,o=this.lastY+c}const i=(0,Pi.createCoreData)(this,r,o);if(this.props.onStop(t,i)===!1||this.mounted===!1)return!1;const a=this.findDOMNode();a&&this.props.enableUserSelectHack&&(0,ln.removeUserSelectStyles)(a.ownerDocument),(0,Gc.default)("DraggableCore: handleDragStop: %j",i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&((0,Gc.default)("DraggableCore: Removing handlers"),(0,ln.removeEvent)(a.ownerDocument,Mi.move,this.handleDrag),(0,ln.removeEvent)(a.ownerDocument,Mi.stop,this.handleDragStop))}),yn(this,"onMouseDown",t=>(Mi=Ur.mouse,this.handleDragStart(t))),yn(this,"onMouseUp",t=>(Mi=Ur.mouse,this.handleDragStop(t))),yn(this,"onTouchStart",t=>(Mi=Ur.touch,this.handleDragStart(t))),yn(this,"onTouchEnd",t=>(Mi=Ur.touch,this.handleDragStop(t)))}componentDidMount(){this.mounted=!0;const t=this.findDOMNode();t&&(0,ln.addEvent)(t,Ur.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const t=this.findDOMNode();if(t){const{ownerDocument:n}=t;(0,ln.removeEvent)(n,Ur.mouse.move,this.handleDrag),(0,ln.removeEvent)(n,Ur.touch.move,this.handleDrag),(0,ln.removeEvent)(n,Ur.mouse.stop,this.handleDragStop),(0,ln.removeEvent)(n,Ur.touch.stop,this.handleDragStop),(0,ln.removeEvent)(t,Ur.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,ln.removeUserSelectStyles)(n)}}findDOMNode(){var t,n;return(t=this.props)!==null&&t!==void 0&&t.nodeRef?(n=this.props)===null||n===void 0||(n=n.nodeRef)===null||n===void 0?void 0:n.current:Toe.default.findDOMNode(this)}render(){return Dv.cloneElement(Dv.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};wg.default=Sg;yn(Sg,"displayName","DraggableCore");yn(Sg,"propTypes",{allowAnyClick:Rn.default.bool,children:Rn.default.node.isRequired,disabled:Rn.default.bool,enableUserSelectHack:Rn.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:Rn.default.arrayOf(Rn.default.number),handle:Rn.default.string,cancel:Rn.default.string,nodeRef:Rn.default.object,onStart:Rn.default.func,onDrag:Rn.default.func,onStop:Rn.default.func,onMouseDown:Rn.default.func,scale:Rn.default.number,className:Lv.dontSetMe,style:Lv.dontSetMe,transform:Lv.dontSetMe});yn(Sg,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1});(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return l.default}}),e.default=void 0;var t=f(m),n=u(rf),r=u(Nr),o=u(Xre),i=bt,s=Do,a=Io,l=u(wg),c=u(kg);function u(x){return x&&x.__esModule?x:{default:x}}function d(x){if(typeof WeakMap!="function")return null;var w=new WeakMap,k=new WeakMap;return(d=function(S){return S?k:w})(x)}function f(x,w){if(!w&&x&&x.__esModule)return x;if(x===null||typeof x!="object"&&typeof x!="function")return{default:x};var k=d(w);if(k&&k.has(x))return k.get(x);var S={},O=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var E in x)if(E!=="default"&&Object.prototype.hasOwnProperty.call(x,E)){var P=O?Object.getOwnPropertyDescriptor(x,E):null;P&&(P.get||P.set)?Object.defineProperty(S,E,P):S[E]=x[E]}return S.default=x,k&&k.set(x,S),S}function p(){return p=Object.assign?Object.assign.bind():function(x){for(var w=1;w<arguments.length;w++){var k=arguments[w];for(var S in k)Object.prototype.hasOwnProperty.call(k,S)&&(x[S]=k[S])}return x},p.apply(this,arguments)}function h(x,w,k){return w=g(w),w in x?Object.defineProperty(x,w,{value:k,enumerable:!0,configurable:!0,writable:!0}):x[w]=k,x}function g(x){var w=b(x,"string");return typeof w=="symbol"?w:String(w)}function b(x,w){if(typeof x!="object"||x===null)return x;var k=x[Symbol.toPrimitive];if(k!==void 0){var S=k.call(x,w||"default");if(typeof S!="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return(w==="string"?String:Number)(x)}class y extends t.Component{static getDerivedStateFromProps(w,k){let{position:S}=w,{prevPropsPosition:O}=k;return S&&(!O||S.x!==O.x||S.y!==O.y)?((0,c.default)("Draggable: getDerivedStateFromProps %j",{position:S,prevPropsPosition:O}),{x:S.x,y:S.y,prevPropsPosition:{...S}}):null}constructor(w){super(w),h(this,"onDragStart",(k,S)=>{if((0,c.default)("Draggable: onDragStart: %j",S),this.props.onStart(k,(0,s.createDraggableData)(this,S))===!1)return!1;this.setState({dragging:!0,dragged:!0})}),h(this,"onDrag",(k,S)=>{if(!this.state.dragging)return!1;(0,c.default)("Draggable: onDrag: %j",S);const O=(0,s.createDraggableData)(this,S),E={x:O.x,y:O.y,slackX:0,slackY:0};if(this.props.bounds){const{x:N,y:$}=E;E.x+=this.state.slackX,E.y+=this.state.slackY;const[z,j]=(0,s.getBoundPosition)(this,E.x,E.y);E.x=z,E.y=j,E.slackX=this.state.slackX+(N-E.x),E.slackY=this.state.slackY+($-E.y),O.x=E.x,O.y=E.y,O.deltaX=E.x-this.state.x,O.deltaY=E.y-this.state.y}if(this.props.onDrag(k,O)===!1)return!1;this.setState(E)}),h(this,"onDragStop",(k,S)=>{if(!this.state.dragging||this.props.onStop(k,(0,s.createDraggableData)(this,S))===!1)return!1;(0,c.default)("Draggable: onDragStop: %j",S);const E={dragging:!1,slackX:0,slackY:0};if(!!this.props.position){const{x:N,y:$}=this.props.position;E.x=N,E.y=$}this.setState(E)}),this.state={dragging:!1,dragged:!1,x:w.position?w.position.x:w.defaultPosition.x,y:w.position?w.position.y:w.defaultPosition.y,prevPropsPosition:{...w.position},slackX:0,slackY:0,isElementSVG:!1},w.position&&!(w.onDrag||w.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){typeof window.SVGElement<"u"&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.setState({dragging:!1})}findDOMNode(){var w,k;return(w=(k=this.props)===null||k===void 0||(k=k.nodeRef)===null||k===void 0?void 0:k.current)!==null&&w!==void 0?w:r.default.findDOMNode(this)}render(){const{axis:w,bounds:k,children:S,defaultPosition:O,defaultClassName:E,defaultClassNameDragging:P,defaultClassNameDragged:N,position:$,positionOffset:z,scale:j,...le}=this.props;let U={},K=null;const T=!!!$||this.state.dragging,C=$||O,M={x:(0,s.canDragX)(this)&&T?this.state.x:C.x,y:(0,s.canDragY)(this)&&T?this.state.y:C.y};this.state.isElementSVG?K=(0,i.createSVGTransform)(M,z):U=(0,i.createCSSTransform)(M,z);const R=(0,o.default)(S.props.className||"",E,{[P]:this.state.dragging,[N]:this.state.dragged});return t.createElement(l.default,p({},le,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),t.cloneElement(t.Children.only(S),{className:R,style:{...S.props.style,...U},transform:K}))}}e.default=y,h(y,"displayName","Draggable"),h(y,"propTypes",{...l.default.propTypes,axis:n.default.oneOf(["both","x","y","none"]),bounds:n.default.oneOfType([n.default.shape({left:n.default.number,right:n.default.number,top:n.default.number,bottom:n.default.number}),n.default.string,n.default.oneOf([!1])]),defaultClassName:n.default.string,defaultClassNameDragging:n.default.string,defaultClassNameDragged:n.default.string,defaultPosition:n.default.shape({x:n.default.number,y:n.default.number}),positionOffset:n.default.shape({x:n.default.oneOfType([n.default.number,n.default.string]),y:n.default.oneOfType([n.default.number,n.default.string])}),position:n.default.shape({x:n.default.number,y:n.default.number}),className:a.dontSetMe,style:a.dontSetMe,transform:a.dontSetMe}),h(y,"defaultProps",{...l.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})})(h$);const{default:S$,DraggableCore:Roe}=h$;bg.exports=S$;bg.exports.default=S$;bg.exports.DraggableCore=Roe;var $oe=bg.exports,Kb={};Kb.__esModule=!0;Kb.cloneElement=zoe;var Aoe=Ioe(m);function Ioe(e){return e&&e.__esModule?e:{default:e}}function p_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function h_(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?p_(Object(n),!0).forEach(function(r){Doe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p_(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Doe(e,t,n){return t=Loe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Loe(e){var t=joe(e,"string");return typeof t=="symbol"?t:String(t)}function joe(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function zoe(e,t){return t.style&&e.props.style&&(t.style=h_(h_({},e.props.style),t.style)),t.className&&e.props.className&&(t.className=e.props.className+" "+t.className),Aoe.default.cloneElement(e,t)}var vf={};vf.__esModule=!0;vf.resizableProps=void 0;var Se=Foe(rf);function Foe(e){return e&&e.__esModule?e:{default:e}}var Boe={axis:Se.default.oneOf(["both","x","y","none"]),className:Se.default.string,children:Se.default.element.isRequired,draggableOpts:Se.default.shape({allowAnyClick:Se.default.bool,cancel:Se.default.string,children:Se.default.node,disabled:Se.default.bool,enableUserSelectHack:Se.default.bool,offsetParent:Se.default.node,grid:Se.default.arrayOf(Se.default.number),handle:Se.default.string,nodeRef:Se.default.object,onStart:Se.default.func,onDrag:Se.default.func,onStop:Se.default.func,onMouseDown:Se.default.func,scale:Se.default.number}),height:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var o=n[0];if(o.axis==="both"||o.axis==="y"){var i;return(i=Se.default.number).isRequired.apply(i,n)}return Se.default.number.apply(Se.default,n)},handle:Se.default.oneOfType([Se.default.node,Se.default.func]),handleSize:Se.default.arrayOf(Se.default.number),lockAspectRatio:Se.default.bool,maxConstraints:Se.default.arrayOf(Se.default.number),minConstraints:Se.default.arrayOf(Se.default.number),onResizeStop:Se.default.func,onResizeStart:Se.default.func,onResize:Se.default.func,resizeHandles:Se.default.arrayOf(Se.default.oneOf(["s","w","e","n","sw","nw","se","ne"])),transformScale:Se.default.number,width:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var o=n[0];if(o.axis==="both"||o.axis==="x"){var i;return(i=Se.default.number).isRequired.apply(i,n)}return Se.default.number.apply(Se.default,n)}};vf.resizableProps=Boe;gf.__esModule=!0;gf.default=void 0;var Yc=Koe(m),Voe=$oe,Uoe=Kb,Hoe=vf,Woe=["children","className","draggableOpts","width","height","handle","handleSize","lockAspectRatio","axis","minConstraints","maxConstraints","onResize","onResizeStop","onResizeStart","resizeHandles","transformScale"];function E$(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,n=new WeakMap;return(E$=function(o){return o?n:t})(e)}function Koe(e,t){if(!t&&e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var n=E$(t);if(n&&n.has(e))return n.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)){var s=o?Object.getOwnPropertyDescriptor(e,i):null;s&&(s.get||s.set)?Object.defineProperty(r,i,s):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}function X0(){return X0=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X0.apply(this,arguments)}function qoe(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,i;for(i=0;i<r.length;i++)o=r[i],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function m_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function jv(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?m_(Object(n),!0).forEach(function(r){Goe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m_(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Goe(e,t,n){return t=Yoe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Yoe(e){var t=Xoe(e,"string");return typeof t=="symbol"?t:String(t)}function Xoe(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Zoe(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Z0(e,t)}function Z0(e,t){return Z0=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Z0(e,t)}var qb=function(e){Zoe(t,e);function t(){for(var r,o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];return r=e.call.apply(e,[this].concat(i))||this,r.handleRefs={},r.lastHandleRect=null,r.slack=null,r}var n=t.prototype;return n.componentWillUnmount=function(){this.resetData()},n.resetData=function(){this.lastHandleRect=this.slack=null},n.runConstraints=function(o,i){var s=this.props,a=s.minConstraints,l=s.maxConstraints,c=s.lockAspectRatio;if(!a&&!l&&!c)return[o,i];if(c){var u=this.props.width/this.props.height,d=o-this.props.width,f=i-this.props.height;Math.abs(d)>Math.abs(f*u)?i=o/u:o=i*u}var p=o,h=i,g=this.slack||[0,0],b=g[0],y=g[1];return o+=b,i+=y,a&&(o=Math.max(a[0],o),i=Math.max(a[1],i)),l&&(o=Math.min(l[0],o),i=Math.min(l[1],i)),this.slack=[b+(p-o),y+(h-i)],[o,i]},n.resizeHandler=function(o,i){var s=this;return function(a,l){var c=l.node,u=l.deltaX,d=l.deltaY;o==="onResizeStart"&&s.resetData();var f=(s.props.axis==="both"||s.props.axis==="x")&&i!=="n"&&i!=="s",p=(s.props.axis==="both"||s.props.axis==="y")&&i!=="e"&&i!=="w";if(!(!f&&!p)){var h=i[0],g=i[i.length-1],b=c.getBoundingClientRect();if(s.lastHandleRect!=null){if(g==="w"){var y=b.left-s.lastHandleRect.left;u+=y}if(h==="n"){var x=b.top-s.lastHandleRect.top;d+=x}}s.lastHandleRect=b,g==="w"&&(u=-u),h==="n"&&(d=-d);var w=s.props.width+(f?u/s.props.transformScale:0),k=s.props.height+(p?d/s.props.transformScale:0),S=s.runConstraints(w,k);w=S[0],k=S[1];var O=w!==s.props.width||k!==s.props.height,E=typeof s.props[o]=="function"?s.props[o]:null,P=o==="onResize"&&!O;E&&!P&&(a.persist==null||a.persist(),E(a,{node:c,size:{width:w,height:k},handle:i})),o==="onResizeStop"&&s.resetData()}}},n.renderResizeHandle=function(o,i){var s=this.props.handle;if(!s)return Yc.createElement("span",{className:"react-resizable-handle react-resizable-handle-"+o,ref:i});if(typeof s=="function")return s(o,i);var a=typeof s.type=="string",l=jv({ref:i},a?{}:{handleAxis:o});return Yc.cloneElement(s,l)},n.render=function(){var o=this,i=this.props,s=i.children,a=i.className,l=i.draggableOpts;i.width,i.height,i.handle,i.handleSize,i.lockAspectRatio,i.axis,i.minConstraints,i.maxConstraints,i.onResize,i.onResizeStop,i.onResizeStart;var c=i.resizeHandles;i.transformScale;var u=qoe(i,Woe);return(0,Uoe.cloneElement)(s,jv(jv({},u),{},{className:(a?a+" ":"")+"react-resizable",children:[].concat(s.props.children,c.map(function(d){var f,p=(f=o.handleRefs[d])!=null?f:o.handleRefs[d]=Yc.createRef();return Yc.createElement(Voe.DraggableCore,X0({},l,{nodeRef:p,key:"resizableHandle-"+d,onStop:o.resizeHandler("onResizeStop",d),onStart:o.resizeHandler("onResizeStart",d),onDrag:o.resizeHandler("onResize",d)}),o.renderResizeHandle(d,p))}))}))},t}(Yc.Component);gf.default=qb;qb.propTypes=Hoe.resizableProps;qb.defaultProps={axis:"both",handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:["se"],transformScale:1};var Eg={};Eg.__esModule=!0;Eg.default=void 0;var zv=nie(m),Joe=_$(rf),Qoe=_$(gf),eie=vf,tie=["handle","handleSize","onResize","onResizeStart","onResizeStop","draggableOpts","minConstraints","maxConstraints","lockAspectRatio","axis","width","height","resizeHandles","style","transformScale"];function _$(e){return e&&e.__esModule?e:{default:e}}function C$(e){if(typeof WeakMap!="function")return null;var t=new WeakMap,n=new WeakMap;return(C$=function(o){return o?n:t})(e)}function nie(e,t){if(!t&&e&&e.__esModule)return e;if(e===null||typeof e!="object"&&typeof e!="function")return{default:e};var n=C$(t);if(n&&n.has(e))return n.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)){var s=o?Object.getOwnPropertyDescriptor(e,i):null;s&&(s.get||s.set)?Object.defineProperty(r,i,s):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}function J0(){return J0=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},J0.apply(this,arguments)}function g_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function nm(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?g_(Object(n),!0).forEach(function(r){rie(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):g_(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function rie(e,t,n){return t=oie(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oie(e){var t=iie(e,"string");return typeof t=="symbol"?t:String(t)}function iie(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function sie(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,i;for(i=0;i<r.length;i++)o=r[i],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function aie(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Q0(e,t)}function Q0(e,t){return Q0=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Q0(e,t)}var O$=function(e){aie(t,e);function t(){for(var r,o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];return r=e.call.apply(e,[this].concat(i))||this,r.state={width:r.props.width,height:r.props.height,propsWidth:r.props.width,propsHeight:r.props.height},r.onResize=function(a,l){var c=l.size;r.props.onResize?(a.persist==null||a.persist(),r.setState(c,function(){return r.props.onResize&&r.props.onResize(a,l)})):r.setState(c)},r}t.getDerivedStateFromProps=function(o,i){return i.propsWidth!==o.width||i.propsHeight!==o.height?{width:o.width,height:o.height,propsWidth:o.width,propsHeight:o.height}:null};var n=t.prototype;return n.render=function(){var o=this.props,i=o.handle,s=o.handleSize;o.onResize;var a=o.onResizeStart,l=o.onResizeStop,c=o.draggableOpts,u=o.minConstraints,d=o.maxConstraints,f=o.lockAspectRatio,p=o.axis;o.width,o.height;var h=o.resizeHandles,g=o.style,b=o.transformScale,y=sie(o,tie);return zv.createElement(Qoe.default,{axis:p,draggableOpts:c,handle:i,handleSize:s,height:this.state.height,lockAspectRatio:f,maxConstraints:d,minConstraints:u,onResizeStart:a,onResize:this.onResize,onResizeStop:l,resizeHandles:h,transformScale:b,width:this.state.width},zv.createElement("div",J0({},y,{style:nm(nm({},g),{},{width:this.state.width+"px",height:this.state.height+"px"})})))},t}(zv.Component);Eg.default=O$;O$.propTypes=nm(nm({},eie.resizableProps),{},{children:Joe.default.element});Vb.exports=function(){throw new Error("Don't instantiate Resizable directly! Use require('react-resizable').Resizable")};var lie=Vb.exports.Resizable=gf.default;Vb.exports.ResizableBox=Eg.default;const ml=400,Fv=250;function cie({position:e,onClose:t,children:n}){const[r,o]=m.useState({height:window.innerHeight,width:window.innerWidth});m.useEffect(()=>{const g=()=>{window.visualViewport?o({height:window.visualViewport.height,width:window.visualViewport.width}):o({height:window.innerHeight,width:window.innerWidth})};return window.addEventListener("resize",g),window.addEventListener("orientationchange",g),()=>{window.removeEventListener("resize",g),window.removeEventListener("orientationchange",g)}},[]);const[i,s,a,l,c]=uie({position:e,globalSize:r});m.useEffect(()=>{c({left:r.width-ml-74,top:16})},[r]),m.useEffect(()=>{const g=b=>{b.key==="Escape"&&t()};return document.addEventListener("keyup",g),()=>{document.removeEventListener("keyup",g)}},[]);const{windowSize:u,setWindowSize:d}=Tm(),f=r.width<=600||r.height<=600;m.useEffect(()=>{var g,b;d({height:window.innerHeight-30,width:ml,innerHeight:window.innerHeight-30-(64+(((b=(g=p.current)==null?void 0:g.getBoundingClientRect())==null?void 0:b.height)||0))})},[]);const p=m.useRef(null);m.useEffect(()=>{if(f){c({top:0,left:0}),d({height:window.innerHeight,width:window.innerWidth,innerHeight:window.innerHeight-64});const g=document.ownerDocument||document,b=g.body.style.overflow;return g.body.style.overflow="hidden",()=>{g.body.style.overflow=b}}},[f,r]);const h=m.useRef();return v.jsx(lie,{minConstraints:f?void 0:[ml,Fv],width:(u==null?void 0:u.width)||ml,height:(u==null?void 0:u.height)||Fv,onResize:(g,{size:b})=>{var y,x;return!f&&d({...b,innerHeight:b.height-(64+(((x=(y=p.current)==null?void 0:y.getBoundingClientRect())==null?void 0:x.height)||0))})},handle:f?null:v.jsx("div",{className:"fixed bottom-0 right-0 cursor-se-resize",children:v.jsx("svg",{height:"18",viewBox:"0 0 18 18",width:"18",xmlns:"http://www.w3.org/2000/svg",children:v.jsx("path",{d:"m14.228 16.227a1 1 0 0 1 -.707-1.707l1-1a1 1 0 0 1 1.416 1.414l-1 1a1 1 0 0 1 -.707.293zm-5.638 0a1 1 0 0 1 -.707-1.707l6.638-6.638a1 1 0 0 1 1.416 1.414l-6.638 6.638a1 1 0 0 1 -.707.293zm-5.84 0a1 1 0 0 1 -.707-1.707l12.477-12.477a1 1 0 1 1 1.415 1.414l-12.478 12.477a1 1 0 0 1 -.707.293z",fill:"currentColor"})})}),className:It("absolute inset-0 tablet:w-auto tablet:h-auto tablet:min-h-fit max-h-svh bg-gradient-to-br from-background/90 from-40% to-background backdrop-blur-lg text-primary drop-shadow-2xl min-w-[320px]",{"opacity-0":!s,"opacity-100":s,"rounded-lg":!f}),children:v.jsxs("div",{style:{width:(u==null?void 0:u.width)||ml,height:(u==null?void 0:u.height)||Fv,left:i.left,top:i.top,right:i.right,bottom:i.bottom},children:[v.jsxs("div",{ref:a,className:"relative flex items-center justify-center px-2 py-2 text-primary",onTouchStart:g=>{var y;const b=(y=g.changedTouches)==null?void 0:y[0];b&&(h.current={time:Date.now(),y:b.clientY})},onTouchEnd:g=>{var y;const b=(y=g.changedTouches)==null?void 0:y[0];b&&h.current&&b.clientY-h.current.y>20&&b.clientY-h.current.y<100&&Date.now()-h.current.time<150&&(g.preventDefault(),t())},children:[f?v.jsx("div",{className:"py-6",children:v.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 h-[8px] w-[80px] top-4 bg-primary rounded-lg"})}):v.jsx(S5,{size:16,className:"block w-full cursor-grab",onMouseDown:g=>{f||(g.preventDefault(),g.stopPropagation(),l())}}),v.jsx("button",{className:"absolute top-0 right-0 px-4 py-2 focus:outline-none focus-visible:outline-accent",onClick:t,children:v.jsx(Om,{size:f?32:16})})]}),v.jsxs("div",{children:[Array.isArray(n)&&n.slice(0,1),v.jsx(Dl,{className:"relative",style:{height:u==null?void 0:u.innerHeight},children:Array.isArray(n)?n.slice(1,-1):n}),v.jsx("div",{ref:p,className:"w-full px-4 pb-0",children:Array.isArray(n)&&n.slice(-1)})]})]})})}function uie({position:e,globalSize:t}){var c,u;const[n,r]=m.useState({left:t.width-ml-74,top:16});m.useEffect(()=>{e&&r(e)},[e]);const[o,i]=m.useState(!1),s=m.useRef(null);m.useEffect(()=>{const d=()=>{i(!1)},f=p=>{var h,g,b,y;if(o){p.preventDefault(),p.stopPropagation();const x=-((((g=(h=s==null?void 0:s.current)==null?void 0:h.getBoundingClientRect())==null?void 0:g.width)||0)/2)+p.clientX,w=-((((y=(b=s==null?void 0:s.current)==null?void 0:b.getBoundingClientRect())==null?void 0:y.height)||0)/2)+ +p.clientY;r({left:x<0?0:x,top:w<0?0:w})}};return document.addEventListener("mouseup",d),document.addEventListener("mousemove",f),()=>{document.removeEventListener("mouseup",d),document.removeEventListener("mousemove",f)}},[o]);const a=()=>i(!0),l=!!((u=(c=s==null?void 0:s.current)==null?void 0:c.getBoundingClientRect())!=null&&u.width);return[n,l,s,a,r]}function die({defaultTheme:e,api:t,store:n,onSubmit:r}){const[o,i]=bT(e),s=MT(t),[a,l]=hie(),[c,u]=pie(a),[d,f]=m.useState(null),p=d!=null&&d.path?d.path.split(","):[],[h,g]=m.useState(Object.fromEntries(p.map(z=>[z,{status:"not-asked"}])));m.useEffect(()=>{g(Object.fromEntries(p.map(j=>[j,{status:"loading"}])));async function z(){const j=await Promise.all(p.map(async le=>{const[U,K]=Fe.splitModuleIdAndModulePath(le),_=await n.getModule(U,!1);if(He.isErr(_))return[U,{status:"error",error:_.error.message}];{const{source:T,schema:C}=_.value;if(!T||!C)return[U,{status:"error",error:"Val could load this content. Please try again."}];{const M=Fe.resolvePath(K,T,C);return!M.source||!M.schema?[U,{status:"error",error:"Val could not internally resolve this content. This is possibly due to a misconfiguration or a bug in Val."}]:[le,{status:"success",data:{source:M.source,schema:M.schema}}]}}}));g(Object.fromEntries(j))}z()},[p.join(";")]);const[b,y]=m.useState();m.useEffect(()=>{n.reset()},[]);const{patches:x,setPatchResetId:w}=wT(s,t),k=m.useCallback(z=>async j=>{const[le,U]=Fe.splitModuleIdAndModulePath(z),K=await j(Fe.createPatchPath(U));n.applyPatch(le,K),w(_=>_+1),r(!0)},[]),[S,O]=m.useState(!1),[E,P]=m.useState({globalError:null}),[N,$]=m.useState(!1);return m.useEffect(()=>{let z=!1;return Object.keys(x).length>0&&($(!0),t.postValidate({patches:x}).then(j=>{z||(He.isErr(j)?P({globalError:{message:j.error.message}}):P({globalError:null,...j.value}))}).finally(()=>{z||$(!1)})),()=>{z=!0}},[x]),v.jsx(r1.Provider,{value:{theme:o,session:s,editMode:a,setEditMode:l,setTheme:i,windowSize:b,setWindowSize:y},children:v.jsxs("div",{id:"val-overlay-container","data-mode":o,className:"font-serif antialiased",style:{position:"fixed",top:0,left:0,zIndex:8999},children:[S&&v.jsx("div",{className:"fixed z-5 top-[16px] left-[16px] w-[calc(100%-32px-50px-16px)] h-[calc(100svh-32px)]",children:v.jsx(jL,{patches:x,isValidating:N,validationResponse:E,api:t,onCancel:()=>{O(!1)},onCommit:()=>{w(z=>z+1)}})}),v.jsxs(Wre,{children:[v.jsx(f$,{}),v.jsx("div",{className:"fixed -translate-y-1/2 right-4 top-1/2 z-overlay",children:v.jsx(Gre,{direction:"vertical",api:t,patches:x,onClickPatches:()=>O(z=>!z)})})]}),s.status==="success"&&s.data.enabled&&(a==="hover"||a==="window")&&c.path&&v.jsx(fie,{hoverTarget:c,setHoverTarget:u,setEditMode:l,setWindowTarget:f}),a==="window"&&d&&v.jsx(cie,{onClose:()=>{f(null),l("hover")},children:v.jsx("div",{className:"p-4",style:{maxHeight:b==null?void 0:b.innerHeight,maxWidth:b==null?void 0:b.width},children:Object.entries(h).map(([z,j])=>{if(j.status!=="success")return v.jsxs("div",{children:[v.jsxs("span",{children:[z,j.status!=="error"&&v.jsxs("span",{children:[": ",j.status]})]}),j.status==="error"&&v.jsx("pre",{className:"text-red-600 whitespace-pre-wrap",children:j.error})]},z);const{source:le,schema:U}=j.data;return!le||!U?v.jsxs("div",{children:["Module: ",z," is missing source or schema"]}):v.jsx(xg,{initOnSubmit:k,path:z,schema:U,source:le,top:!0},z)})})})]})})}function fie({hoverTarget:e,setEditMode:t,setWindowTarget:n,setHoverTarget:r}){var i;const o=(i=e.element)==null?void 0:i.getBoundingClientRect();return m.useEffect(()=>{if(e.path){const s=a=>{a.target&&a.target instanceof HTMLElement&&a.target.id!=="val-shadow-root"&&n({...e,path:e.path,mouse:{x:a.pageX,y:a.pageY}}),t("window"),r(null),a.stopPropagation()};return document.body.addEventListener("click",s),()=>{document.body.removeEventListener("click",s)}}},[e]),v.jsx("div",{id:"val-hover",className:"fixed border-2 cursor-pointer z-overlay-hover border-accent",style:{pointerEvents:"none",top:o==null?void 0:o.top,left:o==null?void 0:o.left,width:o==null?void 0:o.width,height:o==null?void 0:o.height},children:v.jsx("div",{className:"flex items-center justify-end w-full text-xs",children:v.jsx("div",{className:"flex items-center justify-center px-3 py-1 border-b-2 border-l-2 text-accent-foreground bg-accent border-accent",style:{maxHeight:(o==null?void 0:o.height)&&o.height-4,fontSize:o!=null&&o.height&&o.height<=16?o.height-4:void 0},children:"Edit"})})})}function pie(e){const[t,n]=m.useState(),[r,o]=m.useState(),[i,s]=m.useState();function a(l){if(l){const c=[];l.dataset.valPath&&c.push(l.dataset.valPath);for(const u of Array.from(l.querySelectorAll("*")))if(u instanceof HTMLElement){const d=u.dataset.valPath;d&&c.push(d)}c.length>0&&(n(l),o(c.join(",")),s(l.getBoundingClientRect()))}}return m.useEffect(()=>{if(e==="hover"||e==="window"){const l=c=>{a(c.target)};return document.addEventListener("mouseover",l),()=>{n(void 0),o(void 0),document.removeEventListener("mouseover",l)}}},[e]),m.useEffect(()=>{const l=()=>{t&&s(t.getBoundingClientRect())},c=new ResizeObserver(()=>{t&&s(t.getBoundingClientRect())}),u=document.getElementById("val-shadow-root");return t&&u&&c.observe(u),document.addEventListener("scroll",l,{passive:!0}),()=>{document.removeEventListener("scroll",l),c.disconnect()}},[t]),[{path:r,element:t,rect:i},l=>{var c;n(l==null?void 0:l.element),o(l==null?void 0:l.path),s((c=l==null?void 0:l.element)==null?void 0:c.getBoundingClientRect())}]}const tp="val-edit-mode";function hie(){const[e,t]=m.useState("off");m.useEffect(()=>{try{const r=localStorage.getItem(tp);r==="off"||r==="hover"||r==="window"||r==="full"?t(r==="window"?"hover":r):(localStorage.removeItem(tp),t("off"))}catch{t("off")}},[]);const n=m.useCallback(r=>{typeof r=="function"?t(o=>{const i=r(o);return localStorage.setItem(tp,i),i}):(localStorage.setItem(tp,r),t(r))},[]);return[e,n]}function mie(){const e="/api/val",t=new Qx(e),n=new x1(t);return v.jsx(Lb,{fallbackRender:jb,children:v.jsxs(Pre,{children:[v.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),v.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),v.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap",rel:"stylesheet"}),v.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;1,100;1,300;1,400;1,500;1,700&family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap",rel:"stylesheet"}),v.jsx("style",{children:`
214
218
  #val-overlay-container {
215
219
  visibility: hidden;
216
220
  }