@nocobase/plugin-block-workbench 2.1.0-alpha.10 → 2.1.0-alpha.11

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.
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- "use strict";(self.webpackChunk_nocobase_plugin_block_workbench=self.webpackChunk_nocobase_plugin_block_workbench||[]).push([["721"],{264:function(e,t,n){n.r(t),n.d(t,{QRCodeScannerInner:function(){return S},QRCodeScanner:function(){return k}});var r=n(375),o=n(342),i=n(940),a=n(155),l=n.n(a),c=n(953);function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function s(e){var t=e.style,n={position:"absolute",backgroundColor:"rgb(255, 255, 255)"};return l().createElement("div",{id:"qr-scan-box",style:u({boxSizing:"border-box",inset:"0px"},void 0===t?{}:t)},l().createElement("div",{style:u({width:"40px",height:"5px",top:"-5px",left:"0px"},n)}),l().createElement("div",{style:u({width:"40px",height:"5px",top:"-5px",right:"0px"},n)}),l().createElement("div",{style:u({width:"40px",height:"5px",bottom:"-5px",left:"0px"},n)}),l().createElement("div",{style:u({width:"40px",height:"5px",bottom:"-5px",right:"0px"},n)}),l().createElement("div",{style:u({width:"5px",height:"45px",top:"-5px",left:"-5px"},n)}),l().createElement("div",{style:u({width:"5px",height:"45px",bottom:"-5px",left:"-5px"},n)}),l().createElement("div",{style:u({width:"5px",height:"45px",top:"-5px",right:"-5px"},n)}),l().createElement("div",{style:u({width:"5px",height:"45px",bottom:"-5px",right:"-5px"},n)}))}var f=n(27),h=n.n(f),p=n(442);function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function b(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function m(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){b(i,r,o,a,l,"next",e)}function l(e){b(i,r,o,a,l,"throw",e)}a(void 0)})}}function y(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function v(e,t){return e.startsWith(t)?e.slice(t.length):e}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function x(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function w(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var E="qrcode",S=function(e){var t,n,u,f,b,g,x,S,k,O,j,C,I,A,P,M,z,W,T,N=e.setVisible,R=(0,a.useRef)(),_=(0,a.useRef)(),F=(0,c.useTranslation)("block-workbench").t,H=w((0,a.useState)({width:0,height:0}),2),Q=H[0],q=H[1],B=Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),D=Math.max(document.documentElement.clientHeight||0,window.innerHeight||0),V=(n=(t={onScannerSizeChanged:q,elementId:E,onScanSuccess:(0,a.useCallback)(function(e){N(!1)},[N])}).onScannerSizeChanged,u=t.elementId,f=t.onScanSuccess,g=(b=(0,o.useApp)()).pm.get(h()).mobileRouter,x=b.router,S=((null==g?void 0:g.router)?null==g?void 0:g.basename:x.basename).replace(/\/+$/,""),j=(O=function(e){if(Array.isArray(e))return e}(k=(0,a.useState)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(k)||function(e){if(e){if("string"==typeof e)return d(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return d(e,2)}}(k)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],C=O[1],I=(0,p.useNavigate)(),A=(0,c.useTranslation)("block-workbench").t,P=(0,a.useMemo)(function(){return{width:Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),height:Math.max(document.documentElement.clientHeight||0,window.innerHeight||0)}},[]),M=(0,a.useCallback)(function(e){return m(function(){return y(this,function(t){return[2,e.start({facingMode:"environment"},{fps:10,qrbox:function(e,t){return n({width:e,height:t}),{width:P.width,height:P.height}}},function(e){if(null==e?void 0:e.startsWith("http")){window.location.href=e;return}I(v(e,S)),f&&f(e)},void 0)]})})()},[I,n,P,S,f]),z=(0,a.useCallback)(function(e){return m(function(){var t;return y(this,function(n){return(t=e.getState(),[i.Qq.SCANNING,i.Qq.PAUSED].includes(t))?[2,e.stop()]:[2]})})()},[]),W=(0,a.useCallback)(function(e){return m(function(){var t;return y(this,function(n){switch(n.label){case 0:return[4,z(j)];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,4,,5]),[4,j.scanFileV2(e,!1)];case 3:if(null==(t=n.sent().decodedText)?void 0:t.startsWith("http"))return window.location.href=t,[2];return I(v(t,S)),f&&f(t),[3,5];case 4:return n.sent(),alert(A("QR code recognition failed, please scan again")),M(j),[3,5];case 5:return[2]}})})()},[z,j,I,S,A,M,f]),(0,a.useEffect)(function(){var e=new i.j9(u);return C(e),M(e),function(){z(e)}},[u,M,z]),{startScanCamera:M,startScanFile:W}).startScanFile,G=function(){_.current&&_.current.click()},U=function(e){var t=e.target.files;if(t.length>0){var n=t[0];n.size<1e6?V(n):alert(F("The image size is too large. Please compress it to below 1MB before uploading"))}};(0,a.useEffect)(function(){return document.documentElement.style.overscrollBehavior="none",function(){document.documentElement.style.overscrollBehavior="default"}},[]),(0,a.useEffect)(function(){var e=Q.width,t=Q.height,n=Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),r=Math.max(document.documentElement.clientHeight||0,window.innerHeight||0);if(e>0&&t>0&&t<r){var o=Math.floor(r/t*e),i=document.getElementsByTagName("video")[0];i.style.height="".concat(r,"px"),i.style.width="".concat(o,"px"),R.current.style.left="".concat((n-o)/2,"px"),R.current.style.position="absolute"}},[Q]);var $={zIndex:"1003",fontSize:"1.8em",fontWeight:"bold"};return l().createElement(l().Fragment,null,l().createElement("div",{ref:R,id:E,style:{position:"absolute"}}),l().createElement(s,{style:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},(T=Math.floor(.6*Math.min(B,D)),{left:"".concat((B-T)/2,"px"),top:"".concat((D-T)/2,"px"),position:"fixed",width:"".concat(T,"px"),height:"".concat(T,"px")}))}),l().createElement(function(){return l().createElement("div",{style:{position:"absolute",bottom:"20px",left:"20px",padding:"10px 60px"}},l().createElement("div",{style:{color:"white",width:"40px",display:"flex",flexDirection:"column",alignItems:"center"}},l().createElement(r.FileImageOutlined,{style:$,onClick:G}),F("Album"),l().createElement("input",{ref:_,type:"file",accept:"image/*",onChange:U,style:{visibility:"hidden"}})))},null))},k=function(e){var t=(0,o.useActionContext)(),n=t.visible,u=t.setVisible,s=w((0,a.useState)(!1),2),f=s[0],h=s[1],p=(0,c.useTranslation)("block-workbench").t;return(0,a.useEffect)(function(){var e;n&&!f&&(e=function(){var e,t,n;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,i.j9.getCameras()];case 1:return 0===r.sent().length?alert(p("No camera device detected")):h(!0),[3,3];case 2:return e=r.sent(),t={NotFoundError:p("No camera device detected"),NotAllowedError:p("You have not granted permission to use the camera")},console.log(e),alert(null!=(n=t[e.name])?n:e),h(!1),u(!1),[3,3];case 3:return[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){x(i,r,o,a,l,"next",e)}function l(e){x(i,r,o,a,l,"throw",e)}a(void 0)})})()},[n,f,u,p]),n&&f?l().createElement("div",{style:{position:"fixed",width:"100%",height:"100%",background:"black",zIndex:"1001",top:0,left:0,overflow:"hidden"}},l().createElement(S,{setVisible:u}),l().createElement(r.LeftOutlined,{style:{position:"absolute",top:"22px",left:"20px",zIndex:"1003",color:"white",fontSize:"1.8em",fontWeight:"bold"},onClick:function(){return u(!1)}}),l().createElement("div",{style:{position:"absolute",color:"white",fontSize:"1.5em",left:0,right:0,top:"20px",zIndex:"1002",marginLeft:"auto",marginRight:"auto",textAlign:"center"}},p("Scan QR code"))):null}}}]);
10
+ "use strict";(self.webpackChunk_nocobase_plugin_block_workbench=self.webpackChunk_nocobase_plugin_block_workbench||[]).push([["393"],{824:function(e,t,n){n.r(t),n.d(t,{QRCodeScannerInner:function(){return S},QRCodeScanner:function(){return k}});var r=n(375),o=n(342),i=n(940),a=n(155),l=n.n(a),c=n(953);function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function s(e){var t=e.style,n={position:"absolute",backgroundColor:"rgb(255, 255, 255)"};return l().createElement("div",{id:"qr-scan-box",style:u({boxSizing:"border-box",inset:"0px"},void 0===t?{}:t)},l().createElement("div",{style:u({width:"40px",height:"5px",top:"-5px",left:"0px"},n)}),l().createElement("div",{style:u({width:"40px",height:"5px",top:"-5px",right:"0px"},n)}),l().createElement("div",{style:u({width:"40px",height:"5px",bottom:"-5px",left:"0px"},n)}),l().createElement("div",{style:u({width:"40px",height:"5px",bottom:"-5px",right:"0px"},n)}),l().createElement("div",{style:u({width:"5px",height:"45px",top:"-5px",left:"-5px"},n)}),l().createElement("div",{style:u({width:"5px",height:"45px",bottom:"-5px",left:"-5px"},n)}),l().createElement("div",{style:u({width:"5px",height:"45px",top:"-5px",right:"-5px"},n)}),l().createElement("div",{style:u({width:"5px",height:"45px",bottom:"-5px",right:"-5px"},n)}))}var f=n(27),h=n.n(f),p=n(442);function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function b(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function m(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){b(i,r,o,a,l,"next",e)}function l(e){b(i,r,o,a,l,"throw",e)}a(void 0)})}}function y(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function v(e,t){return e.startsWith(t)?e.slice(t.length):e}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function x(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function w(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var E="qrcode",S=function(e){var t,n,u,f,b,g,x,S,k,O,j,C,I,A,P,M,z,W,T,N=e.setVisible,R=(0,a.useRef)(),_=(0,a.useRef)(),F=(0,c.useTranslation)("block-workbench").t,H=w((0,a.useState)({width:0,height:0}),2),Q=H[0],q=H[1],B=Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),D=Math.max(document.documentElement.clientHeight||0,window.innerHeight||0),V=(n=(t={onScannerSizeChanged:q,elementId:E,onScanSuccess:(0,a.useCallback)(function(e){N(!1)},[N])}).onScannerSizeChanged,u=t.elementId,f=t.onScanSuccess,g=(b=(0,o.useApp)()).pm.get(h()).mobileRouter,x=b.router,S=((null==g?void 0:g.router)?null==g?void 0:g.basename:x.basename).replace(/\/+$/,""),j=(O=function(e){if(Array.isArray(e))return e}(k=(0,a.useState)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(k)||function(e){if(e){if("string"==typeof e)return d(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return d(e,2)}}(k)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],C=O[1],I=(0,p.useNavigate)(),A=(0,c.useTranslation)("block-workbench").t,P=(0,a.useMemo)(function(){return{width:Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),height:Math.max(document.documentElement.clientHeight||0,window.innerHeight||0)}},[]),M=(0,a.useCallback)(function(e){return m(function(){return y(this,function(t){return[2,e.start({facingMode:"environment"},{fps:10,qrbox:function(e,t){return n({width:e,height:t}),{width:P.width,height:P.height}}},function(e){if(null==e?void 0:e.startsWith("http")){window.location.href=e;return}I(v(e,S)),f&&f(e)},void 0)]})})()},[I,n,P,S,f]),z=(0,a.useCallback)(function(e){return m(function(){var t;return y(this,function(n){return(t=e.getState(),[i.Qq.SCANNING,i.Qq.PAUSED].includes(t))?[2,e.stop()]:[2]})})()},[]),W=(0,a.useCallback)(function(e){return m(function(){var t;return y(this,function(n){switch(n.label){case 0:return[4,z(j)];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,4,,5]),[4,j.scanFileV2(e,!1)];case 3:if(null==(t=n.sent().decodedText)?void 0:t.startsWith("http"))return window.location.href=t,[2];return I(v(t,S)),f&&f(t),[3,5];case 4:return n.sent(),alert(A("QR code recognition failed, please scan again")),M(j),[3,5];case 5:return[2]}})})()},[z,j,I,S,A,M,f]),(0,a.useEffect)(function(){var e=new i.j9(u);return C(e),M(e),function(){z(e)}},[u,M,z]),{startScanCamera:M,startScanFile:W}).startScanFile,G=function(){_.current&&_.current.click()},U=function(e){var t=e.target.files;if(t.length>0){var n=t[0];n.size<1e6?V(n):alert(F("The image size is too large. Please compress it to below 1MB before uploading"))}};(0,a.useEffect)(function(){return document.documentElement.style.overscrollBehavior="none",function(){document.documentElement.style.overscrollBehavior="default"}},[]),(0,a.useEffect)(function(){var e=Q.width,t=Q.height,n=Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),r=Math.max(document.documentElement.clientHeight||0,window.innerHeight||0);if(e>0&&t>0&&t<r){var o=Math.floor(r/t*e),i=document.getElementsByTagName("video")[0];i.style.height="".concat(r,"px"),i.style.width="".concat(o,"px"),R.current.style.left="".concat((n-o)/2,"px"),R.current.style.position="absolute"}},[Q]);var $={zIndex:"1003",fontSize:"1.8em",fontWeight:"bold"};return l().createElement(l().Fragment,null,l().createElement("div",{ref:R,id:E,style:{position:"absolute"}}),l().createElement(s,{style:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},(T=Math.floor(.6*Math.min(B,D)),{left:"".concat((B-T)/2,"px"),top:"".concat((D-T)/2,"px"),position:"fixed",width:"".concat(T,"px"),height:"".concat(T,"px")}))}),l().createElement(function(){return l().createElement("div",{style:{position:"absolute",bottom:"20px",left:"20px",padding:"10px 60px"}},l().createElement("div",{style:{color:"white",width:"40px",display:"flex",flexDirection:"column",alignItems:"center"}},l().createElement(r.FileImageOutlined,{style:$,onClick:G}),F("Album"),l().createElement("input",{ref:_,type:"file",accept:"image/*",onChange:U,style:{visibility:"hidden"}})))},null))},k=function(e){var t=(0,o.useActionContext)(),n=t.visible,u=t.setVisible,s=w((0,a.useState)(!1),2),f=s[0],h=s[1],p=(0,c.useTranslation)("block-workbench").t;return(0,a.useEffect)(function(){var e;n&&!f&&(e=function(){var e,t,n;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,i.j9.getCameras()];case 1:return 0===r.sent().length?alert(p("No camera device detected")):h(!0),[3,3];case 2:return e=r.sent(),t={NotFoundError:p("No camera device detected"),NotAllowedError:p("You have not granted permission to use the camera")},console.log(e),alert(null!=(n=t[e.name])?n:e),h(!1),u(!1),[3,3];case 3:return[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){x(i,r,o,a,l,"next",e)}function l(e){x(i,r,o,a,l,"throw",e)}a(void 0)})})()},[n,f,u,p]),n&&f?l().createElement("div",{style:{position:"fixed",width:"100%",height:"100%",background:"black",zIndex:"1001",top:0,left:0,overflow:"hidden"}},l().createElement(S,{setVisible:u}),l().createElement(r.LeftOutlined,{style:{position:"absolute",top:"22px",left:"20px",zIndex:"1003",color:"white",fontSize:"1.8em",fontWeight:"bold"},onClick:function(){return u(!1)}}),l().createElement("div",{style:{position:"absolute",color:"white",fontSize:"1.5em",left:0,right:0,top:"20px",zIndex:"1002",marginLeft:"auto",marginRight:"auto",textAlign:"center"}},p("Scan QR code"))):null}}}]);