@meituan-nocode/vite-plugin-nocode-compiler 0.3.1-beta.0 → 0.3.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +12 -10
- package/dist/index.d.cts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +13 -11
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -178,7 +178,7 @@ function readJsonBody(req) {
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
// package.json
|
|
181
|
-
var version = "0.3.1-beta.
|
|
181
|
+
var version = "0.3.1-beta.2";
|
|
182
182
|
|
|
183
183
|
// src/design-mode/types.ts
|
|
184
184
|
var SANDBOX_SCRIPT_PATH = "/sandbox-script.js";
|
|
@@ -186,7 +186,6 @@ var VIRTUAL_CODE_API_PATH = "/api/virtual-code";
|
|
|
186
186
|
var DEFAULT_DESIGN_MODE_OPTIONS = {
|
|
187
187
|
enableVirtualCode: true,
|
|
188
188
|
virtualCodeApiPath: VIRTUAL_CODE_API_PATH,
|
|
189
|
-
enableSandboxScript: true,
|
|
190
189
|
verbose: false,
|
|
191
190
|
exclude: [/node_modules/],
|
|
192
191
|
include: [/\.[jt]sx?$/]
|
|
@@ -299,7 +298,7 @@ function createVirtualCodeMiddleware(server, options, projectRoot) {
|
|
|
299
298
|
|
|
300
299
|
// src/design-mode/sandbox-script.ts
|
|
301
300
|
function getSandboxScriptContent() {
|
|
302
|
-
return '(()=>{var e={572(e,t,n){var r=n(736).Symbol;e.exports=r},561(e,t,n){var r=n(572),o=n(504),i=n(567),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?o(e):i(e)}},605(e,t,n){var r=n(327),o=/^\\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},433(e,t,n){var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},504(e,t,n){var r=n(572),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var o=s.call(e);return r&&(t?e[a]=n:delete e[a]),o}},567(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},736(e,t,n){var r=n(433),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();e.exports=i},327(e){var t=/\\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},702(e,t,n){var r=n(230),o=n(381),i=n(569),s=Math.max,a=Math.min;e.exports=function(e,t,n){var c,u,l,d,f,h,p=0,g=!1,m=!1,v=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){var n=c,r=u;return c=u=void 0,p=t,d=e.apply(r,n)}function w(e){var n=e-h;return void 0===h||n>=t||n<0||m&&e-p>=l}function b(){var e=o();if(w(e))return E(e);f=setTimeout(b,function(e){var n=t-(e-h);return m?a(n,l-(e-p)):n}(e))}function E(e){return f=void 0,v&&c?y(e):(c=u=void 0,d)}function N(){var e=o(),n=w(e);if(c=arguments,u=this,h=e,n){if(void 0===f)return function(e){return p=e,f=setTimeout(b,t),g?y(e):d}(h);if(m)return clearTimeout(f),f=setTimeout(b,t),y(h)}return void 0===f&&(f=setTimeout(b,t)),d}return t=i(t)||0,r(n)&&(g=!!n.leading,l=(m="maxWait"in n)?s(i(n.maxWait)||0,t):l,v="trailing"in n?!!n.trailing:v),N.cancel=function(){void 0!==f&&clearTimeout(f),p=0,c=h=u=f=void 0},N.flush=function(){return void 0===f?d:E(o())},N}},230(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},470(e){e.exports=function(e){return null!=e&&"object"==typeof e}},89(e,t,n){var r=n(561),o=n(470);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},381(e,t,n){var r=n(736);e.exports=function(){return r.Date.now()}},569(e,t,n){var r=n(605),o=n(230),i=n(89),s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=a.test(e);return n||c.test(e)?u(e.slice(2),n?2:8):s.test(e)?NaN:+e}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=n(702),t=n.n(e),r=class extends Error{code;constructor(e,t){super(t),this.name="PenpalError",this.code=e}},o=e=>({name:e.name,message:e.message,stack:e.stack,penpalCode:e instanceof r?e.code:void 0}),i=Symbol("Reply"),s=class{value;transferables;#e=i;constructor(e,t){this.value=e,this.transferables=t?.transferables}},a="penpal",c=e=>"object"==typeof e&&null!==e,u=e=>"function"==typeof e,l=e=>"SYN"===e.type,d=e=>"ACK1"===e.type,f=e=>"ACK2"===e.type,h=e=>"CALL"===e.type,p=e=>"REPLY"===e.type,g=(e,t=[])=>{const n=[];for(const r of Object.keys(e)){const o=e[r];u(o)?n.push([...t,r]):c(o)&&n.push(...g(o,[...t,r]))}return n},m=e=>e.join("."),v=(e,t,n)=>({namespace:a,channel:e,type:"REPLY",callId:t,isError:!0,...n instanceof Error?{value:o(n),isSerializedErrorInstance:!0}:{value:n}}),y=crypto.randomUUID?.bind(crypto)??(()=>new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")),w=Symbol("CallOptions"),b=class{transferables;timeout;#e=w;constructor(e){this.transferables=e?.transferables,this.timeout=e?.timeout}},E=new Set(["apply","call","bind"]),N=(e,t,n=[])=>new Proxy(n.length?()=>{}:Object.create(null),{get(r,o){if("then"!==o)return n.length&&E.has(o)?Reflect.get(r,o):N(e,t,[...n,o])},apply:(t,r,o)=>e(n,o)}),C=e=>new r("CONNECTION_DESTROYED",`Method call ${m(e)}() failed due to destroyed connection`),S=class extends Error{constructor(e){super(`You\'ve hit a bug in Penpal. Please file an issue with the following information: ${e}`)}},x="deprecated-penpal",O=e=>e.join("."),P=e=>new S(`Unexpected message to translate: ${JSON.stringify(e)}`),T=({messenger:e,methods:t,timeout:n,channel:o,log:i})=>{const w=y();let E;const S=[];let O=!1;const P=g(t),{promise:T,resolve:M,reject:I}=(()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}})(),A=void 0!==n?setTimeout(()=>{I(new r("CONNECTION_TIMEOUT",`Connection timed out after ${n}ms`))},n):void 0,R=()=>{for(const e of S)e()},L=()=>{if(O)return;S.push(((e,t,n,o)=>{let i=!1;const l=async l=>{if(i)return;if(!h(l))return;o?.(`Received ${m(l.methodPath)}() call`,l);const{methodPath:d,args:f,id:p}=l;let g,y;try{const e=((e,t)=>{const n=e.reduce((e,t)=>c(e)?e[t]:void 0,t);return u(n)?n:void 0})(d,t);if(!e)throw new r("METHOD_NOT_FOUND",`Method \\`${m(d)}\\` is not found.`);let o=await e(...f);o instanceof s&&(y=o.transferables,o=await o.value),g={namespace:a,channel:n,type:"REPLY",callId:p,value:o}}catch(e){g=v(n,p,e)}if(!i)try{o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g,y)}catch(t){throw"DataCloneError"===t.name&&(g=v(n,p,t),o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g)),t}};return e.addMessageHandler(l),()=>{i=!0,e.removeMessageHandler(l)}})(e,t,o,i));const{remoteProxy:n,destroy:l}=((e,t,n)=>{let o=!1;const i=new Map,s=e=>{if(!p(e))return;const{callId:t,value:o,isError:s,isSerializedErrorInstance:a}=e,c=i.get(t);c&&(i.delete(t),n?.(`Received ${m(c.methodPath)}() call`,e),s?c.reject(a?(({name:e,message:t,stack:n,penpalCode:o})=>{const i=o?new r(o,t):new Error(t);return i.name=e,i.stack=n,i})(o):o):c.resolve(o))};return e.addMessageHandler(s),{remoteProxy:N((s,c)=>{if(o)throw C(s);const u=y(),l=c[c.length-1],d=l instanceof b,{timeout:f,transferables:h}=d?l:{},p=d?c.slice(0,-1):c;return new Promise((o,c)=>{const l=void 0!==f?window.setTimeout(()=>{i.delete(u),c(new r("METHOD_CALL_TIMEOUT",`Method call ${m(s)}() timed out after ${f}ms`))},f):void 0;i.set(u,{methodPath:s,resolve:o,reject:c,timeoutId:l});try{const r={namespace:a,channel:t,type:"CALL",id:u,methodPath:s,args:p};n?.(`Sending ${m(s)}() call`,r),e.sendMessage(r,h)}catch(e){c(new r("TRANSMISSION_FAILED",e.message))}})},n),destroy:()=>{o=!0,e.removeMessageHandler(s);for(const{methodPath:e,reject:t,timeoutId:n}of i.values())clearTimeout(n),t(C(e));i.clear()}}})(e,o,i);S.push(l),clearTimeout(A),O=!0,M({remoteProxy:n,destroy:R})},D=()=>{const t={namespace:a,type:"SYN",channel:o,participantId:w};i?.("Sending handshake SYN",t);try{e.sendMessage(t)}catch(e){I(new r("TRANSMISSION_FAILED",e.message))}},F=t=>{l(t)&&(t=>{if(i?.("Received handshake SYN",t),t.participantId===E&&E!==x)return;if(E=t.participantId,D(),!(w>E||E===x))return;const n={namespace:a,channel:o,type:"ACK1",methodPaths:P};i?.("Sending handshake ACK1",n);try{e.sendMessage(n)}catch(e){return void I(new r("TRANSMISSION_FAILED",e.message))}})(t),d(t)&&(t=>{i?.("Received handshake ACK1",t);const n={namespace:a,channel:o,type:"ACK2"};i?.("Sending handshake ACK2",n);try{e.sendMessage(n)}catch(e){return void I(new r("TRANSMISSION_FAILED",e.message))}L()})(t),f(t)&&(e=>{i?.("Received handshake ACK2",e),L()})(t)};return e.addMessageHandler(F),S.push(()=>e.removeMessageHandler(F)),D(),T},M=new WeakSet,I=class{#t;#n;#r;#o;#i;#s=new Set;#a;#c=!1;constructor({remoteWindow:e,allowedOrigins:t}){if(!e)throw new r("INVALID_ARGUMENT","remoteWindow must be defined");this.#t=e,this.#n=t?.length?t:[window.origin]}initialize=({log:e,validateReceivedMessage:t})=>{this.#r=e,this.#o=t,window.addEventListener("message",this.#u)};sendMessage=(e,t)=>{if(l(e)){const n=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:n,transfer:t})}if(d(e)||this.#c){const n=this.#c?(e=>{if(d(e))return{penpal:"synAck",methodNames:e.methodPaths.map(O)};if(h(e))return{penpal:"call",id:e.id,methodName:O(e.methodPath),args:e.args};if(p(e))return e.isError?{penpal:"reply",id:e.callId,resolution:"rejected",...e.isSerializedErrorInstance?{returnValue:e.value,returnValueIsError:!0}:{returnValue:e.value}}:{penpal:"reply",id:e.callId,resolution:"fulfilled",returnValue:e.value};throw P(e)})(e):e,r=this.#l(e);return void this.#t.postMessage(n,{targetOrigin:r,transfer:t})}if(f(e)){const{port1:n,port2:r}=new MessageChannel;this.#a=n,n.addEventListener("message",this.#d),n.start();const o=[r,...t||[]],i=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:i,transfer:o})}if(!this.#a)throw new S("Port is undefined");this.#a.postMessage(e,{transfer:t})};addMessageHandler=e=>{this.#s.add(e)};removeMessageHandler=e=>{this.#s.delete(e)};destroy=()=>{window.removeEventListener("message",this.#u),this.#f(),this.#s.clear()};#h=e=>this.#n.some(t=>t instanceof RegExp?t.test(e):t===e||"*"===t);#l=e=>{if(l(e))return"*";if(!this.#i)throw new S("Concrete remote origin not set");return"null"===this.#i&&this.#n.includes("*")?"*":this.#i};#f=()=>{this.#a?.removeEventListener("message",this.#d),this.#a?.close(),this.#a=void 0};#u=({source:e,origin:t,ports:n,data:r})=>{if(e===this.#t&&((e=>c(e)&&"penpal"in e)(r)&&(this.#r?.("Please upgrade the child window to the latest version of Penpal."),this.#c=!0,r=(e=>{if("syn"===e.penpal)return{namespace:a,channel:void 0,type:"SYN",participantId:x};if("ack"===e.penpal)return{namespace:a,channel:void 0,type:"ACK2"};if("call"===e.penpal)return{namespace:a,channel:void 0,type:"CALL",id:e.id,methodPath:(t=e.methodName,t.split(".")),args:e.args};var t;if("reply"===e.penpal)return"fulfilled"===e.resolution?{namespace:a,channel:void 0,type:"REPLY",callId:e.id,value:e.returnValue}:{namespace:a,channel:void 0,type:"REPLY",callId:e.id,isError:!0,...e.returnValueIsError?{value:e.returnValue,isSerializedErrorInstance:!0}:{value:e.returnValue}};throw P(e)})(r)),this.#o?.(r)))if(this.#h(t)){if(l(r)&&(this.#f(),this.#i=t),f(r)&&!this.#c){if(this.#a=n[0],!this.#a)throw new S("No port received on ACK2");this.#a.addEventListener("message",this.#d),this.#a.start()}for(const e of this.#s)e(r)}else this.#r?.(`Received a message from origin \\`${t}\\` which did not match allowed origins \\`[${this.#n.join(", ")}]\\``)};#d=({data:e})=>{if(this.#o?.(e))for(const t of this.#s)t(e)}},A=document,R=window,L=Array.prototype,D=L.filter,F=L.indexOf,j=L.map,$=L.push,_=L.reverse,k=L.slice,W=L.splice,z=/^#[\\w-]*$/,U=/^\\.[\\w-]*$/,V=/<.+>/,H=/^\\w+$/;function B(e,t){return void 0===t&&(t=A),U.test(e)?t.getElementsByClassName(e.slice(1)):H.test(e)?t.getElementsByTagName(e):t.querySelectorAll(e)}function Y(e,t){if(void 0===t&&(t=A),e){if(e.__cash)return e;var n=e;if(ne(e)){if(t.__cash&&(t=t[0]),!(n=z.test(e)?t.getElementById(e.slice(1)):V.test(e)?ke(e):B(e,t)))return}else if(te(e))return this.ready(e);(n.nodeType||n===R)&&(n=[n]),this.length=n.length;for(var r=0,o=this.length;r<o;r++)this[r]=n[r]}}function K(e,t){return new Y(e,t)}var q=K.fn=K.prototype=Y.prototype={constructor:K,__cash:!0,length:0,splice:W};q.get=function(e){return void 0===e?k.call(this):this[e<0?e+this.length:e]},q.eq=function(e){return K(this.get(e))},q.first=function(){return this.eq(0)},q.last=function(){return this.eq(-1)},q.map=function(e){return K(j.call(this,function(t,n){return e.call(t,n,t)}))},q.slice=function(){return K(k.apply(this,arguments))};var G=/(?:^\\w|[A-Z]|\\b\\w)/g,X=/[\\s-_]+/g;function J(e){return e.replace(G,function(e,t){return e[t?"toUpperCase":"toLowerCase"]()}).replace(X,"")}function Z(e,t){for(var n=0,r=e.length;n<r&&!1!==t.call(e[n],e[n],n,e);n++);}K.camelCase=J,K.each=Z,q.each=function(e){return Z(this,function(t,n){return e.call(t,n,t)}),this},q.removeProp=function(e){return this.each(function(t,n){delete n[e]})},K.extend=q.extend=function(e){void 0===e&&(e=this);for(var t=arguments,n=t.length,r=n<2?0:1;r<n;r++)for(var o in t[r])e[o]=t[r][o];return e};var Q=1;function ee(e,t){var n=e&&(e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector);return!!n&&n.call(e,t)}function te(e){return"function"==typeof e}function ne(e){return"string"==typeof e}function re(e){return!isNaN(parseFloat(e))&&isFinite(e)}K.guid=Q,K.matches=ee,K.isFunction=te,K.isString=ne,K.isNumeric=re;var oe=Array.isArray;function ie(e){return ne(e)?function(t,n){return ee(n,e)}:e.__cash?function(t,n){return e.is(n)}:function(e,t,n){return t===n}}K.isArray=oe,q.prop=function(e,t){if(e){if(ne(e))return arguments.length<2?this[0]&&this[0][e]:this.each(function(n,r){r[e]=t});for(var n in e)this.prop(n,e[n]);return this}},q.filter=function(e){if(!e)return K();var t=te(e)?e:ie(e);return K(D.call(this,function(n,r){return t.call(n,r,n,e)}))};var se=/\\S+/g;function ae(e){return ne(e)&&e.match(se)||[]}function ce(e){return e.filter(function(e,t,n){return n.indexOf(e)===t})}function ue(e,t,n){if(1===e.nodeType){var r=R.getComputedStyle(e,null);return t?n?r.getPropertyValue(t):r[t]:r}}function le(e,t){return parseInt(ue(e,t),10)||0}q.hasClass=function(e){var t=ae(e),n=!1;return t.length&&this.each(function(e,r){return!(n=r.classList.contains(t[0]))}),n},q.removeAttr=function(e){var t=ae(e);return t.length?this.each(function(e,n){Z(t,function(e){n.removeAttribute(e)})}):this},q.attr=function(e,t){if(e){if(ne(e)){if(arguments.length<2){if(!this[0])return;var n=this[0].getAttribute(e);return null===n?void 0:n}return null===t?this.removeAttr(e):this.each(function(n,r){r.setAttribute(e,t)})}for(var r in e)this.attr(r,e[r]);return this}},q.toggleClass=function(e,t){var n=ae(e),r=void 0!==t;return n.length?this.each(function(e,o){Z(n,function(e){r?t?o.classList.add(e):o.classList.remove(e):o.classList.toggle(e)})}):this},q.addClass=function(e){return this.toggleClass(e,!0)},q.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},K.unique=ce,q.add=function(e,t){return K(ce(this.get().concat(K(e,t).get())))};var de=/^--/;function fe(e){return de.test(e)}var he={},pe=A.createElement("div").style,ge=["webkit","moz","ms","o"];function me(e,t){if(void 0===t&&(t=fe(e)),t)return e;if(!he[e]){var n=J(e),r=""+n.charAt(0).toUpperCase()+n.slice(1);Z((n+" "+ge.join(r+" ")+r).split(" "),function(t){if(t in pe)return he[e]=t,!1})}return he[e]}K.prefixedProp=me;var ve={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function ye(e,t,n){return void 0===n&&(n=fe(e)),n||ve[e]||!re(t)?t:t+"px"}q.css=function(e,t){if(ne(e)){var n=fe(e);return e=me(e,n),arguments.length<2?this[0]&&ue(this[0],e,n):e?(t=ye(e,t,n),this.each(function(r,o){1===o.nodeType&&(n?o.style.setProperty(e,t):o.style[e]=t)})):this}for(var r in e)this.css(r,e[r]);return this};var we="__cashData",be=/^data-(.*)/;function Ee(e){return e[we]=e[we]||{}}function Ne(e,t){var n=Ee(e);if(t){if(!(t in n)){var r=e.dataset?e.dataset[t]||e.dataset[J(t)]:K(e).attr("data-"+t);if(void 0!==r){try{r=JSON.parse(r)}catch(e){}n[t]=r}}return n[t]}return n}function Ce(e,t){return le(e,"border"+(t?"Left":"Top")+"Width")+le(e,"padding"+(t?"Left":"Top"))+le(e,"padding"+(t?"Right":"Bottom"))+le(e,"border"+(t?"Right":"Bottom")+"Width")}function Se(e,t){for(var n=0,r=t.length;n<r;n++)if(e.indexOf(t[n])<0)return!1;return!0}function xe(e,t,n){Z(e[n],function(e){e[0];var r=e[1];t.removeEventListener(n,r)}),delete e[n]}K.hasData=function(e){return we in e},q.data=function(e,t){var n=this;if(!e){if(!this[0])return;return Z(this[0].attributes,function(e){var t=e.name.match(be);t&&n.data(t[1])}),Ne(this[0])}if(ne(e))return void 0===t?this[0]&&Ne(this[0],e):this.each(function(n,r){return function(e,t,n){Ee(e)[t]=n}(r,e,t)});for(var r in e)this.data(r,e[r]);return this},q.removeData=function(e){return this.each(function(t,n){return function(e,t){void 0===t?delete e[we]:delete Ee(e)[t]}(n,e)})},Z(["Width","Height"],function(e){q["inner"+e]=function(){if(this[0])return this[0]===R?R["inner"+e]:this[0]["client"+e]}}),Z(["width","height"],function(e,t){q[e]=function(n){return this[0]?arguments.length?(n=parseInt(n,10),this.each(function(r,o){if(1===o.nodeType){var i=ue(o,"boxSizing");o.style[e]=ye(e,n+("border-box"===i?Ce(o,!t):0))}})):this[0]===R?this[0][J("outer-"+e)]:this[0].getBoundingClientRect()[e]-Ce(this[0],!t):void 0===n?void 0:this}}),Z(["Width","Height"],function(e,t){q["outer"+e]=function(n){if(this[0])return this[0]===R?R["outer"+e]:this[0]["offset"+e]+(n?le(this[0],"margin"+(t?"Top":"Left"))+le(this[0],"margin"+(t?"Bottom":"Right")):0)}});var Oe="__cashEvents";function Pe(e){return e[Oe]=e[Oe]||{}}function Te(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Me(e,t,n,r){var o=Pe(e);if(t){var i=o[t];if(!i)return;r&&(r.guid=r.guid||Q++),o[t]=i.filter(function(o){var i=o[0],s=o[1];if(r&&s.guid!==r.guid||!Se(i,n))return!0;e.removeEventListener(t,s)})}else if(n&&n.length)for(t in o)Me(e,t,n,r);else for(t in o)xe(o,e,t)}q.off=function(e,t){var n=this;return void 0===e?this.each(function(e,t){return Me(t)}):Z(ae(e),function(e){var r=Te(e),o=r[0],i=r[1];n.each(function(e,n){return Me(n,o,i,t)})}),this},q.on=function(e,t,n,r){var o=this;if(!ne(e)){for(var i in e)this.on(i,t,e[i]);return this}return te(t)&&(n=t,t=!1),Z(ae(e),function(e){var i=Te(e),s=i[0],a=i[1];o.each(function(e,o){var i=function e(i){if(!i.namespace||Se(a,i.namespace.split("."))){var c=o;if(t){for(var u=i.target;!ee(u,t);){if(u===o)return;if(!(u=u.parentNode))return}c=u}i.namespace=i.namespace||"";var l=n.call(c,i,i.data);r&&Me(o,s,a,e),!1===l&&(i.preventDefault(),i.stopPropagation())}};i.guid=n.guid=n.guid||Q++,function(e,t,n,r){r.guid=r.guid||Q++;var o=Pe(e);o[t]=o[t]||[],o[t].push([n,r]),e.addEventListener(t,r)}(o,s,a,i)})}),this},q.one=function(e,t,n){return this.on(e,t,n,!0)},q.ready=function(e){var t=function(){return e(K)};return"loading"!==A.readyState?setTimeout(t):A.addEventListener("DOMContentLoaded",t),this},q.trigger=function(e,t){var n=e;if(ne(e)){var r=Te(e),o=r[0],i=r[1];(n=A.createEvent("HTMLEvents")).initEvent(o,!0,!0),n.namespace=i.join(".")}return n.data=t,this.each(function(e,t){t.dispatchEvent(n)})};var Ie=/select-one/i,Ae=/select-multiple/i;function Re(e){var t=e.type;return Ie.test(t)?function(e){return e.selectedIndex<0?null:e.options[e.selectedIndex].value}(e):Ae.test(t)?function(e){var t=[];return Z(e.options,function(e){!e.selected||e.disabled||e.parentNode.disabled||t.push(e.value)}),t}(e):e.value}var Le=/%20/g,De=/file|reset|submit|button|image/i,Fe=/radio|checkbox/i;q.serialize=function(){var e="";return this.each(function(t,n){Z(n.elements||[n],function(t){if(!t.disabled&&t.name&&"FIELDSET"!==t.tagName&&!De.test(t.type)&&(!Fe.test(t.type)||t.checked)){var n=Re(t);void 0!==n&&Z(oe(n)?n:[n],function(n){e+=function(e,t){return"&"+encodeURIComponent(e)+"="+encodeURIComponent(t).replace(Le,"+")}(t.name,n)})}})}),e.substr(1)},q.val=function(e){return void 0===e?this[0]&&Re(this[0]):this.each(function(t,n){var r=Ae.test(n.type),o=null===e?r?[]:"":e;r&&oe(o)?Z(n.options,function(e){e.selected=o.indexOf(e.value)>=0}):n.value=o})},q.clone=function(){return this.map(function(e,t){return t.cloneNode(!0)})},q.detach=function(){return this.each(function(e,t){t.parentNode&&t.parentNode.removeChild(t)})};var je,$e=/^\\s*<(\\w+)[^>]*>/,_e=/^\\s*<(\\w+)\\s*\\/?>(?:<\\/\\1>)?\\s*$/;function ke(e){if(function(){if(!je){var e=A.createElement("table"),t=A.createElement("tr");je={"*":A.createElement("div"),tr:A.createElement("tbody"),td:t,th:t,thead:e,tbody:e,tfoot:e}}}(),!ne(e))return[];if(_e.test(e))return[A.createElement(RegExp.$1)];var t=$e.test(e)&&RegExp.$1,n=je[t]||je["*"];return n.innerHTML=e,K(n.childNodes).detach().get()}function We(e,t,n){if(void 0!==t){var r=ne(t);!r&&t.length?Z(t,function(t){return We(e,t,n)}):Z(e,r?function(e){e.insertAdjacentHTML(n?"afterbegin":"beforeend",t)}:function(e,r){return function(e,t,n){n?e.insertBefore(t,e.childNodes[0]):e.appendChild(t)}(e,r?t.cloneNode(!0):t,n)})}}K.parseHTML=ke,q.empty=function(){var e=this[0];if(e)for(;e.firstChild;)e.removeChild(e.firstChild);return this},q.append=function(){var e=this;return Z(arguments,function(t){We(e,t)}),this},q.appendTo=function(e){return We(K(e),this),this},q.html=function(e){if(void 0===e)return this[0]&&this[0].innerHTML;var t=e.nodeType?e[0].outerHTML:e;return this.each(function(e,n){n.innerHTML=t})},q.insertAfter=function(e){var t=this;return K(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n.nextSibling)})}),this},q.after=function(){var e=this;return Z(_.apply(arguments),function(t){_.apply(K(t).slice()).insertAfter(e)}),this},q.insertBefore=function(e){var t=this;return K(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n)})}),this},q.before=function(){var e=this;return Z(arguments,function(t){K(t).insertBefore(e)}),this},q.prepend=function(){var e=this;return Z(arguments,function(t){We(e,t,!0)}),this},q.prependTo=function(e){return We(K(e),_.apply(this.slice()),!0),this},q.remove=function(){return this.detach().off()},q.replaceWith=function(e){var t=this;return this.each(function(n,r){var o=r.parentNode;if(o){var i=n?K(e).clone():K(e);if(!i[0])return t.remove(),!1;o.replaceChild(i[0],r),K(i[0]).after(i.slice(1))}})},q.replaceAll=function(e){return K(e).replaceWith(this),this},q.text=function(e){return void 0===e?this[0]?this[0].textContent:"":this.each(function(t,n){n.textContent=e})};var ze=A.documentElement;q.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+R.pageYOffset-ze.clientTop,left:t.left+R.pageXOffset-ze.clientLeft}}},q.offsetParent=function(){return K(this[0]&&this[0].offsetParent)},q.position=function(){var e=this[0];if(e)return{left:e.offsetLeft,top:e.offsetTop}},q.children=function(e){var t=[];return this.each(function(e,n){$.apply(t,n.children)}),t=K(ce(t)),e?t.filter(function(t,n){return ee(n,e)}):t},q.contents=function(){var e=[];return this.each(function(t,n){$.apply(e,"IFRAME"===n.tagName?[n.contentDocument]:n.childNodes)}),K(e.length&&ce(e))},q.find=function(e){for(var t=[],n=0,r=this.length;n<r;n++){var o=B(e,this[n]);o.length&&$.apply(t,o)}return K(t.length&&ce(t))},q.has=function(e){var t=ne(e)?function(t,n){return!!B(e,n).length}:function(t,n){return n.contains(e)};return this.filter(t)},q.is=function(e){if(!e||!this[0])return!1;var t=ie(e),n=!1;return this.each(function(r,o){return!(n=t(r,o,e))}),n},q.next=function(){return K(this[0]&&this[0].nextElementSibling)},q.not=function(e){if(!e||!this[0])return this;var t=ie(e);return this.filter(function(n,r){return!t(n,r,e)})},q.parent=function(){var e=[];return this.each(function(t,n){n&&n.parentNode&&e.push(n.parentNode)}),K(ce(e))},q.index=function(e){var t=e?K(e)[0]:this[0],n=e?this:K(t).parent().children();return F.call(n,t)},q.closest=function(e){return e&&this[0]?this.is(e)?this.filter(e):this.parent().closest(e):K()},q.parents=function(e){var t,n=[];return this.each(function(r,o){for(t=o;t&&t.parentNode&&t!==A.body.parentNode;)t=t.parentNode,(!e||e&&ee(t,e))&&n.push(t)}),K(ce(n))},q.prev=function(){return K(this[0]&&this[0].previousElementSibling)},q.siblings=function(){var e=this[0];return this.parent().children().filter(function(t,n){return n!==e})};const Ue=K,Ve=new class{getFiberNode(e){try{const t=Object.keys(e).find(e=>e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"));return t?e[t]:null}catch(e){return console.warn("[ReactFiberService] Error getting fiber node:",e),null}}getDebugOwner(e){const t=this.getFiberNode(e);return t?._debugOwner??null}getDebugSource(e){const t=this.getFiberNode(e);return t?._debugSource??null}getOwnerDebugSource(e){const t=this.getDebugOwner(e);return t?._debugSource??null}hasDirectSourceInfo(e){return!!e.getAttribute("data-nocode-id")||!!this.getDebugSource(e)}hasOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return!1;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n&&n.length>0}getOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return null;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n?n:null}isSelectableElement(e){if(this.hasDirectSourceInfo(e))return!0;const t=this.getFiberNode(e),n=this.getOwnerDebugSource(e);return!!(t?.return&&5!==t.return.tag&&this.hasOwnerNocodeId(e)&&n)}isComponent(e){if(!this.isSelectableElement(e))return!1;if(e.getAttribute("data-nocode-components-name"))return!0;if(this.getDebugSource(e))return!1;const t=this.getFiberNode(e);return!(!t?.return||5===t.return.tag)}getComponentName(e){const t=e.getAttribute("data-nocode-tag-name");if(t)return t;const n=this.getDebugOwner(e);if(n?.type){const e=n.type;if("function"==typeof e){const t=e.displayName||e.name||"Unknown";return this.normalizeComponentName(t)}if("string"==typeof e)return e}return e.tagName.toLowerCase()}normalizeComponentName(e){return e.replace(/\\d+$/,"")}getComponentProps(e){if(!this.isComponent(e))return;const t=this.getDebugOwner(e);return t?.memoizedProps?this.sanitizeProps(t.memoizedProps):void 0}sanitizeProps(e){const t={};for(const[n,r]of Object.entries(e)){if("children"===n||n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}sanitizeValue(e){if(null===e)return null;if(void 0===e)return;if("function"==typeof e)return;if("symbol"==typeof e)return;if("object"!=typeof e)return e;if("$$typeof"in e)return;if(e instanceof Node)return;if(Array.isArray(e)){const t=[];for(const n of e){const e=this.sanitizeValue(n);void 0!==e&&t.push(e)}return t}const t={};for(const[n,r]of Object.entries(e)){if(n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}buildComponentInfo(e,t){const n=this.isComponent(e),r={isComponent:n,componentType:n?"component":"host",name:n?this.getComponentName(e):e.tagName.toLowerCase()};if(n){const n={...t,...this.getComponentProps(e)??{}},{cleanProps:o,extractedProps:i}=this.extractSpecialProps(n);i.componentsName&&(r.componentsName=i.componentsName),i.componentsVersion&&(r.componentsVersion=i.componentsVersion),r.props=o}return r}extractSpecialProps(e){const t={},n={};for(const[r,o]of Object.entries(e))"componentsName"===r&&"string"==typeof o?n.componentsName=o:"componentsVersion"===r&&"string"==typeof o?n.componentsVersion=o:t[r]=o;return{cleanProps:t,extractedProps:n}}};function He(e){const t={},n=e.attributes;for(let e=0;e<n.length;e++){const r=n[e];r.name.startsWith("data-nocode-")&&(t[r.name.replace("data-nocode-","").replace(/-([a-z])/g,(e,t)=>t.toUpperCase())]=r.value)}return t}const Be="data-dnd",Ye=`[${Be}]`;function Ke(e){return document.querySelector(`[${Be}="${e}"]`)}const qe=(e,t)=>{const n=e.getBoundingClientRect(),{x:r,y:o}=((e,t)=>{let n=e.x,r=e.y;if(t){const e=t.getBoundingClientRect();n-=e.left,r-=e.top}return{x:n,y:r}})({x:n.left,y:n.top},t);return{width:e.offsetWidth,height:e.offsetHeight,top:o,left:r}},Ge=(e,t)=>{const n=qe(e,t),r=function(e){return e.dataset}(e),o=Xe(e),i=Je(e),s=(e=>{const t=window.getComputedStyle(e);return{display:t.display,flexDirection:t.flexDirection,flexWrap:t.flexWrap,position:t.position}})(e),a=r.dnd||"",c=function(e){if(!e)return{};const t=e.split(":");if(t.length>=3){const n=t.pop(),r=t.pop(),o=t.join(":");return{id:e,filename:decodeURIComponent(o),component:r,codeId:n}}return 2===t.length?{id:e,component:t[0],codeId:t[1]}:{id:e}}(a),u=He(e),l=function(e){const t=He(e);return Ve.buildComponentInfo(e,t)}(e),d=(e=>{const t=e.querySelectorAll(`:scope > ${Ye}`);if(!t.length)return[];const n=[];return t.forEach(e=>{const t=e;n.push(qe(t))}),n})(e);return{id:a,codeId:c.codeId,name:c.component||e.tagName.toLowerCase(),filename:c.filename,bounding:n,display:o,computedStyle:s,text:i,nocodeData:u,componentInfo:l,childrenBoundings:d.length>0?d:void 0}},Xe=e=>Ue(e).css("display"),Je=e=>{const t=[];return e.childNodes.forEach(e=>{if(e.nodeType===Node.TEXT_NODE){const n=e.textContent?.trim()||"";n&&t.push(n)}}),t.join(" ")};function Ze(e){const t=["div","p","section","article","main","header","footer","nav","h1","h2","h3","h4","h5","h6","span","a","button","i","input","textarea","select","label","form","ul","ol","li","table","thead","tbody","tr","td","th","img","video","audio","canvas","svg"];try{const n=e.tagName.toLowerCase();if(!t.includes(n))return!1;const r=window.getComputedStyle(e);if("none"===r.display||"hidden"===r.visibility||"0"===r.opacity)return!1;const o=e.getBoundingClientRect();return!("inline"!==r.display&&"inline-block"!==r.display&&(0===o.width||0===o.height))}catch(e){return console.warn("Element validation failed:",e),!1}}function Qe(e,t=20){let n=e,r=0;for(;n&&r<t;){if(n.getAttribute(Be))return n;n=n.parentElement,r++}return null}function et(e){const t=window.getComputedStyle(e),n={};for(let e=0;e<t.length;e++){const r=t[e];n[r]=t.getPropertyValue(r)}return n}function tt(e){return(...t)=>{try{const n=e(...t);return n&&"function"==typeof n.then?n.catch(n=>(console.error(`Async error in ${e.name}:`,n),console.error("Error stack:",n.stack),console.error("Function arguments:",t),null)):n}catch(n){return console.error(`Sync error in ${e.name}:`,n),n instanceof Error&&console.error("Error stack:",n.stack),console.error("Function arguments:",t),null}}}const nt={getDraggableParentsData:(e,t)=>{const n=function(e,t){const n=((e,t)=>{const n=document.elementFromPoint(e,t);if(!n)return null;const r=n=>{if(n?.shadowRoot){const o=n.shadowRoot.elementFromPoint(e,t);return o===n?n:o?.shadowRoot?r(o):o||n}return n};return r(n)})(e,t);if(!n)return null;let r=n;if(!Ze(r)){let e=r.parentElement,t=0;const n=20;for(;e&&t<n;){if(Ze(e)){r=e;break}e=e.parentElement,t++}if(!Ze(r))return null}const o=Qe(r);return o&&Ze(o)?o:null}(e.x,e.y);if(!n)return;const r=(e=>{const t=Ue(e).closest(Ye).get(0),n=Ue(e).parents(Ye).get();return n[0]!==t&&n.unshift(t),n})(n);if(r.length){if(t){const e=r.map(e=>Ge(e));return{...e[0],computedStyle:et(n),parents:e.slice(1)}}return{...Ge(r[0]),computedStyle:et(r[0])}}},getElementDataById:e=>{const t=Ke(e);if(t)return{...Ge(t),computedStyle:et(t)};console.warn("[getElementDataById] Element not found for domId:",e)},getEditableTextElementAtPosition:e=>{const t=function(e,t){if(document.caretPositionFromPoint){const n=document.caretPositionFromPoint(e,t);return n?.offsetNode??null}if(document.caretRangeFromPoint){const n=document.caretRangeFromPoint(e,t);return n?.startContainer??null}return document.elementFromPoint(e,t)}(e.x,e.y);if(!t)return void console.log("[getEditableTextElementAtPosition] No node at point:",e);if(t.nodeType!==Node.TEXT_NODE)return void console.log("[getEditableTextElementAtPosition] Not a text node:",t.nodeType);const n=t.textContent?.trim();if(!n)return void console.log("[getEditableTextElementAtPosition] Empty text node");const r=t.parentElement;if(!r)return void console.log("[getEditableTextElementAtPosition] No parent element");const o=Qe(r);if(o){if(function(e){const t=e.childNodes;let n=!1;for(let e=0;e<t.length;e++){const r=t[e];if(r.nodeType===Node.ELEMENT_NODE)return!1;if(r.nodeType===Node.TEXT_NODE){const e=r.textContent?.trim();e&&(n=!0)}}return n}(o))return console.log("[getEditableTextElementAtPosition] Found editable text element:",o.tagName,o.textContent),{...Ge(o),computedStyle:et(o)};console.log("[getEditableTextElementAtPosition] Element has child elements, cannot edit directly:",o.tagName)}else console.log("[getEditableTextElementAtPosition] No marked element found")},updateElementTextContent:(e,t)=>{const n=Ke(e);return n?(n.textContent=t,!0):(console.warn("[updateElementTextContent] Element not found:",e),!1)},scrollToElement:e=>{const t=Ke(e);return t?(t.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),!0):(console.warn("[scrollToElement] Element not found for domId:",e),!1)}},rt=Object.fromEntries(Object.entries(nt).map(([e,t])=>[e,tt(t)])),ot="nocode-design-mode";let it=null,st=!1,at=null;const ct=t()(()=>{it?.onWindowMutated&&(console.log(`${ot} - Notifying parent of DOM mutation`),it.onWindowMutated({added:{},removed:{}}))},100),ut=async()=>{if(st||it)return it;st=!0,console.log(`${ot} - Creating penpal connection`);const e=(({messenger:e,methods:t={},timeout:n,channel:o,log:i})=>{if(!e)throw new r("INVALID_ARGUMENT","messenger must be defined");if(M.has(e))throw new r("INVALID_ARGUMENT","A messenger can only be used for a single connection");M.add(e);const s=[e.destroy],u=(e=>{let t,n=!1;return(...r)=>(n||(n=!0,t=e(...r)),t)})(t=>{if(t){const t={namespace:a,channel:o,type:"DESTROY"};try{e.sendMessage(t)}catch(e){}}for(const e of s)e();i?.("Connection destroyed")}),l=e=>(e=>c(e)&&e.namespace===a)(e)&&e.channel===o;return{promise:(async()=>{try{e.initialize({log:i,validateReceivedMessage:l}),e.addMessageHandler(e=>{(e=>"DESTROY"===e.type)(e)&&u(!1)});const{remoteProxy:r,destroy:a}=await T({messenger:e,methods:t,timeout:n,channel:o,log:i});return s.push(a),r}catch(e){throw u(!0),e}})(),destroy:()=>{u(!0)}}})({messenger:new I({remoteWindow:window===window.top?(console.warn(`${ot} - Not in an iframe, using window.parent as fallback`),window.parent):window.parent===window.top?window.parent:window.top?(console.log(`${ot} - Using window.top for nested iframe scenario`),window.top):window.parent,allowedOrigins:["*"]}),methods:rt});return e.promise.then(e=>{if(!e)return console.error(`${ot} - Failed to setup penpal connection: child is null`),void lt();it=e,console.log(`${ot} - Penpal connection set`),(()=>{if(at)return;at=new MutationObserver(e=>{e.some(e=>{const t=e.target;return"SCRIPT"!==t.tagName&&"STYLE"!==t.tagName&&("attributes"!==e.type||"style"===e.attributeName||"class"===e.attributeName)})&&ct()});const e=()=>{document.body&&at&&(at.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"],characterData:!0}),console.log(`${ot} - MutationObserver started`))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()})()}).finally(()=>{st=!1}),e.promise.catch(e=>{console.error(`${ot} - Failed to setup penpal connection:`,e),lt()}),it},lt=t()(()=>{st||(console.log(`${ot} - Reconnecting to penpal parent`),it=null,ut())},1e3);ut()})()})();';
|
|
301
|
+
return '(()=>{var e={572(e,t,n){var r=n(736).Symbol;e.exports=r},561(e,t,n){var r=n(572),o=n(504),i=n(567),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?o(e):i(e)}},605(e,t,n){var r=n(327),o=/^\\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},433(e,t,n){var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},504(e,t,n){var r=n(572),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var o=s.call(e);return r&&(t?e[a]=n:delete e[a]),o}},567(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},736(e,t,n){var r=n(433),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();e.exports=i},327(e){var t=/\\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},702(e,t,n){var r=n(230),o=n(381),i=n(569),s=Math.max,a=Math.min;e.exports=function(e,t,n){var c,u,l,d,f,h,p=0,g=!1,m=!1,v=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){var n=c,r=u;return c=u=void 0,p=t,d=e.apply(r,n)}function b(e){var n=e-h;return void 0===h||n>=t||n<0||m&&e-p>=l}function w(){var e=o();if(b(e))return E(e);f=setTimeout(w,function(e){var n=t-(e-h);return m?a(n,l-(e-p)):n}(e))}function E(e){return f=void 0,v&&c?y(e):(c=u=void 0,d)}function N(){var e=o(),n=b(e);if(c=arguments,u=this,h=e,n){if(void 0===f)return function(e){return p=e,f=setTimeout(w,t),g?y(e):d}(h);if(m)return clearTimeout(f),f=setTimeout(w,t),y(h)}return void 0===f&&(f=setTimeout(w,t)),d}return t=i(t)||0,r(n)&&(g=!!n.leading,l=(m="maxWait"in n)?s(i(n.maxWait)||0,t):l,v="trailing"in n?!!n.trailing:v),N.cancel=function(){void 0!==f&&clearTimeout(f),p=0,c=h=u=f=void 0},N.flush=function(){return void 0===f?d:E(o())},N}},230(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},470(e){e.exports=function(e){return null!=e&&"object"==typeof e}},89(e,t,n){var r=n(561),o=n(470);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},381(e,t,n){var r=n(736);e.exports=function(){return r.Date.now()}},569(e,t,n){var r=n(605),o=n(230),i=n(89),s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=a.test(e);return n||c.test(e)?u(e.slice(2),n?2:8):s.test(e)?NaN:+e}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=n(702),t=n.n(e),r=class extends Error{code;constructor(e,t){super(t),this.name="PenpalError",this.code=e}},o=e=>({name:e.name,message:e.message,stack:e.stack,penpalCode:e instanceof r?e.code:void 0}),i=Symbol("Reply"),s=class{value;transferables;#e=i;constructor(e,t){this.value=e,this.transferables=t?.transferables}},a="penpal",c=e=>"object"==typeof e&&null!==e,u=e=>"function"==typeof e,l=e=>"SYN"===e.type,d=e=>"ACK1"===e.type,f=e=>"ACK2"===e.type,h=e=>"CALL"===e.type,p=e=>"REPLY"===e.type,g=(e,t=[])=>{const n=[];for(const r of Object.keys(e)){const o=e[r];u(o)?n.push([...t,r]):c(o)&&n.push(...g(o,[...t,r]))}return n},m=e=>e.join("."),v=(e,t,n)=>({namespace:a,channel:e,type:"REPLY",callId:t,isError:!0,...n instanceof Error?{value:o(n),isSerializedErrorInstance:!0}:{value:n}}),y=crypto.randomUUID?.bind(crypto)??(()=>new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")),b=Symbol("CallOptions"),w=class{transferables;timeout;#e=b;constructor(e){this.transferables=e?.transferables,this.timeout=e?.timeout}},E=new Set(["apply","call","bind"]),N=(e,t,n=[])=>new Proxy(n.length?()=>{}:Object.create(null),{get(r,o){if("then"!==o)return n.length&&E.has(o)?Reflect.get(r,o):N(e,t,[...n,o])},apply:(t,r,o)=>e(n,o)}),C=e=>new r("CONNECTION_DESTROYED",`Method call ${m(e)}() failed due to destroyed connection`),S=class extends Error{constructor(e){super(`You\'ve hit a bug in Penpal. Please file an issue with the following information: ${e}`)}},x="deprecated-penpal",O=e=>e.join("."),P=e=>new S(`Unexpected message to translate: ${JSON.stringify(e)}`),T=({messenger:e,methods:t,timeout:n,channel:o,log:i})=>{const b=y();let E;const S=[];let O=!1;const P=g(t),{promise:T,resolve:M,reject:I}=(()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}})(),A=void 0!==n?setTimeout(()=>{I(new r("CONNECTION_TIMEOUT",`Connection timed out after ${n}ms`))},n):void 0,R=()=>{for(const e of S)e()},L=()=>{if(O)return;S.push(((e,t,n,o)=>{let i=!1;const l=async l=>{if(i)return;if(!h(l))return;o?.(`Received ${m(l.methodPath)}() call`,l);const{methodPath:d,args:f,id:p}=l;let g,y;try{const e=((e,t)=>{const n=e.reduce((e,t)=>c(e)?e[t]:void 0,t);return u(n)?n:void 0})(d,t);if(!e)throw new r("METHOD_NOT_FOUND",`Method \\`${m(d)}\\` is not found.`);let o=await e(...f);o instanceof s&&(y=o.transferables,o=await o.value),g={namespace:a,channel:n,type:"REPLY",callId:p,value:o}}catch(e){g=v(n,p,e)}if(!i)try{o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g,y)}catch(t){throw"DataCloneError"===t.name&&(g=v(n,p,t),o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g)),t}};return e.addMessageHandler(l),()=>{i=!0,e.removeMessageHandler(l)}})(e,t,o,i));const{remoteProxy:n,destroy:l}=((e,t,n)=>{let o=!1;const i=new Map,s=e=>{if(!p(e))return;const{callId:t,value:o,isError:s,isSerializedErrorInstance:a}=e,c=i.get(t);c&&(i.delete(t),n?.(`Received ${m(c.methodPath)}() call`,e),s?c.reject(a?(({name:e,message:t,stack:n,penpalCode:o})=>{const i=o?new r(o,t):new Error(t);return i.name=e,i.stack=n,i})(o):o):c.resolve(o))};return e.addMessageHandler(s),{remoteProxy:N((s,c)=>{if(o)throw C(s);const u=y(),l=c[c.length-1],d=l instanceof w,{timeout:f,transferables:h}=d?l:{},p=d?c.slice(0,-1):c;return new Promise((o,c)=>{const l=void 0!==f?window.setTimeout(()=>{i.delete(u),c(new r("METHOD_CALL_TIMEOUT",`Method call ${m(s)}() timed out after ${f}ms`))},f):void 0;i.set(u,{methodPath:s,resolve:o,reject:c,timeoutId:l});try{const r={namespace:a,channel:t,type:"CALL",id:u,methodPath:s,args:p};n?.(`Sending ${m(s)}() call`,r),e.sendMessage(r,h)}catch(e){c(new r("TRANSMISSION_FAILED",e.message))}})},n),destroy:()=>{o=!0,e.removeMessageHandler(s);for(const{methodPath:e,reject:t,timeoutId:n}of i.values())clearTimeout(n),t(C(e));i.clear()}}})(e,o,i);S.push(l),clearTimeout(A),O=!0,M({remoteProxy:n,destroy:R})},D=()=>{const t={namespace:a,type:"SYN",channel:o,participantId:b};i?.("Sending handshake SYN",t);try{e.sendMessage(t)}catch(e){I(new r("TRANSMISSION_FAILED",e.message))}},j=t=>{l(t)&&(t=>{if(i?.("Received handshake SYN",t),t.participantId===E&&E!==x)return;if(E=t.participantId,D(),!(b>E||E===x))return;const n={namespace:a,channel:o,type:"ACK1",methodPaths:P};i?.("Sending handshake ACK1",n);try{e.sendMessage(n)}catch(e){return void I(new r("TRANSMISSION_FAILED",e.message))}})(t),d(t)&&(t=>{i?.("Received handshake ACK1",t);const n={namespace:a,channel:o,type:"ACK2"};i?.("Sending handshake ACK2",n);try{e.sendMessage(n)}catch(e){return void I(new r("TRANSMISSION_FAILED",e.message))}L()})(t),f(t)&&(e=>{i?.("Received handshake ACK2",e),L()})(t)};return e.addMessageHandler(j),S.push(()=>e.removeMessageHandler(j)),D(),T},M=new WeakSet,I=class{#t;#n;#r;#o;#i;#s=new Set;#a;#c=!1;constructor({remoteWindow:e,allowedOrigins:t}){if(!e)throw new r("INVALID_ARGUMENT","remoteWindow must be defined");this.#t=e,this.#n=t?.length?t:[window.origin]}initialize=({log:e,validateReceivedMessage:t})=>{this.#r=e,this.#o=t,window.addEventListener("message",this.#u)};sendMessage=(e,t)=>{if(l(e)){const n=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:n,transfer:t})}if(d(e)||this.#c){const n=this.#c?(e=>{if(d(e))return{penpal:"synAck",methodNames:e.methodPaths.map(O)};if(h(e))return{penpal:"call",id:e.id,methodName:O(e.methodPath),args:e.args};if(p(e))return e.isError?{penpal:"reply",id:e.callId,resolution:"rejected",...e.isSerializedErrorInstance?{returnValue:e.value,returnValueIsError:!0}:{returnValue:e.value}}:{penpal:"reply",id:e.callId,resolution:"fulfilled",returnValue:e.value};throw P(e)})(e):e,r=this.#l(e);return void this.#t.postMessage(n,{targetOrigin:r,transfer:t})}if(f(e)){const{port1:n,port2:r}=new MessageChannel;this.#a=n,n.addEventListener("message",this.#d),n.start();const o=[r,...t||[]],i=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:i,transfer:o})}if(!this.#a)throw new S("Port is undefined");this.#a.postMessage(e,{transfer:t})};addMessageHandler=e=>{this.#s.add(e)};removeMessageHandler=e=>{this.#s.delete(e)};destroy=()=>{window.removeEventListener("message",this.#u),this.#f(),this.#s.clear()};#h=e=>this.#n.some(t=>t instanceof RegExp?t.test(e):t===e||"*"===t);#l=e=>{if(l(e))return"*";if(!this.#i)throw new S("Concrete remote origin not set");return"null"===this.#i&&this.#n.includes("*")?"*":this.#i};#f=()=>{this.#a?.removeEventListener("message",this.#d),this.#a?.close(),this.#a=void 0};#u=({source:e,origin:t,ports:n,data:r})=>{if(e===this.#t&&((e=>c(e)&&"penpal"in e)(r)&&(this.#r?.("Please upgrade the child window to the latest version of Penpal."),this.#c=!0,r=(e=>{if("syn"===e.penpal)return{namespace:a,channel:void 0,type:"SYN",participantId:x};if("ack"===e.penpal)return{namespace:a,channel:void 0,type:"ACK2"};if("call"===e.penpal)return{namespace:a,channel:void 0,type:"CALL",id:e.id,methodPath:(t=e.methodName,t.split(".")),args:e.args};var t;if("reply"===e.penpal)return"fulfilled"===e.resolution?{namespace:a,channel:void 0,type:"REPLY",callId:e.id,value:e.returnValue}:{namespace:a,channel:void 0,type:"REPLY",callId:e.id,isError:!0,...e.returnValueIsError?{value:e.returnValue,isSerializedErrorInstance:!0}:{value:e.returnValue}};throw P(e)})(r)),this.#o?.(r)))if(this.#h(t)){if(l(r)&&(this.#f(),this.#i=t),f(r)&&!this.#c){if(this.#a=n[0],!this.#a)throw new S("No port received on ACK2");this.#a.addEventListener("message",this.#d),this.#a.start()}for(const e of this.#s)e(r)}else this.#r?.(`Received a message from origin \\`${t}\\` which did not match allowed origins \\`[${this.#n.join(", ")}]\\``)};#d=({data:e})=>{if(this.#o?.(e))for(const t of this.#s)t(e)}},A=document,R=window,L=Array.prototype,D=L.filter,j=L.indexOf,F=L.map,$=L.push,_=L.reverse,k=L.slice,W=L.splice,z=/^#[\\w-]*$/,H=/^\\.[\\w-]*$/,U=/<.+>/,V=/^\\w+$/;function B(e,t){return void 0===t&&(t=A),H.test(e)?t.getElementsByClassName(e.slice(1)):V.test(e)?t.getElementsByTagName(e):t.querySelectorAll(e)}function Y(e,t){if(void 0===t&&(t=A),e){if(e.__cash)return e;var n=e;if(ne(e)){if(t.__cash&&(t=t[0]),!(n=z.test(e)?t.getElementById(e.slice(1)):U.test(e)?ke(e):B(e,t)))return}else if(te(e))return this.ready(e);(n.nodeType||n===R)&&(n=[n]),this.length=n.length;for(var r=0,o=this.length;r<o;r++)this[r]=n[r]}}function K(e,t){return new Y(e,t)}var q=K.fn=K.prototype=Y.prototype={constructor:K,__cash:!0,length:0,splice:W};q.get=function(e){return void 0===e?k.call(this):this[e<0?e+this.length:e]},q.eq=function(e){return K(this.get(e))},q.first=function(){return this.eq(0)},q.last=function(){return this.eq(-1)},q.map=function(e){return K(F.call(this,function(t,n){return e.call(t,n,t)}))},q.slice=function(){return K(k.apply(this,arguments))};var G=/(?:^\\w|[A-Z]|\\b\\w)/g,X=/[\\s-_]+/g;function J(e){return e.replace(G,function(e,t){return e[t?"toUpperCase":"toLowerCase"]()}).replace(X,"")}function Z(e,t){for(var n=0,r=e.length;n<r&&!1!==t.call(e[n],e[n],n,e);n++);}K.camelCase=J,K.each=Z,q.each=function(e){return Z(this,function(t,n){return e.call(t,n,t)}),this},q.removeProp=function(e){return this.each(function(t,n){delete n[e]})},K.extend=q.extend=function(e){void 0===e&&(e=this);for(var t=arguments,n=t.length,r=n<2?0:1;r<n;r++)for(var o in t[r])e[o]=t[r][o];return e};var Q=1;function ee(e,t){var n=e&&(e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector);return!!n&&n.call(e,t)}function te(e){return"function"==typeof e}function ne(e){return"string"==typeof e}function re(e){return!isNaN(parseFloat(e))&&isFinite(e)}K.guid=Q,K.matches=ee,K.isFunction=te,K.isString=ne,K.isNumeric=re;var oe=Array.isArray;function ie(e){return ne(e)?function(t,n){return ee(n,e)}:e.__cash?function(t,n){return e.is(n)}:function(e,t,n){return t===n}}K.isArray=oe,q.prop=function(e,t){if(e){if(ne(e))return arguments.length<2?this[0]&&this[0][e]:this.each(function(n,r){r[e]=t});for(var n in e)this.prop(n,e[n]);return this}},q.filter=function(e){if(!e)return K();var t=te(e)?e:ie(e);return K(D.call(this,function(n,r){return t.call(n,r,n,e)}))};var se=/\\S+/g;function ae(e){return ne(e)&&e.match(se)||[]}function ce(e){return e.filter(function(e,t,n){return n.indexOf(e)===t})}function ue(e,t,n){if(1===e.nodeType){var r=R.getComputedStyle(e,null);return t?n?r.getPropertyValue(t):r[t]:r}}function le(e,t){return parseInt(ue(e,t),10)||0}q.hasClass=function(e){var t=ae(e),n=!1;return t.length&&this.each(function(e,r){return!(n=r.classList.contains(t[0]))}),n},q.removeAttr=function(e){var t=ae(e);return t.length?this.each(function(e,n){Z(t,function(e){n.removeAttribute(e)})}):this},q.attr=function(e,t){if(e){if(ne(e)){if(arguments.length<2){if(!this[0])return;var n=this[0].getAttribute(e);return null===n?void 0:n}return null===t?this.removeAttr(e):this.each(function(n,r){r.setAttribute(e,t)})}for(var r in e)this.attr(r,e[r]);return this}},q.toggleClass=function(e,t){var n=ae(e),r=void 0!==t;return n.length?this.each(function(e,o){Z(n,function(e){r?t?o.classList.add(e):o.classList.remove(e):o.classList.toggle(e)})}):this},q.addClass=function(e){return this.toggleClass(e,!0)},q.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},K.unique=ce,q.add=function(e,t){return K(ce(this.get().concat(K(e,t).get())))};var de=/^--/;function fe(e){return de.test(e)}var he={},pe=A.createElement("div").style,ge=["webkit","moz","ms","o"];function me(e,t){if(void 0===t&&(t=fe(e)),t)return e;if(!he[e]){var n=J(e),r=""+n.charAt(0).toUpperCase()+n.slice(1);Z((n+" "+ge.join(r+" ")+r).split(" "),function(t){if(t in pe)return he[e]=t,!1})}return he[e]}K.prefixedProp=me;var ve={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function ye(e,t,n){return void 0===n&&(n=fe(e)),n||ve[e]||!re(t)?t:t+"px"}q.css=function(e,t){if(ne(e)){var n=fe(e);return e=me(e,n),arguments.length<2?this[0]&&ue(this[0],e,n):e?(t=ye(e,t,n),this.each(function(r,o){1===o.nodeType&&(n?o.style.setProperty(e,t):o.style[e]=t)})):this}for(var r in e)this.css(r,e[r]);return this};var be="__cashData",we=/^data-(.*)/;function Ee(e){return e[be]=e[be]||{}}function Ne(e,t){var n=Ee(e);if(t){if(!(t in n)){var r=e.dataset?e.dataset[t]||e.dataset[J(t)]:K(e).attr("data-"+t);if(void 0!==r){try{r=JSON.parse(r)}catch(e){}n[t]=r}}return n[t]}return n}function Ce(e,t){return le(e,"border"+(t?"Left":"Top")+"Width")+le(e,"padding"+(t?"Left":"Top"))+le(e,"padding"+(t?"Right":"Bottom"))+le(e,"border"+(t?"Right":"Bottom")+"Width")}function Se(e,t){for(var n=0,r=t.length;n<r;n++)if(e.indexOf(t[n])<0)return!1;return!0}function xe(e,t,n){Z(e[n],function(e){e[0];var r=e[1];t.removeEventListener(n,r)}),delete e[n]}K.hasData=function(e){return be in e},q.data=function(e,t){var n=this;if(!e){if(!this[0])return;return Z(this[0].attributes,function(e){var t=e.name.match(we);t&&n.data(t[1])}),Ne(this[0])}if(ne(e))return void 0===t?this[0]&&Ne(this[0],e):this.each(function(n,r){return function(e,t,n){Ee(e)[t]=n}(r,e,t)});for(var r in e)this.data(r,e[r]);return this},q.removeData=function(e){return this.each(function(t,n){return function(e,t){void 0===t?delete e[be]:delete Ee(e)[t]}(n,e)})},Z(["Width","Height"],function(e){q["inner"+e]=function(){if(this[0])return this[0]===R?R["inner"+e]:this[0]["client"+e]}}),Z(["width","height"],function(e,t){q[e]=function(n){return this[0]?arguments.length?(n=parseInt(n,10),this.each(function(r,o){if(1===o.nodeType){var i=ue(o,"boxSizing");o.style[e]=ye(e,n+("border-box"===i?Ce(o,!t):0))}})):this[0]===R?this[0][J("outer-"+e)]:this[0].getBoundingClientRect()[e]-Ce(this[0],!t):void 0===n?void 0:this}}),Z(["Width","Height"],function(e,t){q["outer"+e]=function(n){if(this[0])return this[0]===R?R["outer"+e]:this[0]["offset"+e]+(n?le(this[0],"margin"+(t?"Top":"Left"))+le(this[0],"margin"+(t?"Bottom":"Right")):0)}});var Oe="__cashEvents";function Pe(e){return e[Oe]=e[Oe]||{}}function Te(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Me(e,t,n,r){var o=Pe(e);if(t){var i=o[t];if(!i)return;r&&(r.guid=r.guid||Q++),o[t]=i.filter(function(o){var i=o[0],s=o[1];if(r&&s.guid!==r.guid||!Se(i,n))return!0;e.removeEventListener(t,s)})}else if(n&&n.length)for(t in o)Me(e,t,n,r);else for(t in o)xe(o,e,t)}q.off=function(e,t){var n=this;return void 0===e?this.each(function(e,t){return Me(t)}):Z(ae(e),function(e){var r=Te(e),o=r[0],i=r[1];n.each(function(e,n){return Me(n,o,i,t)})}),this},q.on=function(e,t,n,r){var o=this;if(!ne(e)){for(var i in e)this.on(i,t,e[i]);return this}return te(t)&&(n=t,t=!1),Z(ae(e),function(e){var i=Te(e),s=i[0],a=i[1];o.each(function(e,o){var i=function e(i){if(!i.namespace||Se(a,i.namespace.split("."))){var c=o;if(t){for(var u=i.target;!ee(u,t);){if(u===o)return;if(!(u=u.parentNode))return}c=u}i.namespace=i.namespace||"";var l=n.call(c,i,i.data);r&&Me(o,s,a,e),!1===l&&(i.preventDefault(),i.stopPropagation())}};i.guid=n.guid=n.guid||Q++,function(e,t,n,r){r.guid=r.guid||Q++;var o=Pe(e);o[t]=o[t]||[],o[t].push([n,r]),e.addEventListener(t,r)}(o,s,a,i)})}),this},q.one=function(e,t,n){return this.on(e,t,n,!0)},q.ready=function(e){var t=function(){return e(K)};return"loading"!==A.readyState?setTimeout(t):A.addEventListener("DOMContentLoaded",t),this},q.trigger=function(e,t){var n=e;if(ne(e)){var r=Te(e),o=r[0],i=r[1];(n=A.createEvent("HTMLEvents")).initEvent(o,!0,!0),n.namespace=i.join(".")}return n.data=t,this.each(function(e,t){t.dispatchEvent(n)})};var Ie=/select-one/i,Ae=/select-multiple/i;function Re(e){var t=e.type;return Ie.test(t)?function(e){return e.selectedIndex<0?null:e.options[e.selectedIndex].value}(e):Ae.test(t)?function(e){var t=[];return Z(e.options,function(e){!e.selected||e.disabled||e.parentNode.disabled||t.push(e.value)}),t}(e):e.value}var Le=/%20/g,De=/file|reset|submit|button|image/i,je=/radio|checkbox/i;q.serialize=function(){var e="";return this.each(function(t,n){Z(n.elements||[n],function(t){if(!t.disabled&&t.name&&"FIELDSET"!==t.tagName&&!De.test(t.type)&&(!je.test(t.type)||t.checked)){var n=Re(t);void 0!==n&&Z(oe(n)?n:[n],function(n){e+=function(e,t){return"&"+encodeURIComponent(e)+"="+encodeURIComponent(t).replace(Le,"+")}(t.name,n)})}})}),e.substr(1)},q.val=function(e){return void 0===e?this[0]&&Re(this[0]):this.each(function(t,n){var r=Ae.test(n.type),o=null===e?r?[]:"":e;r&&oe(o)?Z(n.options,function(e){e.selected=o.indexOf(e.value)>=0}):n.value=o})},q.clone=function(){return this.map(function(e,t){return t.cloneNode(!0)})},q.detach=function(){return this.each(function(e,t){t.parentNode&&t.parentNode.removeChild(t)})};var Fe,$e=/^\\s*<(\\w+)[^>]*>/,_e=/^\\s*<(\\w+)\\s*\\/?>(?:<\\/\\1>)?\\s*$/;function ke(e){if(function(){if(!Fe){var e=A.createElement("table"),t=A.createElement("tr");Fe={"*":A.createElement("div"),tr:A.createElement("tbody"),td:t,th:t,thead:e,tbody:e,tfoot:e}}}(),!ne(e))return[];if(_e.test(e))return[A.createElement(RegExp.$1)];var t=$e.test(e)&&RegExp.$1,n=Fe[t]||Fe["*"];return n.innerHTML=e,K(n.childNodes).detach().get()}function We(e,t,n){if(void 0!==t){var r=ne(t);!r&&t.length?Z(t,function(t){return We(e,t,n)}):Z(e,r?function(e){e.insertAdjacentHTML(n?"afterbegin":"beforeend",t)}:function(e,r){return function(e,t,n){n?e.insertBefore(t,e.childNodes[0]):e.appendChild(t)}(e,r?t.cloneNode(!0):t,n)})}}K.parseHTML=ke,q.empty=function(){var e=this[0];if(e)for(;e.firstChild;)e.removeChild(e.firstChild);return this},q.append=function(){var e=this;return Z(arguments,function(t){We(e,t)}),this},q.appendTo=function(e){return We(K(e),this),this},q.html=function(e){if(void 0===e)return this[0]&&this[0].innerHTML;var t=e.nodeType?e[0].outerHTML:e;return this.each(function(e,n){n.innerHTML=t})},q.insertAfter=function(e){var t=this;return K(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n.nextSibling)})}),this},q.after=function(){var e=this;return Z(_.apply(arguments),function(t){_.apply(K(t).slice()).insertAfter(e)}),this},q.insertBefore=function(e){var t=this;return K(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n)})}),this},q.before=function(){var e=this;return Z(arguments,function(t){K(t).insertBefore(e)}),this},q.prepend=function(){var e=this;return Z(arguments,function(t){We(e,t,!0)}),this},q.prependTo=function(e){return We(K(e),_.apply(this.slice()),!0),this},q.remove=function(){return this.detach().off()},q.replaceWith=function(e){var t=this;return this.each(function(n,r){var o=r.parentNode;if(o){var i=n?K(e).clone():K(e);if(!i[0])return t.remove(),!1;o.replaceChild(i[0],r),K(i[0]).after(i.slice(1))}})},q.replaceAll=function(e){return K(e).replaceWith(this),this},q.text=function(e){return void 0===e?this[0]?this[0].textContent:"":this.each(function(t,n){n.textContent=e})};var ze=A.documentElement;q.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+R.pageYOffset-ze.clientTop,left:t.left+R.pageXOffset-ze.clientLeft}}},q.offsetParent=function(){return K(this[0]&&this[0].offsetParent)},q.position=function(){var e=this[0];if(e)return{left:e.offsetLeft,top:e.offsetTop}},q.children=function(e){var t=[];return this.each(function(e,n){$.apply(t,n.children)}),t=K(ce(t)),e?t.filter(function(t,n){return ee(n,e)}):t},q.contents=function(){var e=[];return this.each(function(t,n){$.apply(e,"IFRAME"===n.tagName?[n.contentDocument]:n.childNodes)}),K(e.length&&ce(e))},q.find=function(e){for(var t=[],n=0,r=this.length;n<r;n++){var o=B(e,this[n]);o.length&&$.apply(t,o)}return K(t.length&&ce(t))},q.has=function(e){var t=ne(e)?function(t,n){return!!B(e,n).length}:function(t,n){return n.contains(e)};return this.filter(t)},q.is=function(e){if(!e||!this[0])return!1;var t=ie(e),n=!1;return this.each(function(r,o){return!(n=t(r,o,e))}),n},q.next=function(){return K(this[0]&&this[0].nextElementSibling)},q.not=function(e){if(!e||!this[0])return this;var t=ie(e);return this.filter(function(n,r){return!t(n,r,e)})},q.parent=function(){var e=[];return this.each(function(t,n){n&&n.parentNode&&e.push(n.parentNode)}),K(ce(e))},q.index=function(e){var t=e?K(e)[0]:this[0],n=e?this:K(t).parent().children();return j.call(n,t)},q.closest=function(e){return e&&this[0]?this.is(e)?this.filter(e):this.parent().closest(e):K()},q.parents=function(e){var t,n=[];return this.each(function(r,o){for(t=o;t&&t.parentNode&&t!==A.body.parentNode;)t=t.parentNode,(!e||e&&ee(t,e))&&n.push(t)}),K(ce(n))},q.prev=function(){return K(this[0]&&this[0].previousElementSibling)},q.siblings=function(){var e=this[0];return this.parent().children().filter(function(t,n){return n!==e})};const He=K,Ue=new class{getFiberNode(e){try{const t=Object.keys(e).find(e=>e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"));return t?e[t]:null}catch(e){return console.warn("[ReactFiberService] Error getting fiber node:",e),null}}getDebugOwner(e){const t=this.getFiberNode(e);return t?._debugOwner??null}getDebugSource(e){const t=this.getFiberNode(e);return t?._debugSource??null}getOwnerDebugSource(e){const t=this.getDebugOwner(e);return t?._debugSource??null}hasDirectSourceInfo(e){return!!e.getAttribute("data-nocode-id")||!!this.getDebugSource(e)}hasOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return!1;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n&&n.length>0}getOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return null;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n?n:null}isSelectableElement(e){if(this.hasDirectSourceInfo(e))return!0;const t=this.getFiberNode(e),n=this.getOwnerDebugSource(e);return!!(t?.return&&5!==t.return.tag&&this.hasOwnerNocodeId(e)&&n)}isComponent(e){if(!this.isSelectableElement(e))return!1;if(e.getAttribute("data-nocode-components-name"))return!0;if(this.getDebugSource(e))return!1;const t=this.getFiberNode(e);return!(!t?.return||5===t.return.tag)}getComponentName(e){const t=e.getAttribute("data-nocode-tag-name");if(t)return t;const n=this.getDebugOwner(e);if(n?.type){const e=n.type;if("function"==typeof e){const t=e.displayName||e.name||"Unknown";return this.normalizeComponentName(t)}if("string"==typeof e)return e}return e.tagName.toLowerCase()}normalizeComponentName(e){return e.replace(/\\d+$/,"")}getComponentProps(e){if(!this.isComponent(e))return;const t=this.getDebugOwner(e);return t?.memoizedProps?this.sanitizeProps(t.memoizedProps):void 0}sanitizeProps(e){const t={};for(const[n,r]of Object.entries(e)){if("children"===n||n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}sanitizeValue(e){if(null===e)return null;if(void 0===e)return;if("function"==typeof e)return;if("symbol"==typeof e)return;if("object"!=typeof e)return e;if("$$typeof"in e)return;if(e instanceof Node)return;if(Array.isArray(e)){const t=[];for(const n of e){const e=this.sanitizeValue(n);void 0!==e&&t.push(e)}return t}const t={};for(const[n,r]of Object.entries(e)){if(n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}buildComponentInfo(e){const t=this.isComponent(e),n={isComponent:t,componentType:t?"component":"host",name:t?this.getComponentName(e):e.tagName.toLowerCase()},r=e.getAttribute("data-nocode-components-name"),o=e.getAttribute("data-nocode-components-version");if(r&&(n.componentsName=r),o&&(n.componentsVersion=o),t){const t=this.getComponentProps(e)??{},r=this.removeSpecialProps(t);n.props=r}return n}removeSpecialProps(e){const t={};for(const[n,r]of Object.entries(e))"componentsName"!==n&&"componentsVersion"!==n&&(n.startsWith("data-nocode-")||(t[n]=r));return t}},Ve="data-dnd",Be=`[${Ve}]`;function Ye(e){return document.querySelector(`[${Ve}="${e}"]`)}const Ke=(e,t)=>{const n=e.getBoundingClientRect(),{x:r,y:o}=((e,t)=>{let n=e.x,r=e.y;if(t){const e=t.getBoundingClientRect();n-=e.left,r-=e.top}return{x:n,y:r}})({x:n.left,y:n.top},t);return{width:e.offsetWidth,height:e.offsetHeight,top:o,left:r}},qe=(e,t)=>{const n=Ke(e,t),r=function(e){return e.dataset}(e),o=Ge(e),i=Xe(e),s=(e=>{const t=window.getComputedStyle(e);return{display:t.display,flexDirection:t.flexDirection,flexWrap:t.flexWrap,position:t.position}})(e),a=r.dnd||"",c=function(e){if(!e)return{};const t=e.split(":");if(t.length>=3){const n=t.pop(),r=t.pop(),o=t.join(":");return{id:e,filename:decodeURIComponent(o),component:r,codeId:n}}return 2===t.length?{id:e,component:t[0],codeId:t[1]}:{id:e}}(a),u=function(e){return Ue.buildComponentInfo(e)}(e),l=function(e){return"true"===e.getAttribute("data-nocode-container-placeholder")}(e),d=(e=>{const t=e.querySelectorAll(`:scope > ${Be}`);if(!t.length)return[];const n=[];return t.forEach(e=>{const t=e;n.push(Ke(t))}),n})(e);return{id:a,codeId:c.codeId,name:c.component||e.tagName.toLowerCase(),filename:c.filename,bounding:n,display:o,computedStyle:s,text:i,containerPlaceholder:l||void 0,componentInfo:u,childrenBoundings:d.length>0?d:void 0}},Ge=e=>He(e).css("display"),Xe=e=>{const t=[];return e.childNodes.forEach(e=>{if(e.nodeType===Node.TEXT_NODE){const n=e.textContent?.trim()||"";n&&t.push(n)}}),t.join(" ")};function Je(e){const t=["div","p","section","article","main","header","footer","nav","h1","h2","h3","h4","h5","h6","span","a","button","i","input","textarea","select","label","form","ul","ol","li","table","thead","tbody","tr","td","th","img","video","audio","canvas","svg"];try{const n=e.tagName.toLowerCase();if(!t.includes(n))return!1;const r=window.getComputedStyle(e);if("none"===r.display||"hidden"===r.visibility||"0"===r.opacity)return!1;const o=e.getBoundingClientRect();return!("inline"!==r.display&&"inline-block"!==r.display&&(0===o.width||0===o.height))}catch(e){return console.warn("Element validation failed:",e),!1}}function Ze(e,t=20){let n=e,r=0;for(;n&&r<t;){if(n.getAttribute(Ve))return n;n=n.parentElement,r++}return null}function Qe(e){const t=window.getComputedStyle(e),n={};for(let e=0;e<t.length;e++){const r=t[e];n[r]=t.getPropertyValue(r)}return n}function et(e){return(...t)=>{try{const n=e(...t);return n&&"function"==typeof n.then?n.catch(n=>(console.error(`Async error in ${e.name}:`,n),console.error("Error stack:",n.stack),console.error("Function arguments:",t),null)):n}catch(n){return console.error(`Sync error in ${e.name}:`,n),n instanceof Error&&console.error("Error stack:",n.stack),console.error("Function arguments:",t),null}}}const tt={getDraggableParentsData:(e,t)=>{const n=function(e,t){const n=((e,t)=>{const n=document.elementFromPoint(e,t);if(!n)return null;const r=n=>{if(n?.shadowRoot){const o=n.shadowRoot.elementFromPoint(e,t);return o===n?n:o?.shadowRoot?r(o):o||n}return n};return r(n)})(e,t);if(!n)return null;let r=n;if(!Je(r)){let e=r.parentElement,t=0;const n=20;for(;e&&t<n;){if(Je(e)){r=e;break}e=e.parentElement,t++}if(!Je(r))return null}const o=Ze(r);return o&&Je(o)?o:null}(e.x,e.y);if(!n)return;const r=(e=>{const t=He(e).closest(Be).get(0),n=He(e).parents(Be).get();return n[0]!==t&&n.unshift(t),n})(n);if(r.length){if(t){const e=r.map(e=>qe(e));return{...e[0],computedStyle:Qe(n),parents:e.slice(1)}}return{...qe(r[0]),computedStyle:Qe(r[0])}}},getElementDataById:e=>{const t=Ye(e);if(t)return{...qe(t),computedStyle:Qe(t)};console.warn("[getElementDataById] Element not found for domId:",e)},getEditableTextElementAtPosition:e=>{const t=function(e,t){if(document.caretPositionFromPoint){const n=document.caretPositionFromPoint(e,t);return n?.offsetNode??null}if(document.caretRangeFromPoint){const n=document.caretRangeFromPoint(e,t);return n?.startContainer??null}return document.elementFromPoint(e,t)}(e.x,e.y);if(!t)return void console.log("[getEditableTextElementAtPosition] No node at point:",e);if(t.nodeType!==Node.TEXT_NODE)return void console.log("[getEditableTextElementAtPosition] Not a text node:",t.nodeType);const n=t.textContent?.trim();if(!n)return void console.log("[getEditableTextElementAtPosition] Empty text node");const r=t.parentElement;if(!r)return void console.log("[getEditableTextElementAtPosition] No parent element");const o=Ze(r);if(o){if(function(e){const t=e.childNodes;let n=!1;for(let e=0;e<t.length;e++){const r=t[e];if(r.nodeType===Node.ELEMENT_NODE)return!1;if(r.nodeType===Node.TEXT_NODE){const e=r.textContent?.trim();e&&(n=!0)}}return n}(o))return console.log("[getEditableTextElementAtPosition] Found editable text element:",o.tagName,o.textContent),{...qe(o),computedStyle:Qe(o)};console.log("[getEditableTextElementAtPosition] Element has child elements, cannot edit directly:",o.tagName)}else console.log("[getEditableTextElementAtPosition] No marked element found")},updateElementTextContent:(e,t)=>{const n=Ye(e);return n?(n.textContent=t,!0):(console.warn("[updateElementTextContent] Element not found:",e),!1)},scrollToElement:e=>{const t=Ye(e);return t?(t.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),!0):(console.warn("[scrollToElement] Element not found for domId:",e),!1)},getProjectLibVersions:function(){try{const e=document.body;if(!e)return console.warn("[sandbox] document.body is not available"),null;const t=e.getAttribute("data-nocode-lib-versions");if(!t)return console.warn("[sandbox] data-nocode-lib-versions attribute not found on body"),null;const n=JSON.parse(t);return"object"!=typeof n||null===n?(console.warn("[sandbox] data-nocode-lib-versions is not a valid object"),null):n}catch(e){return console.error("[sandbox] Failed to parse data-nocode-lib-versions:",e),null}},getCompilerVersion:function(){try{const e=document.body;return e?e.getAttribute("data-nocode-compiler-version"):null}catch(e){return console.error("[sandbox] Failed to get compiler version:",e),null}}},nt=Object.fromEntries(Object.entries(tt).map(([e,t])=>[e,et(t)])),rt="nocode-design-mode";let ot=null,it=!1,st=null;const at=t()(()=>{ot?.onWindowMutated&&(console.log(`${rt} - Notifying parent of DOM mutation`),ot.onWindowMutated({added:{},removed:{}}))},100),ct=async()=>{if(it||ot)return ot;it=!0,console.log(`${rt} - Creating penpal connection`);const e=(({messenger:e,methods:t={},timeout:n,channel:o,log:i})=>{if(!e)throw new r("INVALID_ARGUMENT","messenger must be defined");if(M.has(e))throw new r("INVALID_ARGUMENT","A messenger can only be used for a single connection");M.add(e);const s=[e.destroy],u=(e=>{let t,n=!1;return(...r)=>(n||(n=!0,t=e(...r)),t)})(t=>{if(t){const t={namespace:a,channel:o,type:"DESTROY"};try{e.sendMessage(t)}catch(e){}}for(const e of s)e();i?.("Connection destroyed")}),l=e=>(e=>c(e)&&e.namespace===a)(e)&&e.channel===o;return{promise:(async()=>{try{e.initialize({log:i,validateReceivedMessage:l}),e.addMessageHandler(e=>{(e=>"DESTROY"===e.type)(e)&&u(!1)});const{remoteProxy:r,destroy:a}=await T({messenger:e,methods:t,timeout:n,channel:o,log:i});return s.push(a),r}catch(e){throw u(!0),e}})(),destroy:()=>{u(!0)}}})({messenger:new I({remoteWindow:window===window.top?(console.warn(`${rt} - Not in an iframe, using window.parent as fallback`),window.parent):window.parent===window.top?window.parent:window.top?(console.log(`${rt} - Using window.top for nested iframe scenario`),window.top):window.parent,allowedOrigins:["*"]}),methods:nt});return e.promise.then(e=>{if(!e)return console.error(`${rt} - Failed to setup penpal connection: child is null`),void ut();ot=e,console.log(`${rt} - Penpal connection set`),(()=>{if(st)return;st=new MutationObserver(e=>{e.some(e=>{const t=e.target;return"SCRIPT"!==t.tagName&&"STYLE"!==t.tagName&&("attributes"!==e.type||"style"===e.attributeName||"class"===e.attributeName)})&&at()});const e=()=>{document.body&&st&&(st.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"],characterData:!0}),console.log(`${rt} - MutationObserver started`))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()})()}).finally(()=>{it=!1}),e.promise.catch(e=>{console.error(`${rt} - Failed to setup penpal connection:`,e),ut()}),ot},ut=t()(()=>{it||(console.log(`${rt} - Reconnecting to penpal parent`),ot=null,ct())},1e3);ct()})()})();';
|
|
303
302
|
}
|
|
304
303
|
function createSandboxScriptMiddleware(options) {
|
|
305
304
|
var _a;
|
|
@@ -451,11 +450,13 @@ function componentCompiler(options = {}) {
|
|
|
451
450
|
* 配置解析完成后:
|
|
452
451
|
* 1. 将本插件移到插件列表最前面,确保在所有 enforce: 'pre' 插件中第一个执行
|
|
453
452
|
* 2. 初始化 PackageVersionRegistry
|
|
453
|
+
* 并预扫描项目 dependencies,填充版本缓存
|
|
454
454
|
*/
|
|
455
455
|
configResolved(config) {
|
|
456
456
|
ensurePluginFirst(config, (error) => monitorService.reportError(error, { scene: "ensurePluginFirst" }));
|
|
457
457
|
pkgRegistry = new import_nocode_compiler_core.PackageVersionRegistry(config.root);
|
|
458
458
|
projectRoot = config.root;
|
|
459
|
+
(0, import_nocode_compiler_core.preloadDependencyVersions)(pkgRegistry);
|
|
459
460
|
},
|
|
460
461
|
/**
|
|
461
462
|
* 配置开发服务器,添加 Override 中间件和设计模式中间件
|
|
@@ -473,21 +474,22 @@ function componentCompiler(options = {}) {
|
|
|
473
474
|
}
|
|
474
475
|
});
|
|
475
476
|
server.middlewares.use(createOverrideMiddleware(server));
|
|
476
|
-
|
|
477
|
-
server.middlewares.use(createSandboxScriptMiddleware(designModeOptions));
|
|
478
|
-
}
|
|
477
|
+
server.middlewares.use(createSandboxScriptMiddleware(designModeOptions));
|
|
479
478
|
if (designModeOptions.enableVirtualCode) {
|
|
480
479
|
server.middlewares.use(createVirtualCodeMiddleware(server, designModeOptions, projectRoot));
|
|
481
480
|
console.log(`[DesignMode] Virtual code API enabled at ${designModeOptions.virtualCodeApiPath}`);
|
|
482
481
|
}
|
|
483
482
|
},
|
|
484
483
|
/**
|
|
485
|
-
* 转换
|
|
484
|
+
* 转换 index.html:
|
|
485
|
+
* 1. 在 <body> 标签上注入组件库版本信息和编译插件版本
|
|
486
|
+
* 2. 注入 sandbox script(设计模式功能)
|
|
487
|
+
* 兼容 Vite 2.x - 6.x(transformIndexHtml 从 Vite 2 起就支持简单函数形式)
|
|
486
488
|
*/
|
|
487
489
|
transformIndexHtml(html) {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
490
|
+
const metadata = (0, import_nocode_compiler_core.generateBodyMetadata)(pkgRegistry, version);
|
|
491
|
+
html = (0, import_nocode_compiler_core.injectBodyMetadata)(html, metadata);
|
|
492
|
+
html = injectSandboxScript(html);
|
|
491
493
|
return html;
|
|
492
494
|
},
|
|
493
495
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -8,8 +8,6 @@ interface DesignModePluginOptions {
|
|
|
8
8
|
enableVirtualCode?: boolean;
|
|
9
9
|
/** 虚拟代码 API 路径,默认 '/api/virtual-code' */
|
|
10
10
|
virtualCodeApiPath?: string;
|
|
11
|
-
/** 是否启用 sandbox-script,默认 true */
|
|
12
|
-
enableSandboxScript?: boolean;
|
|
13
11
|
/** 是否启用详细日志,默认 false */
|
|
14
12
|
verbose?: boolean;
|
|
15
13
|
/** 要排除的文件模式,默认 [/node_modules/] */
|
package/dist/index.d.ts
CHANGED
|
@@ -8,8 +8,6 @@ interface DesignModePluginOptions {
|
|
|
8
8
|
enableVirtualCode?: boolean;
|
|
9
9
|
/** 虚拟代码 API 路径,默认 '/api/virtual-code' */
|
|
10
10
|
virtualCodeApiPath?: string;
|
|
11
|
-
/** 是否启用 sandbox-script,默认 true */
|
|
12
|
-
enableSandboxScript?: boolean;
|
|
13
11
|
/** 是否启用详细日志,默认 false */
|
|
14
12
|
verbose?: boolean;
|
|
15
13
|
/** 要排除的文件模式,默认 [/node_modules/] */
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { JSXCompiler, VueCompiler, DesignModeCompiler, detectCompileScenario, PackageVersionRegistry, MonitorService, MetricType } from "@meituan-nocode/nocode-compiler-core";
|
|
2
|
+
import { JSXCompiler, VueCompiler, DesignModeCompiler, detectCompileScenario, PackageVersionRegistry, MonitorService, MetricType, preloadDependencyVersions, generateBodyMetadata, injectBodyMetadata } from "@meituan-nocode/nocode-compiler-core";
|
|
3
3
|
|
|
4
4
|
// src/utils/index.ts
|
|
5
5
|
import { normalize, dirname, isAbsolute, join } from "path";
|
|
@@ -143,7 +143,7 @@ function readJsonBody(req) {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
// package.json
|
|
146
|
-
var version = "0.3.1-beta.
|
|
146
|
+
var version = "0.3.1-beta.2";
|
|
147
147
|
|
|
148
148
|
// src/design-mode/types.ts
|
|
149
149
|
var SANDBOX_SCRIPT_PATH = "/sandbox-script.js";
|
|
@@ -151,7 +151,6 @@ var VIRTUAL_CODE_API_PATH = "/api/virtual-code";
|
|
|
151
151
|
var DEFAULT_DESIGN_MODE_OPTIONS = {
|
|
152
152
|
enableVirtualCode: true,
|
|
153
153
|
virtualCodeApiPath: VIRTUAL_CODE_API_PATH,
|
|
154
|
-
enableSandboxScript: true,
|
|
155
154
|
verbose: false,
|
|
156
155
|
exclude: [/node_modules/],
|
|
157
156
|
include: [/\.[jt]sx?$/]
|
|
@@ -264,7 +263,7 @@ function createVirtualCodeMiddleware(server, options, projectRoot) {
|
|
|
264
263
|
|
|
265
264
|
// src/design-mode/sandbox-script.ts
|
|
266
265
|
function getSandboxScriptContent() {
|
|
267
|
-
return '(()=>{var e={572(e,t,n){var r=n(736).Symbol;e.exports=r},561(e,t,n){var r=n(572),o=n(504),i=n(567),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?o(e):i(e)}},605(e,t,n){var r=n(327),o=/^\\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},433(e,t,n){var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},504(e,t,n){var r=n(572),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var o=s.call(e);return r&&(t?e[a]=n:delete e[a]),o}},567(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},736(e,t,n){var r=n(433),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();e.exports=i},327(e){var t=/\\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},702(e,t,n){var r=n(230),o=n(381),i=n(569),s=Math.max,a=Math.min;e.exports=function(e,t,n){var c,u,l,d,f,h,p=0,g=!1,m=!1,v=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){var n=c,r=u;return c=u=void 0,p=t,d=e.apply(r,n)}function w(e){var n=e-h;return void 0===h||n>=t||n<0||m&&e-p>=l}function b(){var e=o();if(w(e))return E(e);f=setTimeout(b,function(e){var n=t-(e-h);return m?a(n,l-(e-p)):n}(e))}function E(e){return f=void 0,v&&c?y(e):(c=u=void 0,d)}function N(){var e=o(),n=w(e);if(c=arguments,u=this,h=e,n){if(void 0===f)return function(e){return p=e,f=setTimeout(b,t),g?y(e):d}(h);if(m)return clearTimeout(f),f=setTimeout(b,t),y(h)}return void 0===f&&(f=setTimeout(b,t)),d}return t=i(t)||0,r(n)&&(g=!!n.leading,l=(m="maxWait"in n)?s(i(n.maxWait)||0,t):l,v="trailing"in n?!!n.trailing:v),N.cancel=function(){void 0!==f&&clearTimeout(f),p=0,c=h=u=f=void 0},N.flush=function(){return void 0===f?d:E(o())},N}},230(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},470(e){e.exports=function(e){return null!=e&&"object"==typeof e}},89(e,t,n){var r=n(561),o=n(470);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},381(e,t,n){var r=n(736);e.exports=function(){return r.Date.now()}},569(e,t,n){var r=n(605),o=n(230),i=n(89),s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=a.test(e);return n||c.test(e)?u(e.slice(2),n?2:8):s.test(e)?NaN:+e}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=n(702),t=n.n(e),r=class extends Error{code;constructor(e,t){super(t),this.name="PenpalError",this.code=e}},o=e=>({name:e.name,message:e.message,stack:e.stack,penpalCode:e instanceof r?e.code:void 0}),i=Symbol("Reply"),s=class{value;transferables;#e=i;constructor(e,t){this.value=e,this.transferables=t?.transferables}},a="penpal",c=e=>"object"==typeof e&&null!==e,u=e=>"function"==typeof e,l=e=>"SYN"===e.type,d=e=>"ACK1"===e.type,f=e=>"ACK2"===e.type,h=e=>"CALL"===e.type,p=e=>"REPLY"===e.type,g=(e,t=[])=>{const n=[];for(const r of Object.keys(e)){const o=e[r];u(o)?n.push([...t,r]):c(o)&&n.push(...g(o,[...t,r]))}return n},m=e=>e.join("."),v=(e,t,n)=>({namespace:a,channel:e,type:"REPLY",callId:t,isError:!0,...n instanceof Error?{value:o(n),isSerializedErrorInstance:!0}:{value:n}}),y=crypto.randomUUID?.bind(crypto)??(()=>new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")),w=Symbol("CallOptions"),b=class{transferables;timeout;#e=w;constructor(e){this.transferables=e?.transferables,this.timeout=e?.timeout}},E=new Set(["apply","call","bind"]),N=(e,t,n=[])=>new Proxy(n.length?()=>{}:Object.create(null),{get(r,o){if("then"!==o)return n.length&&E.has(o)?Reflect.get(r,o):N(e,t,[...n,o])},apply:(t,r,o)=>e(n,o)}),C=e=>new r("CONNECTION_DESTROYED",`Method call ${m(e)}() failed due to destroyed connection`),S=class extends Error{constructor(e){super(`You\'ve hit a bug in Penpal. Please file an issue with the following information: ${e}`)}},x="deprecated-penpal",O=e=>e.join("."),P=e=>new S(`Unexpected message to translate: ${JSON.stringify(e)}`),T=({messenger:e,methods:t,timeout:n,channel:o,log:i})=>{const w=y();let E;const S=[];let O=!1;const P=g(t),{promise:T,resolve:M,reject:I}=(()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}})(),A=void 0!==n?setTimeout(()=>{I(new r("CONNECTION_TIMEOUT",`Connection timed out after ${n}ms`))},n):void 0,R=()=>{for(const e of S)e()},L=()=>{if(O)return;S.push(((e,t,n,o)=>{let i=!1;const l=async l=>{if(i)return;if(!h(l))return;o?.(`Received ${m(l.methodPath)}() call`,l);const{methodPath:d,args:f,id:p}=l;let g,y;try{const e=((e,t)=>{const n=e.reduce((e,t)=>c(e)?e[t]:void 0,t);return u(n)?n:void 0})(d,t);if(!e)throw new r("METHOD_NOT_FOUND",`Method \\`${m(d)}\\` is not found.`);let o=await e(...f);o instanceof s&&(y=o.transferables,o=await o.value),g={namespace:a,channel:n,type:"REPLY",callId:p,value:o}}catch(e){g=v(n,p,e)}if(!i)try{o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g,y)}catch(t){throw"DataCloneError"===t.name&&(g=v(n,p,t),o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g)),t}};return e.addMessageHandler(l),()=>{i=!0,e.removeMessageHandler(l)}})(e,t,o,i));const{remoteProxy:n,destroy:l}=((e,t,n)=>{let o=!1;const i=new Map,s=e=>{if(!p(e))return;const{callId:t,value:o,isError:s,isSerializedErrorInstance:a}=e,c=i.get(t);c&&(i.delete(t),n?.(`Received ${m(c.methodPath)}() call`,e),s?c.reject(a?(({name:e,message:t,stack:n,penpalCode:o})=>{const i=o?new r(o,t):new Error(t);return i.name=e,i.stack=n,i})(o):o):c.resolve(o))};return e.addMessageHandler(s),{remoteProxy:N((s,c)=>{if(o)throw C(s);const u=y(),l=c[c.length-1],d=l instanceof b,{timeout:f,transferables:h}=d?l:{},p=d?c.slice(0,-1):c;return new Promise((o,c)=>{const l=void 0!==f?window.setTimeout(()=>{i.delete(u),c(new r("METHOD_CALL_TIMEOUT",`Method call ${m(s)}() timed out after ${f}ms`))},f):void 0;i.set(u,{methodPath:s,resolve:o,reject:c,timeoutId:l});try{const r={namespace:a,channel:t,type:"CALL",id:u,methodPath:s,args:p};n?.(`Sending ${m(s)}() call`,r),e.sendMessage(r,h)}catch(e){c(new r("TRANSMISSION_FAILED",e.message))}})},n),destroy:()=>{o=!0,e.removeMessageHandler(s);for(const{methodPath:e,reject:t,timeoutId:n}of i.values())clearTimeout(n),t(C(e));i.clear()}}})(e,o,i);S.push(l),clearTimeout(A),O=!0,M({remoteProxy:n,destroy:R})},D=()=>{const t={namespace:a,type:"SYN",channel:o,participantId:w};i?.("Sending handshake SYN",t);try{e.sendMessage(t)}catch(e){I(new r("TRANSMISSION_FAILED",e.message))}},F=t=>{l(t)&&(t=>{if(i?.("Received handshake SYN",t),t.participantId===E&&E!==x)return;if(E=t.participantId,D(),!(w>E||E===x))return;const n={namespace:a,channel:o,type:"ACK1",methodPaths:P};i?.("Sending handshake ACK1",n);try{e.sendMessage(n)}catch(e){return void I(new r("TRANSMISSION_FAILED",e.message))}})(t),d(t)&&(t=>{i?.("Received handshake ACK1",t);const n={namespace:a,channel:o,type:"ACK2"};i?.("Sending handshake ACK2",n);try{e.sendMessage(n)}catch(e){return void I(new r("TRANSMISSION_FAILED",e.message))}L()})(t),f(t)&&(e=>{i?.("Received handshake ACK2",e),L()})(t)};return e.addMessageHandler(F),S.push(()=>e.removeMessageHandler(F)),D(),T},M=new WeakSet,I=class{#t;#n;#r;#o;#i;#s=new Set;#a;#c=!1;constructor({remoteWindow:e,allowedOrigins:t}){if(!e)throw new r("INVALID_ARGUMENT","remoteWindow must be defined");this.#t=e,this.#n=t?.length?t:[window.origin]}initialize=({log:e,validateReceivedMessage:t})=>{this.#r=e,this.#o=t,window.addEventListener("message",this.#u)};sendMessage=(e,t)=>{if(l(e)){const n=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:n,transfer:t})}if(d(e)||this.#c){const n=this.#c?(e=>{if(d(e))return{penpal:"synAck",methodNames:e.methodPaths.map(O)};if(h(e))return{penpal:"call",id:e.id,methodName:O(e.methodPath),args:e.args};if(p(e))return e.isError?{penpal:"reply",id:e.callId,resolution:"rejected",...e.isSerializedErrorInstance?{returnValue:e.value,returnValueIsError:!0}:{returnValue:e.value}}:{penpal:"reply",id:e.callId,resolution:"fulfilled",returnValue:e.value};throw P(e)})(e):e,r=this.#l(e);return void this.#t.postMessage(n,{targetOrigin:r,transfer:t})}if(f(e)){const{port1:n,port2:r}=new MessageChannel;this.#a=n,n.addEventListener("message",this.#d),n.start();const o=[r,...t||[]],i=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:i,transfer:o})}if(!this.#a)throw new S("Port is undefined");this.#a.postMessage(e,{transfer:t})};addMessageHandler=e=>{this.#s.add(e)};removeMessageHandler=e=>{this.#s.delete(e)};destroy=()=>{window.removeEventListener("message",this.#u),this.#f(),this.#s.clear()};#h=e=>this.#n.some(t=>t instanceof RegExp?t.test(e):t===e||"*"===t);#l=e=>{if(l(e))return"*";if(!this.#i)throw new S("Concrete remote origin not set");return"null"===this.#i&&this.#n.includes("*")?"*":this.#i};#f=()=>{this.#a?.removeEventListener("message",this.#d),this.#a?.close(),this.#a=void 0};#u=({source:e,origin:t,ports:n,data:r})=>{if(e===this.#t&&((e=>c(e)&&"penpal"in e)(r)&&(this.#r?.("Please upgrade the child window to the latest version of Penpal."),this.#c=!0,r=(e=>{if("syn"===e.penpal)return{namespace:a,channel:void 0,type:"SYN",participantId:x};if("ack"===e.penpal)return{namespace:a,channel:void 0,type:"ACK2"};if("call"===e.penpal)return{namespace:a,channel:void 0,type:"CALL",id:e.id,methodPath:(t=e.methodName,t.split(".")),args:e.args};var t;if("reply"===e.penpal)return"fulfilled"===e.resolution?{namespace:a,channel:void 0,type:"REPLY",callId:e.id,value:e.returnValue}:{namespace:a,channel:void 0,type:"REPLY",callId:e.id,isError:!0,...e.returnValueIsError?{value:e.returnValue,isSerializedErrorInstance:!0}:{value:e.returnValue}};throw P(e)})(r)),this.#o?.(r)))if(this.#h(t)){if(l(r)&&(this.#f(),this.#i=t),f(r)&&!this.#c){if(this.#a=n[0],!this.#a)throw new S("No port received on ACK2");this.#a.addEventListener("message",this.#d),this.#a.start()}for(const e of this.#s)e(r)}else this.#r?.(`Received a message from origin \\`${t}\\` which did not match allowed origins \\`[${this.#n.join(", ")}]\\``)};#d=({data:e})=>{if(this.#o?.(e))for(const t of this.#s)t(e)}},A=document,R=window,L=Array.prototype,D=L.filter,F=L.indexOf,j=L.map,$=L.push,_=L.reverse,k=L.slice,W=L.splice,z=/^#[\\w-]*$/,U=/^\\.[\\w-]*$/,V=/<.+>/,H=/^\\w+$/;function B(e,t){return void 0===t&&(t=A),U.test(e)?t.getElementsByClassName(e.slice(1)):H.test(e)?t.getElementsByTagName(e):t.querySelectorAll(e)}function Y(e,t){if(void 0===t&&(t=A),e){if(e.__cash)return e;var n=e;if(ne(e)){if(t.__cash&&(t=t[0]),!(n=z.test(e)?t.getElementById(e.slice(1)):V.test(e)?ke(e):B(e,t)))return}else if(te(e))return this.ready(e);(n.nodeType||n===R)&&(n=[n]),this.length=n.length;for(var r=0,o=this.length;r<o;r++)this[r]=n[r]}}function K(e,t){return new Y(e,t)}var q=K.fn=K.prototype=Y.prototype={constructor:K,__cash:!0,length:0,splice:W};q.get=function(e){return void 0===e?k.call(this):this[e<0?e+this.length:e]},q.eq=function(e){return K(this.get(e))},q.first=function(){return this.eq(0)},q.last=function(){return this.eq(-1)},q.map=function(e){return K(j.call(this,function(t,n){return e.call(t,n,t)}))},q.slice=function(){return K(k.apply(this,arguments))};var G=/(?:^\\w|[A-Z]|\\b\\w)/g,X=/[\\s-_]+/g;function J(e){return e.replace(G,function(e,t){return e[t?"toUpperCase":"toLowerCase"]()}).replace(X,"")}function Z(e,t){for(var n=0,r=e.length;n<r&&!1!==t.call(e[n],e[n],n,e);n++);}K.camelCase=J,K.each=Z,q.each=function(e){return Z(this,function(t,n){return e.call(t,n,t)}),this},q.removeProp=function(e){return this.each(function(t,n){delete n[e]})},K.extend=q.extend=function(e){void 0===e&&(e=this);for(var t=arguments,n=t.length,r=n<2?0:1;r<n;r++)for(var o in t[r])e[o]=t[r][o];return e};var Q=1;function ee(e,t){var n=e&&(e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector);return!!n&&n.call(e,t)}function te(e){return"function"==typeof e}function ne(e){return"string"==typeof e}function re(e){return!isNaN(parseFloat(e))&&isFinite(e)}K.guid=Q,K.matches=ee,K.isFunction=te,K.isString=ne,K.isNumeric=re;var oe=Array.isArray;function ie(e){return ne(e)?function(t,n){return ee(n,e)}:e.__cash?function(t,n){return e.is(n)}:function(e,t,n){return t===n}}K.isArray=oe,q.prop=function(e,t){if(e){if(ne(e))return arguments.length<2?this[0]&&this[0][e]:this.each(function(n,r){r[e]=t});for(var n in e)this.prop(n,e[n]);return this}},q.filter=function(e){if(!e)return K();var t=te(e)?e:ie(e);return K(D.call(this,function(n,r){return t.call(n,r,n,e)}))};var se=/\\S+/g;function ae(e){return ne(e)&&e.match(se)||[]}function ce(e){return e.filter(function(e,t,n){return n.indexOf(e)===t})}function ue(e,t,n){if(1===e.nodeType){var r=R.getComputedStyle(e,null);return t?n?r.getPropertyValue(t):r[t]:r}}function le(e,t){return parseInt(ue(e,t),10)||0}q.hasClass=function(e){var t=ae(e),n=!1;return t.length&&this.each(function(e,r){return!(n=r.classList.contains(t[0]))}),n},q.removeAttr=function(e){var t=ae(e);return t.length?this.each(function(e,n){Z(t,function(e){n.removeAttribute(e)})}):this},q.attr=function(e,t){if(e){if(ne(e)){if(arguments.length<2){if(!this[0])return;var n=this[0].getAttribute(e);return null===n?void 0:n}return null===t?this.removeAttr(e):this.each(function(n,r){r.setAttribute(e,t)})}for(var r in e)this.attr(r,e[r]);return this}},q.toggleClass=function(e,t){var n=ae(e),r=void 0!==t;return n.length?this.each(function(e,o){Z(n,function(e){r?t?o.classList.add(e):o.classList.remove(e):o.classList.toggle(e)})}):this},q.addClass=function(e){return this.toggleClass(e,!0)},q.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},K.unique=ce,q.add=function(e,t){return K(ce(this.get().concat(K(e,t).get())))};var de=/^--/;function fe(e){return de.test(e)}var he={},pe=A.createElement("div").style,ge=["webkit","moz","ms","o"];function me(e,t){if(void 0===t&&(t=fe(e)),t)return e;if(!he[e]){var n=J(e),r=""+n.charAt(0).toUpperCase()+n.slice(1);Z((n+" "+ge.join(r+" ")+r).split(" "),function(t){if(t in pe)return he[e]=t,!1})}return he[e]}K.prefixedProp=me;var ve={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function ye(e,t,n){return void 0===n&&(n=fe(e)),n||ve[e]||!re(t)?t:t+"px"}q.css=function(e,t){if(ne(e)){var n=fe(e);return e=me(e,n),arguments.length<2?this[0]&&ue(this[0],e,n):e?(t=ye(e,t,n),this.each(function(r,o){1===o.nodeType&&(n?o.style.setProperty(e,t):o.style[e]=t)})):this}for(var r in e)this.css(r,e[r]);return this};var we="__cashData",be=/^data-(.*)/;function Ee(e){return e[we]=e[we]||{}}function Ne(e,t){var n=Ee(e);if(t){if(!(t in n)){var r=e.dataset?e.dataset[t]||e.dataset[J(t)]:K(e).attr("data-"+t);if(void 0!==r){try{r=JSON.parse(r)}catch(e){}n[t]=r}}return n[t]}return n}function Ce(e,t){return le(e,"border"+(t?"Left":"Top")+"Width")+le(e,"padding"+(t?"Left":"Top"))+le(e,"padding"+(t?"Right":"Bottom"))+le(e,"border"+(t?"Right":"Bottom")+"Width")}function Se(e,t){for(var n=0,r=t.length;n<r;n++)if(e.indexOf(t[n])<0)return!1;return!0}function xe(e,t,n){Z(e[n],function(e){e[0];var r=e[1];t.removeEventListener(n,r)}),delete e[n]}K.hasData=function(e){return we in e},q.data=function(e,t){var n=this;if(!e){if(!this[0])return;return Z(this[0].attributes,function(e){var t=e.name.match(be);t&&n.data(t[1])}),Ne(this[0])}if(ne(e))return void 0===t?this[0]&&Ne(this[0],e):this.each(function(n,r){return function(e,t,n){Ee(e)[t]=n}(r,e,t)});for(var r in e)this.data(r,e[r]);return this},q.removeData=function(e){return this.each(function(t,n){return function(e,t){void 0===t?delete e[we]:delete Ee(e)[t]}(n,e)})},Z(["Width","Height"],function(e){q["inner"+e]=function(){if(this[0])return this[0]===R?R["inner"+e]:this[0]["client"+e]}}),Z(["width","height"],function(e,t){q[e]=function(n){return this[0]?arguments.length?(n=parseInt(n,10),this.each(function(r,o){if(1===o.nodeType){var i=ue(o,"boxSizing");o.style[e]=ye(e,n+("border-box"===i?Ce(o,!t):0))}})):this[0]===R?this[0][J("outer-"+e)]:this[0].getBoundingClientRect()[e]-Ce(this[0],!t):void 0===n?void 0:this}}),Z(["Width","Height"],function(e,t){q["outer"+e]=function(n){if(this[0])return this[0]===R?R["outer"+e]:this[0]["offset"+e]+(n?le(this[0],"margin"+(t?"Top":"Left"))+le(this[0],"margin"+(t?"Bottom":"Right")):0)}});var Oe="__cashEvents";function Pe(e){return e[Oe]=e[Oe]||{}}function Te(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Me(e,t,n,r){var o=Pe(e);if(t){var i=o[t];if(!i)return;r&&(r.guid=r.guid||Q++),o[t]=i.filter(function(o){var i=o[0],s=o[1];if(r&&s.guid!==r.guid||!Se(i,n))return!0;e.removeEventListener(t,s)})}else if(n&&n.length)for(t in o)Me(e,t,n,r);else for(t in o)xe(o,e,t)}q.off=function(e,t){var n=this;return void 0===e?this.each(function(e,t){return Me(t)}):Z(ae(e),function(e){var r=Te(e),o=r[0],i=r[1];n.each(function(e,n){return Me(n,o,i,t)})}),this},q.on=function(e,t,n,r){var o=this;if(!ne(e)){for(var i in e)this.on(i,t,e[i]);return this}return te(t)&&(n=t,t=!1),Z(ae(e),function(e){var i=Te(e),s=i[0],a=i[1];o.each(function(e,o){var i=function e(i){if(!i.namespace||Se(a,i.namespace.split("."))){var c=o;if(t){for(var u=i.target;!ee(u,t);){if(u===o)return;if(!(u=u.parentNode))return}c=u}i.namespace=i.namespace||"";var l=n.call(c,i,i.data);r&&Me(o,s,a,e),!1===l&&(i.preventDefault(),i.stopPropagation())}};i.guid=n.guid=n.guid||Q++,function(e,t,n,r){r.guid=r.guid||Q++;var o=Pe(e);o[t]=o[t]||[],o[t].push([n,r]),e.addEventListener(t,r)}(o,s,a,i)})}),this},q.one=function(e,t,n){return this.on(e,t,n,!0)},q.ready=function(e){var t=function(){return e(K)};return"loading"!==A.readyState?setTimeout(t):A.addEventListener("DOMContentLoaded",t),this},q.trigger=function(e,t){var n=e;if(ne(e)){var r=Te(e),o=r[0],i=r[1];(n=A.createEvent("HTMLEvents")).initEvent(o,!0,!0),n.namespace=i.join(".")}return n.data=t,this.each(function(e,t){t.dispatchEvent(n)})};var Ie=/select-one/i,Ae=/select-multiple/i;function Re(e){var t=e.type;return Ie.test(t)?function(e){return e.selectedIndex<0?null:e.options[e.selectedIndex].value}(e):Ae.test(t)?function(e){var t=[];return Z(e.options,function(e){!e.selected||e.disabled||e.parentNode.disabled||t.push(e.value)}),t}(e):e.value}var Le=/%20/g,De=/file|reset|submit|button|image/i,Fe=/radio|checkbox/i;q.serialize=function(){var e="";return this.each(function(t,n){Z(n.elements||[n],function(t){if(!t.disabled&&t.name&&"FIELDSET"!==t.tagName&&!De.test(t.type)&&(!Fe.test(t.type)||t.checked)){var n=Re(t);void 0!==n&&Z(oe(n)?n:[n],function(n){e+=function(e,t){return"&"+encodeURIComponent(e)+"="+encodeURIComponent(t).replace(Le,"+")}(t.name,n)})}})}),e.substr(1)},q.val=function(e){return void 0===e?this[0]&&Re(this[0]):this.each(function(t,n){var r=Ae.test(n.type),o=null===e?r?[]:"":e;r&&oe(o)?Z(n.options,function(e){e.selected=o.indexOf(e.value)>=0}):n.value=o})},q.clone=function(){return this.map(function(e,t){return t.cloneNode(!0)})},q.detach=function(){return this.each(function(e,t){t.parentNode&&t.parentNode.removeChild(t)})};var je,$e=/^\\s*<(\\w+)[^>]*>/,_e=/^\\s*<(\\w+)\\s*\\/?>(?:<\\/\\1>)?\\s*$/;function ke(e){if(function(){if(!je){var e=A.createElement("table"),t=A.createElement("tr");je={"*":A.createElement("div"),tr:A.createElement("tbody"),td:t,th:t,thead:e,tbody:e,tfoot:e}}}(),!ne(e))return[];if(_e.test(e))return[A.createElement(RegExp.$1)];var t=$e.test(e)&&RegExp.$1,n=je[t]||je["*"];return n.innerHTML=e,K(n.childNodes).detach().get()}function We(e,t,n){if(void 0!==t){var r=ne(t);!r&&t.length?Z(t,function(t){return We(e,t,n)}):Z(e,r?function(e){e.insertAdjacentHTML(n?"afterbegin":"beforeend",t)}:function(e,r){return function(e,t,n){n?e.insertBefore(t,e.childNodes[0]):e.appendChild(t)}(e,r?t.cloneNode(!0):t,n)})}}K.parseHTML=ke,q.empty=function(){var e=this[0];if(e)for(;e.firstChild;)e.removeChild(e.firstChild);return this},q.append=function(){var e=this;return Z(arguments,function(t){We(e,t)}),this},q.appendTo=function(e){return We(K(e),this),this},q.html=function(e){if(void 0===e)return this[0]&&this[0].innerHTML;var t=e.nodeType?e[0].outerHTML:e;return this.each(function(e,n){n.innerHTML=t})},q.insertAfter=function(e){var t=this;return K(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n.nextSibling)})}),this},q.after=function(){var e=this;return Z(_.apply(arguments),function(t){_.apply(K(t).slice()).insertAfter(e)}),this},q.insertBefore=function(e){var t=this;return K(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n)})}),this},q.before=function(){var e=this;return Z(arguments,function(t){K(t).insertBefore(e)}),this},q.prepend=function(){var e=this;return Z(arguments,function(t){We(e,t,!0)}),this},q.prependTo=function(e){return We(K(e),_.apply(this.slice()),!0),this},q.remove=function(){return this.detach().off()},q.replaceWith=function(e){var t=this;return this.each(function(n,r){var o=r.parentNode;if(o){var i=n?K(e).clone():K(e);if(!i[0])return t.remove(),!1;o.replaceChild(i[0],r),K(i[0]).after(i.slice(1))}})},q.replaceAll=function(e){return K(e).replaceWith(this),this},q.text=function(e){return void 0===e?this[0]?this[0].textContent:"":this.each(function(t,n){n.textContent=e})};var ze=A.documentElement;q.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+R.pageYOffset-ze.clientTop,left:t.left+R.pageXOffset-ze.clientLeft}}},q.offsetParent=function(){return K(this[0]&&this[0].offsetParent)},q.position=function(){var e=this[0];if(e)return{left:e.offsetLeft,top:e.offsetTop}},q.children=function(e){var t=[];return this.each(function(e,n){$.apply(t,n.children)}),t=K(ce(t)),e?t.filter(function(t,n){return ee(n,e)}):t},q.contents=function(){var e=[];return this.each(function(t,n){$.apply(e,"IFRAME"===n.tagName?[n.contentDocument]:n.childNodes)}),K(e.length&&ce(e))},q.find=function(e){for(var t=[],n=0,r=this.length;n<r;n++){var o=B(e,this[n]);o.length&&$.apply(t,o)}return K(t.length&&ce(t))},q.has=function(e){var t=ne(e)?function(t,n){return!!B(e,n).length}:function(t,n){return n.contains(e)};return this.filter(t)},q.is=function(e){if(!e||!this[0])return!1;var t=ie(e),n=!1;return this.each(function(r,o){return!(n=t(r,o,e))}),n},q.next=function(){return K(this[0]&&this[0].nextElementSibling)},q.not=function(e){if(!e||!this[0])return this;var t=ie(e);return this.filter(function(n,r){return!t(n,r,e)})},q.parent=function(){var e=[];return this.each(function(t,n){n&&n.parentNode&&e.push(n.parentNode)}),K(ce(e))},q.index=function(e){var t=e?K(e)[0]:this[0],n=e?this:K(t).parent().children();return F.call(n,t)},q.closest=function(e){return e&&this[0]?this.is(e)?this.filter(e):this.parent().closest(e):K()},q.parents=function(e){var t,n=[];return this.each(function(r,o){for(t=o;t&&t.parentNode&&t!==A.body.parentNode;)t=t.parentNode,(!e||e&&ee(t,e))&&n.push(t)}),K(ce(n))},q.prev=function(){return K(this[0]&&this[0].previousElementSibling)},q.siblings=function(){var e=this[0];return this.parent().children().filter(function(t,n){return n!==e})};const Ue=K,Ve=new class{getFiberNode(e){try{const t=Object.keys(e).find(e=>e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"));return t?e[t]:null}catch(e){return console.warn("[ReactFiberService] Error getting fiber node:",e),null}}getDebugOwner(e){const t=this.getFiberNode(e);return t?._debugOwner??null}getDebugSource(e){const t=this.getFiberNode(e);return t?._debugSource??null}getOwnerDebugSource(e){const t=this.getDebugOwner(e);return t?._debugSource??null}hasDirectSourceInfo(e){return!!e.getAttribute("data-nocode-id")||!!this.getDebugSource(e)}hasOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return!1;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n&&n.length>0}getOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return null;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n?n:null}isSelectableElement(e){if(this.hasDirectSourceInfo(e))return!0;const t=this.getFiberNode(e),n=this.getOwnerDebugSource(e);return!!(t?.return&&5!==t.return.tag&&this.hasOwnerNocodeId(e)&&n)}isComponent(e){if(!this.isSelectableElement(e))return!1;if(e.getAttribute("data-nocode-components-name"))return!0;if(this.getDebugSource(e))return!1;const t=this.getFiberNode(e);return!(!t?.return||5===t.return.tag)}getComponentName(e){const t=e.getAttribute("data-nocode-tag-name");if(t)return t;const n=this.getDebugOwner(e);if(n?.type){const e=n.type;if("function"==typeof e){const t=e.displayName||e.name||"Unknown";return this.normalizeComponentName(t)}if("string"==typeof e)return e}return e.tagName.toLowerCase()}normalizeComponentName(e){return e.replace(/\\d+$/,"")}getComponentProps(e){if(!this.isComponent(e))return;const t=this.getDebugOwner(e);return t?.memoizedProps?this.sanitizeProps(t.memoizedProps):void 0}sanitizeProps(e){const t={};for(const[n,r]of Object.entries(e)){if("children"===n||n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}sanitizeValue(e){if(null===e)return null;if(void 0===e)return;if("function"==typeof e)return;if("symbol"==typeof e)return;if("object"!=typeof e)return e;if("$$typeof"in e)return;if(e instanceof Node)return;if(Array.isArray(e)){const t=[];for(const n of e){const e=this.sanitizeValue(n);void 0!==e&&t.push(e)}return t}const t={};for(const[n,r]of Object.entries(e)){if(n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}buildComponentInfo(e,t){const n=this.isComponent(e),r={isComponent:n,componentType:n?"component":"host",name:n?this.getComponentName(e):e.tagName.toLowerCase()};if(n){const n={...t,...this.getComponentProps(e)??{}},{cleanProps:o,extractedProps:i}=this.extractSpecialProps(n);i.componentsName&&(r.componentsName=i.componentsName),i.componentsVersion&&(r.componentsVersion=i.componentsVersion),r.props=o}return r}extractSpecialProps(e){const t={},n={};for(const[r,o]of Object.entries(e))"componentsName"===r&&"string"==typeof o?n.componentsName=o:"componentsVersion"===r&&"string"==typeof o?n.componentsVersion=o:t[r]=o;return{cleanProps:t,extractedProps:n}}};function He(e){const t={},n=e.attributes;for(let e=0;e<n.length;e++){const r=n[e];r.name.startsWith("data-nocode-")&&(t[r.name.replace("data-nocode-","").replace(/-([a-z])/g,(e,t)=>t.toUpperCase())]=r.value)}return t}const Be="data-dnd",Ye=`[${Be}]`;function Ke(e){return document.querySelector(`[${Be}="${e}"]`)}const qe=(e,t)=>{const n=e.getBoundingClientRect(),{x:r,y:o}=((e,t)=>{let n=e.x,r=e.y;if(t){const e=t.getBoundingClientRect();n-=e.left,r-=e.top}return{x:n,y:r}})({x:n.left,y:n.top},t);return{width:e.offsetWidth,height:e.offsetHeight,top:o,left:r}},Ge=(e,t)=>{const n=qe(e,t),r=function(e){return e.dataset}(e),o=Xe(e),i=Je(e),s=(e=>{const t=window.getComputedStyle(e);return{display:t.display,flexDirection:t.flexDirection,flexWrap:t.flexWrap,position:t.position}})(e),a=r.dnd||"",c=function(e){if(!e)return{};const t=e.split(":");if(t.length>=3){const n=t.pop(),r=t.pop(),o=t.join(":");return{id:e,filename:decodeURIComponent(o),component:r,codeId:n}}return 2===t.length?{id:e,component:t[0],codeId:t[1]}:{id:e}}(a),u=He(e),l=function(e){const t=He(e);return Ve.buildComponentInfo(e,t)}(e),d=(e=>{const t=e.querySelectorAll(`:scope > ${Ye}`);if(!t.length)return[];const n=[];return t.forEach(e=>{const t=e;n.push(qe(t))}),n})(e);return{id:a,codeId:c.codeId,name:c.component||e.tagName.toLowerCase(),filename:c.filename,bounding:n,display:o,computedStyle:s,text:i,nocodeData:u,componentInfo:l,childrenBoundings:d.length>0?d:void 0}},Xe=e=>Ue(e).css("display"),Je=e=>{const t=[];return e.childNodes.forEach(e=>{if(e.nodeType===Node.TEXT_NODE){const n=e.textContent?.trim()||"";n&&t.push(n)}}),t.join(" ")};function Ze(e){const t=["div","p","section","article","main","header","footer","nav","h1","h2","h3","h4","h5","h6","span","a","button","i","input","textarea","select","label","form","ul","ol","li","table","thead","tbody","tr","td","th","img","video","audio","canvas","svg"];try{const n=e.tagName.toLowerCase();if(!t.includes(n))return!1;const r=window.getComputedStyle(e);if("none"===r.display||"hidden"===r.visibility||"0"===r.opacity)return!1;const o=e.getBoundingClientRect();return!("inline"!==r.display&&"inline-block"!==r.display&&(0===o.width||0===o.height))}catch(e){return console.warn("Element validation failed:",e),!1}}function Qe(e,t=20){let n=e,r=0;for(;n&&r<t;){if(n.getAttribute(Be))return n;n=n.parentElement,r++}return null}function et(e){const t=window.getComputedStyle(e),n={};for(let e=0;e<t.length;e++){const r=t[e];n[r]=t.getPropertyValue(r)}return n}function tt(e){return(...t)=>{try{const n=e(...t);return n&&"function"==typeof n.then?n.catch(n=>(console.error(`Async error in ${e.name}:`,n),console.error("Error stack:",n.stack),console.error("Function arguments:",t),null)):n}catch(n){return console.error(`Sync error in ${e.name}:`,n),n instanceof Error&&console.error("Error stack:",n.stack),console.error("Function arguments:",t),null}}}const nt={getDraggableParentsData:(e,t)=>{const n=function(e,t){const n=((e,t)=>{const n=document.elementFromPoint(e,t);if(!n)return null;const r=n=>{if(n?.shadowRoot){const o=n.shadowRoot.elementFromPoint(e,t);return o===n?n:o?.shadowRoot?r(o):o||n}return n};return r(n)})(e,t);if(!n)return null;let r=n;if(!Ze(r)){let e=r.parentElement,t=0;const n=20;for(;e&&t<n;){if(Ze(e)){r=e;break}e=e.parentElement,t++}if(!Ze(r))return null}const o=Qe(r);return o&&Ze(o)?o:null}(e.x,e.y);if(!n)return;const r=(e=>{const t=Ue(e).closest(Ye).get(0),n=Ue(e).parents(Ye).get();return n[0]!==t&&n.unshift(t),n})(n);if(r.length){if(t){const e=r.map(e=>Ge(e));return{...e[0],computedStyle:et(n),parents:e.slice(1)}}return{...Ge(r[0]),computedStyle:et(r[0])}}},getElementDataById:e=>{const t=Ke(e);if(t)return{...Ge(t),computedStyle:et(t)};console.warn("[getElementDataById] Element not found for domId:",e)},getEditableTextElementAtPosition:e=>{const t=function(e,t){if(document.caretPositionFromPoint){const n=document.caretPositionFromPoint(e,t);return n?.offsetNode??null}if(document.caretRangeFromPoint){const n=document.caretRangeFromPoint(e,t);return n?.startContainer??null}return document.elementFromPoint(e,t)}(e.x,e.y);if(!t)return void console.log("[getEditableTextElementAtPosition] No node at point:",e);if(t.nodeType!==Node.TEXT_NODE)return void console.log("[getEditableTextElementAtPosition] Not a text node:",t.nodeType);const n=t.textContent?.trim();if(!n)return void console.log("[getEditableTextElementAtPosition] Empty text node");const r=t.parentElement;if(!r)return void console.log("[getEditableTextElementAtPosition] No parent element");const o=Qe(r);if(o){if(function(e){const t=e.childNodes;let n=!1;for(let e=0;e<t.length;e++){const r=t[e];if(r.nodeType===Node.ELEMENT_NODE)return!1;if(r.nodeType===Node.TEXT_NODE){const e=r.textContent?.trim();e&&(n=!0)}}return n}(o))return console.log("[getEditableTextElementAtPosition] Found editable text element:",o.tagName,o.textContent),{...Ge(o),computedStyle:et(o)};console.log("[getEditableTextElementAtPosition] Element has child elements, cannot edit directly:",o.tagName)}else console.log("[getEditableTextElementAtPosition] No marked element found")},updateElementTextContent:(e,t)=>{const n=Ke(e);return n?(n.textContent=t,!0):(console.warn("[updateElementTextContent] Element not found:",e),!1)},scrollToElement:e=>{const t=Ke(e);return t?(t.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),!0):(console.warn("[scrollToElement] Element not found for domId:",e),!1)}},rt=Object.fromEntries(Object.entries(nt).map(([e,t])=>[e,tt(t)])),ot="nocode-design-mode";let it=null,st=!1,at=null;const ct=t()(()=>{it?.onWindowMutated&&(console.log(`${ot} - Notifying parent of DOM mutation`),it.onWindowMutated({added:{},removed:{}}))},100),ut=async()=>{if(st||it)return it;st=!0,console.log(`${ot} - Creating penpal connection`);const e=(({messenger:e,methods:t={},timeout:n,channel:o,log:i})=>{if(!e)throw new r("INVALID_ARGUMENT","messenger must be defined");if(M.has(e))throw new r("INVALID_ARGUMENT","A messenger can only be used for a single connection");M.add(e);const s=[e.destroy],u=(e=>{let t,n=!1;return(...r)=>(n||(n=!0,t=e(...r)),t)})(t=>{if(t){const t={namespace:a,channel:o,type:"DESTROY"};try{e.sendMessage(t)}catch(e){}}for(const e of s)e();i?.("Connection destroyed")}),l=e=>(e=>c(e)&&e.namespace===a)(e)&&e.channel===o;return{promise:(async()=>{try{e.initialize({log:i,validateReceivedMessage:l}),e.addMessageHandler(e=>{(e=>"DESTROY"===e.type)(e)&&u(!1)});const{remoteProxy:r,destroy:a}=await T({messenger:e,methods:t,timeout:n,channel:o,log:i});return s.push(a),r}catch(e){throw u(!0),e}})(),destroy:()=>{u(!0)}}})({messenger:new I({remoteWindow:window===window.top?(console.warn(`${ot} - Not in an iframe, using window.parent as fallback`),window.parent):window.parent===window.top?window.parent:window.top?(console.log(`${ot} - Using window.top for nested iframe scenario`),window.top):window.parent,allowedOrigins:["*"]}),methods:rt});return e.promise.then(e=>{if(!e)return console.error(`${ot} - Failed to setup penpal connection: child is null`),void lt();it=e,console.log(`${ot} - Penpal connection set`),(()=>{if(at)return;at=new MutationObserver(e=>{e.some(e=>{const t=e.target;return"SCRIPT"!==t.tagName&&"STYLE"!==t.tagName&&("attributes"!==e.type||"style"===e.attributeName||"class"===e.attributeName)})&&ct()});const e=()=>{document.body&&at&&(at.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"],characterData:!0}),console.log(`${ot} - MutationObserver started`))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()})()}).finally(()=>{st=!1}),e.promise.catch(e=>{console.error(`${ot} - Failed to setup penpal connection:`,e),lt()}),it},lt=t()(()=>{st||(console.log(`${ot} - Reconnecting to penpal parent`),it=null,ut())},1e3);ut()})()})();';
|
|
266
|
+
return '(()=>{var e={572(e,t,n){var r=n(736).Symbol;e.exports=r},561(e,t,n){var r=n(572),o=n(504),i=n(567),s=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?o(e):i(e)}},605(e,t,n){var r=n(327),o=/^\\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},433(e,t,n){var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},504(e,t,n){var r=n(572),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),n=e[a];try{e[a]=void 0;var r=!0}catch(e){}var o=s.call(e);return r&&(t?e[a]=n:delete e[a]),o}},567(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},736(e,t,n){var r=n(433),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();e.exports=i},327(e){var t=/\\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},702(e,t,n){var r=n(230),o=n(381),i=n(569),s=Math.max,a=Math.min;e.exports=function(e,t,n){var c,u,l,d,f,h,p=0,g=!1,m=!1,v=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){var n=c,r=u;return c=u=void 0,p=t,d=e.apply(r,n)}function b(e){var n=e-h;return void 0===h||n>=t||n<0||m&&e-p>=l}function w(){var e=o();if(b(e))return E(e);f=setTimeout(w,function(e){var n=t-(e-h);return m?a(n,l-(e-p)):n}(e))}function E(e){return f=void 0,v&&c?y(e):(c=u=void 0,d)}function N(){var e=o(),n=b(e);if(c=arguments,u=this,h=e,n){if(void 0===f)return function(e){return p=e,f=setTimeout(w,t),g?y(e):d}(h);if(m)return clearTimeout(f),f=setTimeout(w,t),y(h)}return void 0===f&&(f=setTimeout(w,t)),d}return t=i(t)||0,r(n)&&(g=!!n.leading,l=(m="maxWait"in n)?s(i(n.maxWait)||0,t):l,v="trailing"in n?!!n.trailing:v),N.cancel=function(){void 0!==f&&clearTimeout(f),p=0,c=h=u=f=void 0},N.flush=function(){return void 0===f?d:E(o())},N}},230(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},470(e){e.exports=function(e){return null!=e&&"object"==typeof e}},89(e,t,n){var r=n(561),o=n(470);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},381(e,t,n){var r=n(736);e.exports=function(){return r.Date.now()}},569(e,t,n){var r=n(605),o=n(230),i=n(89),s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=a.test(e);return n||c.test(e)?u(e.slice(2),n?2:8):s.test(e)?NaN:+e}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=n(702),t=n.n(e),r=class extends Error{code;constructor(e,t){super(t),this.name="PenpalError",this.code=e}},o=e=>({name:e.name,message:e.message,stack:e.stack,penpalCode:e instanceof r?e.code:void 0}),i=Symbol("Reply"),s=class{value;transferables;#e=i;constructor(e,t){this.value=e,this.transferables=t?.transferables}},a="penpal",c=e=>"object"==typeof e&&null!==e,u=e=>"function"==typeof e,l=e=>"SYN"===e.type,d=e=>"ACK1"===e.type,f=e=>"ACK2"===e.type,h=e=>"CALL"===e.type,p=e=>"REPLY"===e.type,g=(e,t=[])=>{const n=[];for(const r of Object.keys(e)){const o=e[r];u(o)?n.push([...t,r]):c(o)&&n.push(...g(o,[...t,r]))}return n},m=e=>e.join("."),v=(e,t,n)=>({namespace:a,channel:e,type:"REPLY",callId:t,isError:!0,...n instanceof Error?{value:o(n),isSerializedErrorInstance:!0}:{value:n}}),y=crypto.randomUUID?.bind(crypto)??(()=>new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")),b=Symbol("CallOptions"),w=class{transferables;timeout;#e=b;constructor(e){this.transferables=e?.transferables,this.timeout=e?.timeout}},E=new Set(["apply","call","bind"]),N=(e,t,n=[])=>new Proxy(n.length?()=>{}:Object.create(null),{get(r,o){if("then"!==o)return n.length&&E.has(o)?Reflect.get(r,o):N(e,t,[...n,o])},apply:(t,r,o)=>e(n,o)}),C=e=>new r("CONNECTION_DESTROYED",`Method call ${m(e)}() failed due to destroyed connection`),S=class extends Error{constructor(e){super(`You\'ve hit a bug in Penpal. Please file an issue with the following information: ${e}`)}},x="deprecated-penpal",O=e=>e.join("."),P=e=>new S(`Unexpected message to translate: ${JSON.stringify(e)}`),T=({messenger:e,methods:t,timeout:n,channel:o,log:i})=>{const b=y();let E;const S=[];let O=!1;const P=g(t),{promise:T,resolve:M,reject:I}=(()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}})(),A=void 0!==n?setTimeout(()=>{I(new r("CONNECTION_TIMEOUT",`Connection timed out after ${n}ms`))},n):void 0,R=()=>{for(const e of S)e()},L=()=>{if(O)return;S.push(((e,t,n,o)=>{let i=!1;const l=async l=>{if(i)return;if(!h(l))return;o?.(`Received ${m(l.methodPath)}() call`,l);const{methodPath:d,args:f,id:p}=l;let g,y;try{const e=((e,t)=>{const n=e.reduce((e,t)=>c(e)?e[t]:void 0,t);return u(n)?n:void 0})(d,t);if(!e)throw new r("METHOD_NOT_FOUND",`Method \\`${m(d)}\\` is not found.`);let o=await e(...f);o instanceof s&&(y=o.transferables,o=await o.value),g={namespace:a,channel:n,type:"REPLY",callId:p,value:o}}catch(e){g=v(n,p,e)}if(!i)try{o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g,y)}catch(t){throw"DataCloneError"===t.name&&(g=v(n,p,t),o?.(`Sending ${m(d)}() reply`,g),e.sendMessage(g)),t}};return e.addMessageHandler(l),()=>{i=!0,e.removeMessageHandler(l)}})(e,t,o,i));const{remoteProxy:n,destroy:l}=((e,t,n)=>{let o=!1;const i=new Map,s=e=>{if(!p(e))return;const{callId:t,value:o,isError:s,isSerializedErrorInstance:a}=e,c=i.get(t);c&&(i.delete(t),n?.(`Received ${m(c.methodPath)}() call`,e),s?c.reject(a?(({name:e,message:t,stack:n,penpalCode:o})=>{const i=o?new r(o,t):new Error(t);return i.name=e,i.stack=n,i})(o):o):c.resolve(o))};return e.addMessageHandler(s),{remoteProxy:N((s,c)=>{if(o)throw C(s);const u=y(),l=c[c.length-1],d=l instanceof w,{timeout:f,transferables:h}=d?l:{},p=d?c.slice(0,-1):c;return new Promise((o,c)=>{const l=void 0!==f?window.setTimeout(()=>{i.delete(u),c(new r("METHOD_CALL_TIMEOUT",`Method call ${m(s)}() timed out after ${f}ms`))},f):void 0;i.set(u,{methodPath:s,resolve:o,reject:c,timeoutId:l});try{const r={namespace:a,channel:t,type:"CALL",id:u,methodPath:s,args:p};n?.(`Sending ${m(s)}() call`,r),e.sendMessage(r,h)}catch(e){c(new r("TRANSMISSION_FAILED",e.message))}})},n),destroy:()=>{o=!0,e.removeMessageHandler(s);for(const{methodPath:e,reject:t,timeoutId:n}of i.values())clearTimeout(n),t(C(e));i.clear()}}})(e,o,i);S.push(l),clearTimeout(A),O=!0,M({remoteProxy:n,destroy:R})},D=()=>{const t={namespace:a,type:"SYN",channel:o,participantId:b};i?.("Sending handshake SYN",t);try{e.sendMessage(t)}catch(e){I(new r("TRANSMISSION_FAILED",e.message))}},j=t=>{l(t)&&(t=>{if(i?.("Received handshake SYN",t),t.participantId===E&&E!==x)return;if(E=t.participantId,D(),!(b>E||E===x))return;const n={namespace:a,channel:o,type:"ACK1",methodPaths:P};i?.("Sending handshake ACK1",n);try{e.sendMessage(n)}catch(e){return void I(new r("TRANSMISSION_FAILED",e.message))}})(t),d(t)&&(t=>{i?.("Received handshake ACK1",t);const n={namespace:a,channel:o,type:"ACK2"};i?.("Sending handshake ACK2",n);try{e.sendMessage(n)}catch(e){return void I(new r("TRANSMISSION_FAILED",e.message))}L()})(t),f(t)&&(e=>{i?.("Received handshake ACK2",e),L()})(t)};return e.addMessageHandler(j),S.push(()=>e.removeMessageHandler(j)),D(),T},M=new WeakSet,I=class{#t;#n;#r;#o;#i;#s=new Set;#a;#c=!1;constructor({remoteWindow:e,allowedOrigins:t}){if(!e)throw new r("INVALID_ARGUMENT","remoteWindow must be defined");this.#t=e,this.#n=t?.length?t:[window.origin]}initialize=({log:e,validateReceivedMessage:t})=>{this.#r=e,this.#o=t,window.addEventListener("message",this.#u)};sendMessage=(e,t)=>{if(l(e)){const n=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:n,transfer:t})}if(d(e)||this.#c){const n=this.#c?(e=>{if(d(e))return{penpal:"synAck",methodNames:e.methodPaths.map(O)};if(h(e))return{penpal:"call",id:e.id,methodName:O(e.methodPath),args:e.args};if(p(e))return e.isError?{penpal:"reply",id:e.callId,resolution:"rejected",...e.isSerializedErrorInstance?{returnValue:e.value,returnValueIsError:!0}:{returnValue:e.value}}:{penpal:"reply",id:e.callId,resolution:"fulfilled",returnValue:e.value};throw P(e)})(e):e,r=this.#l(e);return void this.#t.postMessage(n,{targetOrigin:r,transfer:t})}if(f(e)){const{port1:n,port2:r}=new MessageChannel;this.#a=n,n.addEventListener("message",this.#d),n.start();const o=[r,...t||[]],i=this.#l(e);return void this.#t.postMessage(e,{targetOrigin:i,transfer:o})}if(!this.#a)throw new S("Port is undefined");this.#a.postMessage(e,{transfer:t})};addMessageHandler=e=>{this.#s.add(e)};removeMessageHandler=e=>{this.#s.delete(e)};destroy=()=>{window.removeEventListener("message",this.#u),this.#f(),this.#s.clear()};#h=e=>this.#n.some(t=>t instanceof RegExp?t.test(e):t===e||"*"===t);#l=e=>{if(l(e))return"*";if(!this.#i)throw new S("Concrete remote origin not set");return"null"===this.#i&&this.#n.includes("*")?"*":this.#i};#f=()=>{this.#a?.removeEventListener("message",this.#d),this.#a?.close(),this.#a=void 0};#u=({source:e,origin:t,ports:n,data:r})=>{if(e===this.#t&&((e=>c(e)&&"penpal"in e)(r)&&(this.#r?.("Please upgrade the child window to the latest version of Penpal."),this.#c=!0,r=(e=>{if("syn"===e.penpal)return{namespace:a,channel:void 0,type:"SYN",participantId:x};if("ack"===e.penpal)return{namespace:a,channel:void 0,type:"ACK2"};if("call"===e.penpal)return{namespace:a,channel:void 0,type:"CALL",id:e.id,methodPath:(t=e.methodName,t.split(".")),args:e.args};var t;if("reply"===e.penpal)return"fulfilled"===e.resolution?{namespace:a,channel:void 0,type:"REPLY",callId:e.id,value:e.returnValue}:{namespace:a,channel:void 0,type:"REPLY",callId:e.id,isError:!0,...e.returnValueIsError?{value:e.returnValue,isSerializedErrorInstance:!0}:{value:e.returnValue}};throw P(e)})(r)),this.#o?.(r)))if(this.#h(t)){if(l(r)&&(this.#f(),this.#i=t),f(r)&&!this.#c){if(this.#a=n[0],!this.#a)throw new S("No port received on ACK2");this.#a.addEventListener("message",this.#d),this.#a.start()}for(const e of this.#s)e(r)}else this.#r?.(`Received a message from origin \\`${t}\\` which did not match allowed origins \\`[${this.#n.join(", ")}]\\``)};#d=({data:e})=>{if(this.#o?.(e))for(const t of this.#s)t(e)}},A=document,R=window,L=Array.prototype,D=L.filter,j=L.indexOf,F=L.map,$=L.push,_=L.reverse,k=L.slice,W=L.splice,z=/^#[\\w-]*$/,H=/^\\.[\\w-]*$/,U=/<.+>/,V=/^\\w+$/;function B(e,t){return void 0===t&&(t=A),H.test(e)?t.getElementsByClassName(e.slice(1)):V.test(e)?t.getElementsByTagName(e):t.querySelectorAll(e)}function Y(e,t){if(void 0===t&&(t=A),e){if(e.__cash)return e;var n=e;if(ne(e)){if(t.__cash&&(t=t[0]),!(n=z.test(e)?t.getElementById(e.slice(1)):U.test(e)?ke(e):B(e,t)))return}else if(te(e))return this.ready(e);(n.nodeType||n===R)&&(n=[n]),this.length=n.length;for(var r=0,o=this.length;r<o;r++)this[r]=n[r]}}function K(e,t){return new Y(e,t)}var q=K.fn=K.prototype=Y.prototype={constructor:K,__cash:!0,length:0,splice:W};q.get=function(e){return void 0===e?k.call(this):this[e<0?e+this.length:e]},q.eq=function(e){return K(this.get(e))},q.first=function(){return this.eq(0)},q.last=function(){return this.eq(-1)},q.map=function(e){return K(F.call(this,function(t,n){return e.call(t,n,t)}))},q.slice=function(){return K(k.apply(this,arguments))};var G=/(?:^\\w|[A-Z]|\\b\\w)/g,X=/[\\s-_]+/g;function J(e){return e.replace(G,function(e,t){return e[t?"toUpperCase":"toLowerCase"]()}).replace(X,"")}function Z(e,t){for(var n=0,r=e.length;n<r&&!1!==t.call(e[n],e[n],n,e);n++);}K.camelCase=J,K.each=Z,q.each=function(e){return Z(this,function(t,n){return e.call(t,n,t)}),this},q.removeProp=function(e){return this.each(function(t,n){delete n[e]})},K.extend=q.extend=function(e){void 0===e&&(e=this);for(var t=arguments,n=t.length,r=n<2?0:1;r<n;r++)for(var o in t[r])e[o]=t[r][o];return e};var Q=1;function ee(e,t){var n=e&&(e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector);return!!n&&n.call(e,t)}function te(e){return"function"==typeof e}function ne(e){return"string"==typeof e}function re(e){return!isNaN(parseFloat(e))&&isFinite(e)}K.guid=Q,K.matches=ee,K.isFunction=te,K.isString=ne,K.isNumeric=re;var oe=Array.isArray;function ie(e){return ne(e)?function(t,n){return ee(n,e)}:e.__cash?function(t,n){return e.is(n)}:function(e,t,n){return t===n}}K.isArray=oe,q.prop=function(e,t){if(e){if(ne(e))return arguments.length<2?this[0]&&this[0][e]:this.each(function(n,r){r[e]=t});for(var n in e)this.prop(n,e[n]);return this}},q.filter=function(e){if(!e)return K();var t=te(e)?e:ie(e);return K(D.call(this,function(n,r){return t.call(n,r,n,e)}))};var se=/\\S+/g;function ae(e){return ne(e)&&e.match(se)||[]}function ce(e){return e.filter(function(e,t,n){return n.indexOf(e)===t})}function ue(e,t,n){if(1===e.nodeType){var r=R.getComputedStyle(e,null);return t?n?r.getPropertyValue(t):r[t]:r}}function le(e,t){return parseInt(ue(e,t),10)||0}q.hasClass=function(e){var t=ae(e),n=!1;return t.length&&this.each(function(e,r){return!(n=r.classList.contains(t[0]))}),n},q.removeAttr=function(e){var t=ae(e);return t.length?this.each(function(e,n){Z(t,function(e){n.removeAttribute(e)})}):this},q.attr=function(e,t){if(e){if(ne(e)){if(arguments.length<2){if(!this[0])return;var n=this[0].getAttribute(e);return null===n?void 0:n}return null===t?this.removeAttr(e):this.each(function(n,r){r.setAttribute(e,t)})}for(var r in e)this.attr(r,e[r]);return this}},q.toggleClass=function(e,t){var n=ae(e),r=void 0!==t;return n.length?this.each(function(e,o){Z(n,function(e){r?t?o.classList.add(e):o.classList.remove(e):o.classList.toggle(e)})}):this},q.addClass=function(e){return this.toggleClass(e,!0)},q.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},K.unique=ce,q.add=function(e,t){return K(ce(this.get().concat(K(e,t).get())))};var de=/^--/;function fe(e){return de.test(e)}var he={},pe=A.createElement("div").style,ge=["webkit","moz","ms","o"];function me(e,t){if(void 0===t&&(t=fe(e)),t)return e;if(!he[e]){var n=J(e),r=""+n.charAt(0).toUpperCase()+n.slice(1);Z((n+" "+ge.join(r+" ")+r).split(" "),function(t){if(t in pe)return he[e]=t,!1})}return he[e]}K.prefixedProp=me;var ve={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function ye(e,t,n){return void 0===n&&(n=fe(e)),n||ve[e]||!re(t)?t:t+"px"}q.css=function(e,t){if(ne(e)){var n=fe(e);return e=me(e,n),arguments.length<2?this[0]&&ue(this[0],e,n):e?(t=ye(e,t,n),this.each(function(r,o){1===o.nodeType&&(n?o.style.setProperty(e,t):o.style[e]=t)})):this}for(var r in e)this.css(r,e[r]);return this};var be="__cashData",we=/^data-(.*)/;function Ee(e){return e[be]=e[be]||{}}function Ne(e,t){var n=Ee(e);if(t){if(!(t in n)){var r=e.dataset?e.dataset[t]||e.dataset[J(t)]:K(e).attr("data-"+t);if(void 0!==r){try{r=JSON.parse(r)}catch(e){}n[t]=r}}return n[t]}return n}function Ce(e,t){return le(e,"border"+(t?"Left":"Top")+"Width")+le(e,"padding"+(t?"Left":"Top"))+le(e,"padding"+(t?"Right":"Bottom"))+le(e,"border"+(t?"Right":"Bottom")+"Width")}function Se(e,t){for(var n=0,r=t.length;n<r;n++)if(e.indexOf(t[n])<0)return!1;return!0}function xe(e,t,n){Z(e[n],function(e){e[0];var r=e[1];t.removeEventListener(n,r)}),delete e[n]}K.hasData=function(e){return be in e},q.data=function(e,t){var n=this;if(!e){if(!this[0])return;return Z(this[0].attributes,function(e){var t=e.name.match(we);t&&n.data(t[1])}),Ne(this[0])}if(ne(e))return void 0===t?this[0]&&Ne(this[0],e):this.each(function(n,r){return function(e,t,n){Ee(e)[t]=n}(r,e,t)});for(var r in e)this.data(r,e[r]);return this},q.removeData=function(e){return this.each(function(t,n){return function(e,t){void 0===t?delete e[be]:delete Ee(e)[t]}(n,e)})},Z(["Width","Height"],function(e){q["inner"+e]=function(){if(this[0])return this[0]===R?R["inner"+e]:this[0]["client"+e]}}),Z(["width","height"],function(e,t){q[e]=function(n){return this[0]?arguments.length?(n=parseInt(n,10),this.each(function(r,o){if(1===o.nodeType){var i=ue(o,"boxSizing");o.style[e]=ye(e,n+("border-box"===i?Ce(o,!t):0))}})):this[0]===R?this[0][J("outer-"+e)]:this[0].getBoundingClientRect()[e]-Ce(this[0],!t):void 0===n?void 0:this}}),Z(["Width","Height"],function(e,t){q["outer"+e]=function(n){if(this[0])return this[0]===R?R["outer"+e]:this[0]["offset"+e]+(n?le(this[0],"margin"+(t?"Top":"Left"))+le(this[0],"margin"+(t?"Bottom":"Right")):0)}});var Oe="__cashEvents";function Pe(e){return e[Oe]=e[Oe]||{}}function Te(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Me(e,t,n,r){var o=Pe(e);if(t){var i=o[t];if(!i)return;r&&(r.guid=r.guid||Q++),o[t]=i.filter(function(o){var i=o[0],s=o[1];if(r&&s.guid!==r.guid||!Se(i,n))return!0;e.removeEventListener(t,s)})}else if(n&&n.length)for(t in o)Me(e,t,n,r);else for(t in o)xe(o,e,t)}q.off=function(e,t){var n=this;return void 0===e?this.each(function(e,t){return Me(t)}):Z(ae(e),function(e){var r=Te(e),o=r[0],i=r[1];n.each(function(e,n){return Me(n,o,i,t)})}),this},q.on=function(e,t,n,r){var o=this;if(!ne(e)){for(var i in e)this.on(i,t,e[i]);return this}return te(t)&&(n=t,t=!1),Z(ae(e),function(e){var i=Te(e),s=i[0],a=i[1];o.each(function(e,o){var i=function e(i){if(!i.namespace||Se(a,i.namespace.split("."))){var c=o;if(t){for(var u=i.target;!ee(u,t);){if(u===o)return;if(!(u=u.parentNode))return}c=u}i.namespace=i.namespace||"";var l=n.call(c,i,i.data);r&&Me(o,s,a,e),!1===l&&(i.preventDefault(),i.stopPropagation())}};i.guid=n.guid=n.guid||Q++,function(e,t,n,r){r.guid=r.guid||Q++;var o=Pe(e);o[t]=o[t]||[],o[t].push([n,r]),e.addEventListener(t,r)}(o,s,a,i)})}),this},q.one=function(e,t,n){return this.on(e,t,n,!0)},q.ready=function(e){var t=function(){return e(K)};return"loading"!==A.readyState?setTimeout(t):A.addEventListener("DOMContentLoaded",t),this},q.trigger=function(e,t){var n=e;if(ne(e)){var r=Te(e),o=r[0],i=r[1];(n=A.createEvent("HTMLEvents")).initEvent(o,!0,!0),n.namespace=i.join(".")}return n.data=t,this.each(function(e,t){t.dispatchEvent(n)})};var Ie=/select-one/i,Ae=/select-multiple/i;function Re(e){var t=e.type;return Ie.test(t)?function(e){return e.selectedIndex<0?null:e.options[e.selectedIndex].value}(e):Ae.test(t)?function(e){var t=[];return Z(e.options,function(e){!e.selected||e.disabled||e.parentNode.disabled||t.push(e.value)}),t}(e):e.value}var Le=/%20/g,De=/file|reset|submit|button|image/i,je=/radio|checkbox/i;q.serialize=function(){var e="";return this.each(function(t,n){Z(n.elements||[n],function(t){if(!t.disabled&&t.name&&"FIELDSET"!==t.tagName&&!De.test(t.type)&&(!je.test(t.type)||t.checked)){var n=Re(t);void 0!==n&&Z(oe(n)?n:[n],function(n){e+=function(e,t){return"&"+encodeURIComponent(e)+"="+encodeURIComponent(t).replace(Le,"+")}(t.name,n)})}})}),e.substr(1)},q.val=function(e){return void 0===e?this[0]&&Re(this[0]):this.each(function(t,n){var r=Ae.test(n.type),o=null===e?r?[]:"":e;r&&oe(o)?Z(n.options,function(e){e.selected=o.indexOf(e.value)>=0}):n.value=o})},q.clone=function(){return this.map(function(e,t){return t.cloneNode(!0)})},q.detach=function(){return this.each(function(e,t){t.parentNode&&t.parentNode.removeChild(t)})};var Fe,$e=/^\\s*<(\\w+)[^>]*>/,_e=/^\\s*<(\\w+)\\s*\\/?>(?:<\\/\\1>)?\\s*$/;function ke(e){if(function(){if(!Fe){var e=A.createElement("table"),t=A.createElement("tr");Fe={"*":A.createElement("div"),tr:A.createElement("tbody"),td:t,th:t,thead:e,tbody:e,tfoot:e}}}(),!ne(e))return[];if(_e.test(e))return[A.createElement(RegExp.$1)];var t=$e.test(e)&&RegExp.$1,n=Fe[t]||Fe["*"];return n.innerHTML=e,K(n.childNodes).detach().get()}function We(e,t,n){if(void 0!==t){var r=ne(t);!r&&t.length?Z(t,function(t){return We(e,t,n)}):Z(e,r?function(e){e.insertAdjacentHTML(n?"afterbegin":"beforeend",t)}:function(e,r){return function(e,t,n){n?e.insertBefore(t,e.childNodes[0]):e.appendChild(t)}(e,r?t.cloneNode(!0):t,n)})}}K.parseHTML=ke,q.empty=function(){var e=this[0];if(e)for(;e.firstChild;)e.removeChild(e.firstChild);return this},q.append=function(){var e=this;return Z(arguments,function(t){We(e,t)}),this},q.appendTo=function(e){return We(K(e),this),this},q.html=function(e){if(void 0===e)return this[0]&&this[0].innerHTML;var t=e.nodeType?e[0].outerHTML:e;return this.each(function(e,n){n.innerHTML=t})},q.insertAfter=function(e){var t=this;return K(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n.nextSibling)})}),this},q.after=function(){var e=this;return Z(_.apply(arguments),function(t){_.apply(K(t).slice()).insertAfter(e)}),this},q.insertBefore=function(e){var t=this;return K(e).each(function(e,n){var r=n.parentNode;t.each(function(t,o){r.insertBefore(e?o.cloneNode(!0):o,n)})}),this},q.before=function(){var e=this;return Z(arguments,function(t){K(t).insertBefore(e)}),this},q.prepend=function(){var e=this;return Z(arguments,function(t){We(e,t,!0)}),this},q.prependTo=function(e){return We(K(e),_.apply(this.slice()),!0),this},q.remove=function(){return this.detach().off()},q.replaceWith=function(e){var t=this;return this.each(function(n,r){var o=r.parentNode;if(o){var i=n?K(e).clone():K(e);if(!i[0])return t.remove(),!1;o.replaceChild(i[0],r),K(i[0]).after(i.slice(1))}})},q.replaceAll=function(e){return K(e).replaceWith(this),this},q.text=function(e){return void 0===e?this[0]?this[0].textContent:"":this.each(function(t,n){n.textContent=e})};var ze=A.documentElement;q.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+R.pageYOffset-ze.clientTop,left:t.left+R.pageXOffset-ze.clientLeft}}},q.offsetParent=function(){return K(this[0]&&this[0].offsetParent)},q.position=function(){var e=this[0];if(e)return{left:e.offsetLeft,top:e.offsetTop}},q.children=function(e){var t=[];return this.each(function(e,n){$.apply(t,n.children)}),t=K(ce(t)),e?t.filter(function(t,n){return ee(n,e)}):t},q.contents=function(){var e=[];return this.each(function(t,n){$.apply(e,"IFRAME"===n.tagName?[n.contentDocument]:n.childNodes)}),K(e.length&&ce(e))},q.find=function(e){for(var t=[],n=0,r=this.length;n<r;n++){var o=B(e,this[n]);o.length&&$.apply(t,o)}return K(t.length&&ce(t))},q.has=function(e){var t=ne(e)?function(t,n){return!!B(e,n).length}:function(t,n){return n.contains(e)};return this.filter(t)},q.is=function(e){if(!e||!this[0])return!1;var t=ie(e),n=!1;return this.each(function(r,o){return!(n=t(r,o,e))}),n},q.next=function(){return K(this[0]&&this[0].nextElementSibling)},q.not=function(e){if(!e||!this[0])return this;var t=ie(e);return this.filter(function(n,r){return!t(n,r,e)})},q.parent=function(){var e=[];return this.each(function(t,n){n&&n.parentNode&&e.push(n.parentNode)}),K(ce(e))},q.index=function(e){var t=e?K(e)[0]:this[0],n=e?this:K(t).parent().children();return j.call(n,t)},q.closest=function(e){return e&&this[0]?this.is(e)?this.filter(e):this.parent().closest(e):K()},q.parents=function(e){var t,n=[];return this.each(function(r,o){for(t=o;t&&t.parentNode&&t!==A.body.parentNode;)t=t.parentNode,(!e||e&&ee(t,e))&&n.push(t)}),K(ce(n))},q.prev=function(){return K(this[0]&&this[0].previousElementSibling)},q.siblings=function(){var e=this[0];return this.parent().children().filter(function(t,n){return n!==e})};const He=K,Ue=new class{getFiberNode(e){try{const t=Object.keys(e).find(e=>e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"));return t?e[t]:null}catch(e){return console.warn("[ReactFiberService] Error getting fiber node:",e),null}}getDebugOwner(e){const t=this.getFiberNode(e);return t?._debugOwner??null}getDebugSource(e){const t=this.getFiberNode(e);return t?._debugSource??null}getOwnerDebugSource(e){const t=this.getDebugOwner(e);return t?._debugSource??null}hasDirectSourceInfo(e){return!!e.getAttribute("data-nocode-id")||!!this.getDebugSource(e)}hasOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return!1;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n&&n.length>0}getOwnerNocodeId(e){const t=this.getDebugOwner(e);if(!t?.memoizedProps)return null;const n=t.memoizedProps["data-nocode-id"];return"string"==typeof n?n:null}isSelectableElement(e){if(this.hasDirectSourceInfo(e))return!0;const t=this.getFiberNode(e),n=this.getOwnerDebugSource(e);return!!(t?.return&&5!==t.return.tag&&this.hasOwnerNocodeId(e)&&n)}isComponent(e){if(!this.isSelectableElement(e))return!1;if(e.getAttribute("data-nocode-components-name"))return!0;if(this.getDebugSource(e))return!1;const t=this.getFiberNode(e);return!(!t?.return||5===t.return.tag)}getComponentName(e){const t=e.getAttribute("data-nocode-tag-name");if(t)return t;const n=this.getDebugOwner(e);if(n?.type){const e=n.type;if("function"==typeof e){const t=e.displayName||e.name||"Unknown";return this.normalizeComponentName(t)}if("string"==typeof e)return e}return e.tagName.toLowerCase()}normalizeComponentName(e){return e.replace(/\\d+$/,"")}getComponentProps(e){if(!this.isComponent(e))return;const t=this.getDebugOwner(e);return t?.memoizedProps?this.sanitizeProps(t.memoizedProps):void 0}sanitizeProps(e){const t={};for(const[n,r]of Object.entries(e)){if("children"===n||n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}sanitizeValue(e){if(null===e)return null;if(void 0===e)return;if("function"==typeof e)return;if("symbol"==typeof e)return;if("object"!=typeof e)return e;if("$$typeof"in e)return;if(e instanceof Node)return;if(Array.isArray(e)){const t=[];for(const n of e){const e=this.sanitizeValue(n);void 0!==e&&t.push(e)}return t}const t={};for(const[n,r]of Object.entries(e)){if(n.startsWith("_"))continue;const e=this.sanitizeValue(r);void 0!==e&&(t[n]=e)}return t}buildComponentInfo(e){const t=this.isComponent(e),n={isComponent:t,componentType:t?"component":"host",name:t?this.getComponentName(e):e.tagName.toLowerCase()},r=e.getAttribute("data-nocode-components-name"),o=e.getAttribute("data-nocode-components-version");if(r&&(n.componentsName=r),o&&(n.componentsVersion=o),t){const t=this.getComponentProps(e)??{},r=this.removeSpecialProps(t);n.props=r}return n}removeSpecialProps(e){const t={};for(const[n,r]of Object.entries(e))"componentsName"!==n&&"componentsVersion"!==n&&(n.startsWith("data-nocode-")||(t[n]=r));return t}},Ve="data-dnd",Be=`[${Ve}]`;function Ye(e){return document.querySelector(`[${Ve}="${e}"]`)}const Ke=(e,t)=>{const n=e.getBoundingClientRect(),{x:r,y:o}=((e,t)=>{let n=e.x,r=e.y;if(t){const e=t.getBoundingClientRect();n-=e.left,r-=e.top}return{x:n,y:r}})({x:n.left,y:n.top},t);return{width:e.offsetWidth,height:e.offsetHeight,top:o,left:r}},qe=(e,t)=>{const n=Ke(e,t),r=function(e){return e.dataset}(e),o=Ge(e),i=Xe(e),s=(e=>{const t=window.getComputedStyle(e);return{display:t.display,flexDirection:t.flexDirection,flexWrap:t.flexWrap,position:t.position}})(e),a=r.dnd||"",c=function(e){if(!e)return{};const t=e.split(":");if(t.length>=3){const n=t.pop(),r=t.pop(),o=t.join(":");return{id:e,filename:decodeURIComponent(o),component:r,codeId:n}}return 2===t.length?{id:e,component:t[0],codeId:t[1]}:{id:e}}(a),u=function(e){return Ue.buildComponentInfo(e)}(e),l=function(e){return"true"===e.getAttribute("data-nocode-container-placeholder")}(e),d=(e=>{const t=e.querySelectorAll(`:scope > ${Be}`);if(!t.length)return[];const n=[];return t.forEach(e=>{const t=e;n.push(Ke(t))}),n})(e);return{id:a,codeId:c.codeId,name:c.component||e.tagName.toLowerCase(),filename:c.filename,bounding:n,display:o,computedStyle:s,text:i,containerPlaceholder:l||void 0,componentInfo:u,childrenBoundings:d.length>0?d:void 0}},Ge=e=>He(e).css("display"),Xe=e=>{const t=[];return e.childNodes.forEach(e=>{if(e.nodeType===Node.TEXT_NODE){const n=e.textContent?.trim()||"";n&&t.push(n)}}),t.join(" ")};function Je(e){const t=["div","p","section","article","main","header","footer","nav","h1","h2","h3","h4","h5","h6","span","a","button","i","input","textarea","select","label","form","ul","ol","li","table","thead","tbody","tr","td","th","img","video","audio","canvas","svg"];try{const n=e.tagName.toLowerCase();if(!t.includes(n))return!1;const r=window.getComputedStyle(e);if("none"===r.display||"hidden"===r.visibility||"0"===r.opacity)return!1;const o=e.getBoundingClientRect();return!("inline"!==r.display&&"inline-block"!==r.display&&(0===o.width||0===o.height))}catch(e){return console.warn("Element validation failed:",e),!1}}function Ze(e,t=20){let n=e,r=0;for(;n&&r<t;){if(n.getAttribute(Ve))return n;n=n.parentElement,r++}return null}function Qe(e){const t=window.getComputedStyle(e),n={};for(let e=0;e<t.length;e++){const r=t[e];n[r]=t.getPropertyValue(r)}return n}function et(e){return(...t)=>{try{const n=e(...t);return n&&"function"==typeof n.then?n.catch(n=>(console.error(`Async error in ${e.name}:`,n),console.error("Error stack:",n.stack),console.error("Function arguments:",t),null)):n}catch(n){return console.error(`Sync error in ${e.name}:`,n),n instanceof Error&&console.error("Error stack:",n.stack),console.error("Function arguments:",t),null}}}const tt={getDraggableParentsData:(e,t)=>{const n=function(e,t){const n=((e,t)=>{const n=document.elementFromPoint(e,t);if(!n)return null;const r=n=>{if(n?.shadowRoot){const o=n.shadowRoot.elementFromPoint(e,t);return o===n?n:o?.shadowRoot?r(o):o||n}return n};return r(n)})(e,t);if(!n)return null;let r=n;if(!Je(r)){let e=r.parentElement,t=0;const n=20;for(;e&&t<n;){if(Je(e)){r=e;break}e=e.parentElement,t++}if(!Je(r))return null}const o=Ze(r);return o&&Je(o)?o:null}(e.x,e.y);if(!n)return;const r=(e=>{const t=He(e).closest(Be).get(0),n=He(e).parents(Be).get();return n[0]!==t&&n.unshift(t),n})(n);if(r.length){if(t){const e=r.map(e=>qe(e));return{...e[0],computedStyle:Qe(n),parents:e.slice(1)}}return{...qe(r[0]),computedStyle:Qe(r[0])}}},getElementDataById:e=>{const t=Ye(e);if(t)return{...qe(t),computedStyle:Qe(t)};console.warn("[getElementDataById] Element not found for domId:",e)},getEditableTextElementAtPosition:e=>{const t=function(e,t){if(document.caretPositionFromPoint){const n=document.caretPositionFromPoint(e,t);return n?.offsetNode??null}if(document.caretRangeFromPoint){const n=document.caretRangeFromPoint(e,t);return n?.startContainer??null}return document.elementFromPoint(e,t)}(e.x,e.y);if(!t)return void console.log("[getEditableTextElementAtPosition] No node at point:",e);if(t.nodeType!==Node.TEXT_NODE)return void console.log("[getEditableTextElementAtPosition] Not a text node:",t.nodeType);const n=t.textContent?.trim();if(!n)return void console.log("[getEditableTextElementAtPosition] Empty text node");const r=t.parentElement;if(!r)return void console.log("[getEditableTextElementAtPosition] No parent element");const o=Ze(r);if(o){if(function(e){const t=e.childNodes;let n=!1;for(let e=0;e<t.length;e++){const r=t[e];if(r.nodeType===Node.ELEMENT_NODE)return!1;if(r.nodeType===Node.TEXT_NODE){const e=r.textContent?.trim();e&&(n=!0)}}return n}(o))return console.log("[getEditableTextElementAtPosition] Found editable text element:",o.tagName,o.textContent),{...qe(o),computedStyle:Qe(o)};console.log("[getEditableTextElementAtPosition] Element has child elements, cannot edit directly:",o.tagName)}else console.log("[getEditableTextElementAtPosition] No marked element found")},updateElementTextContent:(e,t)=>{const n=Ye(e);return n?(n.textContent=t,!0):(console.warn("[updateElementTextContent] Element not found:",e),!1)},scrollToElement:e=>{const t=Ye(e);return t?(t.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),!0):(console.warn("[scrollToElement] Element not found for domId:",e),!1)},getProjectLibVersions:function(){try{const e=document.body;if(!e)return console.warn("[sandbox] document.body is not available"),null;const t=e.getAttribute("data-nocode-lib-versions");if(!t)return console.warn("[sandbox] data-nocode-lib-versions attribute not found on body"),null;const n=JSON.parse(t);return"object"!=typeof n||null===n?(console.warn("[sandbox] data-nocode-lib-versions is not a valid object"),null):n}catch(e){return console.error("[sandbox] Failed to parse data-nocode-lib-versions:",e),null}},getCompilerVersion:function(){try{const e=document.body;return e?e.getAttribute("data-nocode-compiler-version"):null}catch(e){return console.error("[sandbox] Failed to get compiler version:",e),null}}},nt=Object.fromEntries(Object.entries(tt).map(([e,t])=>[e,et(t)])),rt="nocode-design-mode";let ot=null,it=!1,st=null;const at=t()(()=>{ot?.onWindowMutated&&(console.log(`${rt} - Notifying parent of DOM mutation`),ot.onWindowMutated({added:{},removed:{}}))},100),ct=async()=>{if(it||ot)return ot;it=!0,console.log(`${rt} - Creating penpal connection`);const e=(({messenger:e,methods:t={},timeout:n,channel:o,log:i})=>{if(!e)throw new r("INVALID_ARGUMENT","messenger must be defined");if(M.has(e))throw new r("INVALID_ARGUMENT","A messenger can only be used for a single connection");M.add(e);const s=[e.destroy],u=(e=>{let t,n=!1;return(...r)=>(n||(n=!0,t=e(...r)),t)})(t=>{if(t){const t={namespace:a,channel:o,type:"DESTROY"};try{e.sendMessage(t)}catch(e){}}for(const e of s)e();i?.("Connection destroyed")}),l=e=>(e=>c(e)&&e.namespace===a)(e)&&e.channel===o;return{promise:(async()=>{try{e.initialize({log:i,validateReceivedMessage:l}),e.addMessageHandler(e=>{(e=>"DESTROY"===e.type)(e)&&u(!1)});const{remoteProxy:r,destroy:a}=await T({messenger:e,methods:t,timeout:n,channel:o,log:i});return s.push(a),r}catch(e){throw u(!0),e}})(),destroy:()=>{u(!0)}}})({messenger:new I({remoteWindow:window===window.top?(console.warn(`${rt} - Not in an iframe, using window.parent as fallback`),window.parent):window.parent===window.top?window.parent:window.top?(console.log(`${rt} - Using window.top for nested iframe scenario`),window.top):window.parent,allowedOrigins:["*"]}),methods:nt});return e.promise.then(e=>{if(!e)return console.error(`${rt} - Failed to setup penpal connection: child is null`),void ut();ot=e,console.log(`${rt} - Penpal connection set`),(()=>{if(st)return;st=new MutationObserver(e=>{e.some(e=>{const t=e.target;return"SCRIPT"!==t.tagName&&"STYLE"!==t.tagName&&("attributes"!==e.type||"style"===e.attributeName||"class"===e.attributeName)})&&at()});const e=()=>{document.body&&st&&(st.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"],characterData:!0}),console.log(`${rt} - MutationObserver started`))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()})()}).finally(()=>{it=!1}),e.promise.catch(e=>{console.error(`${rt} - Failed to setup penpal connection:`,e),ut()}),ot},ut=t()(()=>{it||(console.log(`${rt} - Reconnecting to penpal parent`),ot=null,ct())},1e3);ct()})()})();';
|
|
268
267
|
}
|
|
269
268
|
function createSandboxScriptMiddleware(options) {
|
|
270
269
|
var _a;
|
|
@@ -416,11 +415,13 @@ function componentCompiler(options = {}) {
|
|
|
416
415
|
* 配置解析完成后:
|
|
417
416
|
* 1. 将本插件移到插件列表最前面,确保在所有 enforce: 'pre' 插件中第一个执行
|
|
418
417
|
* 2. 初始化 PackageVersionRegistry
|
|
418
|
+
* 并预扫描项目 dependencies,填充版本缓存
|
|
419
419
|
*/
|
|
420
420
|
configResolved(config) {
|
|
421
421
|
ensurePluginFirst(config, (error) => monitorService.reportError(error, { scene: "ensurePluginFirst" }));
|
|
422
422
|
pkgRegistry = new PackageVersionRegistry(config.root);
|
|
423
423
|
projectRoot = config.root;
|
|
424
|
+
preloadDependencyVersions(pkgRegistry);
|
|
424
425
|
},
|
|
425
426
|
/**
|
|
426
427
|
* 配置开发服务器,添加 Override 中间件和设计模式中间件
|
|
@@ -438,21 +439,22 @@ function componentCompiler(options = {}) {
|
|
|
438
439
|
}
|
|
439
440
|
});
|
|
440
441
|
server.middlewares.use(createOverrideMiddleware(server));
|
|
441
|
-
|
|
442
|
-
server.middlewares.use(createSandboxScriptMiddleware(designModeOptions));
|
|
443
|
-
}
|
|
442
|
+
server.middlewares.use(createSandboxScriptMiddleware(designModeOptions));
|
|
444
443
|
if (designModeOptions.enableVirtualCode) {
|
|
445
444
|
server.middlewares.use(createVirtualCodeMiddleware(server, designModeOptions, projectRoot));
|
|
446
445
|
console.log(`[DesignMode] Virtual code API enabled at ${designModeOptions.virtualCodeApiPath}`);
|
|
447
446
|
}
|
|
448
447
|
},
|
|
449
448
|
/**
|
|
450
|
-
* 转换
|
|
449
|
+
* 转换 index.html:
|
|
450
|
+
* 1. 在 <body> 标签上注入组件库版本信息和编译插件版本
|
|
451
|
+
* 2. 注入 sandbox script(设计模式功能)
|
|
452
|
+
* 兼容 Vite 2.x - 6.x(transformIndexHtml 从 Vite 2 起就支持简单函数形式)
|
|
451
453
|
*/
|
|
452
454
|
transformIndexHtml(html) {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
455
|
+
const metadata = generateBodyMetadata(pkgRegistry, version);
|
|
456
|
+
html = injectBodyMetadata(html, metadata);
|
|
457
|
+
html = injectSandboxScript(html);
|
|
456
458
|
return html;
|
|
457
459
|
},
|
|
458
460
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meituan-nocode/vite-plugin-nocode-compiler",
|
|
3
|
-
"version": "0.3.1-beta.
|
|
3
|
+
"version": "0.3.1-beta.2",
|
|
4
4
|
"description": "Vite plugin for nocode compiler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@nocode/
|
|
20
|
+
"@nocode/design-mode-sandbox-script": "0.1.0-beta.4",
|
|
21
|
+
"@meituan-nocode/nocode-compiler-core": "0.2.9-beta.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^20.19.31",
|