1!function(){try{("undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:{}).__faroBundleId_undefined="17550702746887c08d02d8e"}catch(e){}}(),(self.webpackChunkappsmith=self.webpackChunkappsmith||[]).push([[1717],{42753:(e,t,o)=>{o.d(t,{U:()=>i});const i=(e,t,o,i)=>({...e,...i&&{deviceId:i},...t&&{facingMode:{ideal:o}}})},61717:(e,t,o)=>{o.r(t),o.d(t,{default:()=>se});var i=o(49255),n=o(34869),r=o(97727),a=o(85039),s=o.n(a),d=o(68616),l=o.n(d),c=o(98004),p=o(11795),u=o(43009),h=o(17463),b=o(87607),g=o(5570),y=o(97179),m=o(26490),x=o.n(m),C=o(30456),T=o(79260),f=o(40026);let v=function(e){return e.ALWAYS_ON="ALWAYS_ON",e.CLICK_TO_SCAN="CLICK_TO_SCAN",e}({});var S=o(97981),A=o(81345),w=o(42753),N=o(92894),E=o(65983);const L=(0,A.E)((async()=>o.e(9222).then(o.bind(o,79966)))),I=(0,A.E)((async()=>o.e(9222).then(o.bind(o,30508)))),O=c.DU` 2 .code-scanner-content { 3 position: fixed; 4 top: 50%; 5 left: 50%; 6 transform: translate(-50%, -50%); 7 z-index: 2000; 8 height: 90%; 9 max-height: 500px; 10 width: 90%; 11 max-width: 500px; 12 border-radius: ${e=>{let{borderRadius:t}=e;return t}}; 13 box-shadow: ${e=>{let{boxShadow:t}=e;return t}}; 14 background-color: black; 15 } 16 17 .code-scanner-overlay { 18 position: fixed; 19 top: 0; 20 left: 0; 21 right: 0; 22 bottom: 0; 23 background-color: rgba(16, 22, 26, 0.7); 24 z-index: 10; 25 } 26 27 .code-scanner-close { 28 background-color: white; 29 width: 32px; 30 height: 32px; 31 text-align: center; 32 position: absolute; 33 top: -36px; 34 right: -2px; 35 border-radius: ${e=>{let{borderRadius:t}=e;return t}}; 36 background-image: url(${p.A}); 37 background-repeat: no-repeat; 38 background-position: center; 39 } 40 41 @media only screen and (min-width: 820px) { 42 .code-scanner-close { 43 right: -36px; 44 } 45 } 46 47 @keyframes scan { 48 from {top: 0%} 49 to {top: calc(100% - 4px);} 50 } 51 52 .code-scanner-camera-container { 53 border-radius: ${e=>{let{borderRadius:t}=e;return t}}; 54 background: ${e=>{let{disabled:t}=e;return t?"var(--wds-color-bg-disabled)":"#000"}}; 55 border-radius: ${e=>{let{borderRadius:t}=e;return t}}; 56 box-shadow: ${e=>{let{boxShadow:t,scannerLayout:o}=e;return o===v.ALWAYS_ON?t:"none"}}; 57 overflow: hidden; 58 height: 100%; 59 position: relative; 60 61 &::before { 62 content: ''; 63 position: absolute; 64 top: 0%; 65 left: 0; 66 height: 4px; 67 width: 100%; 68 background-color: rgba(255, 0, 0, 0.75); 69 animation-name: scan; 70 animation-duration: 2s; 71 animation-direction: alternate; 72 animation-iteration-count: infinite; 73 animation-timing-function: ease-in-out; 74 z-index: 1; 75 border-radius: ${e=>{let{borderRadius:t}=e;return t}}; 76 } 77 78 &.mirror-video { 79 video { 80 transform: scaleX(-1); 81 } 82 } 83 } 84 85 .code-scanner-camera-container video { 86 height: 100%; 87 position: relative; 88 object-fit: contain; 89 border-radius: ${e=>{let{borderRadius:t}=e;return t}}; 90 } 91`,R=c.AH` 92 position: absolute; 93 height: 100%; 94 width: 100%; 95 object-fit: contain; 96 top: 50%; 97 left: 50%; 98 transform: translate(-50%, -50%); 99 display: flex; 100 align-items: center; 101 justify-content: center; 102`,P=c.Ay.div` 103 height: 100%; 104 width: 100%; 105`,k=c.Ay.div` 106 ${R}; 107 display: ${e=>{let{disabled:t}=e;return t?"flex":"none"}}; 108 height: 100%; 109 z-index: 2; 110 background: var(--wds-color-bg-disabled); 111`,D=c.Ay.div` 112 position: relative; 113`,B=c.Ay.div` 114 position: absolute; 115 bottom: 34px; 116 right: 0; 117`,j=c.Ay.div` 118 width: 100%; 119`,_=c.Ay.div` 120 position: absolute; 121 width: 100%; 122 left: 0; 123 bottom: 0; 124 padding: 1%; 125 display: flex; 126 align-items: center; 127 justify-content: space-between; 128 z-index: 4; 129 130 flex-direction: ${e=>{let{appLayoutType:t}=e;return"MOBILE"===t?"column":"row"}}; 131`,W=c.Ay.div` 132 display: flex; 133 flex: 1; 134 justify-content: space-between; 135 136 & .bp3-minimal { 137 height: 30px; 138 width: 60px; 139 } 140`,F=c.Ay.div` 141 height: 100%; 142 && .bp3-popover2-target { 143 height: 100%; 144 width: 100%; 145 & > div { 146 height: 100%; 147 } 148 } 149`,V=c.DU` 150 .iconBtnTooltipContainer { 151 .bp3-popover2-content { 152 max-width: 350px;
153 overflow-wrap: anywhere; 154 padding: 10px 12px; 155 border-radius: 0px; 156 } 157 } 158`,M=c.Ay.div` 159 height: 100%; 160 width: 100%; 161 padding: 0.5em 0; 162 text-align: center; 163 color: white; 164 display: flex; 165 align-items: center; 166 justify-content: center; 167 flex-direction: column; 168 background-color: black; 169 border-radius: ${e=>{let{borderRadius:t}=e;return t}}; 170 box-shadow: ${e=>{let{boxShadow:t}=e;return t}}; 171`,$=(0,c.Ay)(h.$n)` 172 z-index: 1; 173 height: 32px; 174 width: 32px; 175 margin: 0 1%; 176 box-shadow: none !important; 177 ${e=>{let{borderRadius:t}=e;return t===f.Eg.CIRCLE&&"\n border-radius: 50%;\n "}} 178 border: ${e=>{let{variant:t}=e;return t===f.xt.SECONDARY?"1px solid white":"none"}}; 179 background: ${e=>{let{theme:t,variant:o}=e;return o===f.xt.PRIMARY?t.colors.button.primary.primary.bgColor:"none"}} !important; 180 181 &:hover { 182 background: rgba(167, 182, 194, 0.3) !important; 183 } 184`;function Y(e){const{items:t,onItemClick:o}=e;return(0,E.jsx)(h.W1,{children:t.map((e=>(0,E.jsx)(h.Dr,{onClick:()=>o(e),text:e.label||e.deviceId},e.deviceId)))})}function U(e){const{disabledMenu:t,isMenuOpen:o,items:i,onItemClick:n,onMenuClick:r}=e;return(0,E.jsxs)(D,{children:[(0,E.jsx)(h.$n,{disabled:t,minimal:!0,onClick:()=>r(!o),rightIcon:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(h.In,{color:"white",icon:"mobile-video"}),(0,E.jsx)(h.In,{color:"white",icon:"caret-down"})]})}),o&&(0,E.jsx)(B,{children:(0,E.jsx)(Y,{items:i,onItemClick:n})})]})}function X(e){const{appLayoutType:t,onMediaInputChange:o,videoInputs:n}=e,[r,a]=(0,i.useState)(!1);(0,i.useEffect)((()=>{const e=()=>{r&&a(!1)};return document.addEventListener("click",e,!1),()=>{document.removeEventListener("click",e,!1)}}),[r]);const s=t=>{e.updateDeviceInputs(),a(t)};return(0,E.jsx)(j,{children:(0,E.jsx)(_,{appLayoutType:t,children:(0,E.jsxs)(W,{children:[(0,E.jsx)($,{borderRadius:f.Eg.SHARP,icon:(0,E.jsx)(h.In,{color:"white",icon:(0,E.jsx)(I,{}),iconSize:20}),onClick:e.handleImageMirror,variant:f.xt.TERTIARY}),(()=>{const e=(0,u.VK)(),t=(0,u.KR)()===u.D5.IOS||(0,u.KR)()===u.D5.MAC&&"object"===typeof e&&"Safari"===(null===e||void 0===e?void 0:e.browser);return(0,E.jsx)(U,{disabled:t,disabledIcon:t,isMenuOpen:r,items:n,onItemClick:o,onMenuClick:s})})()]})})})}const H=function(e){const[t,o]=(0,i.useState)(!1),[n,a]=(0,i.useState)([]),[d,c]=(0,i.useState)(""),[p,u]=(0,i.useState)(!1),[h,m]=(0,i.useState)(N.Fr?{facingMode:{ideal:e.defaultCamera}}:{}),f=(0,S.A)(),A=()=>{o(!1)},I=(0,y.d4)(g.Yf),R=(0,i.useCallback)((e=>{a(e.filter((e=>{let{kind:t}=e;return"videoinput"===t})))}),[a]),D=(0,i.useCallback)((()=>{try{navigator.mediaDevices.enumerateDevices().then(R).catch((e=>{c(e.message)}))}catch(e){x().debug("Error in calling enumerateDevices")}}),[R]),B=(0,i.useCallback)((e=>{if("videoinput"===e.kind){const t=(0,w.U)(h,N.Fr,"",e.deviceId);m(t)}}),[]),j=(0,i.useCallback)((e=>{"string"===typeof e&&c(e),c(e.message)}),[]),_=()=>{u(!p)},W=(0,E.jsx)(r.SC,{borderRadius:e.borderRadius,boxShadow:e.boxShadow,buttonColor:e.buttonColor,disabled:e.isDisabled,iconAlign:e.iconAlign,iconName:e.iconName,onClick:()=>{o(!0)},placement:e.placement,shouldFitContent:e.shouldButtonFitContent,text:e.label});return(0,E.jsxs)(P,{onClick:e=>e.stopPropagation(),children:[e.scannerLayout!==v.ALWAYS_ON&&(e.tooltip?(0,E.jsxs)(F,{children:[(0,E.jsx)(V,{}),(0,E.jsx)(C.I,{autoFocus:!1,content:(0,E.jsx)(T.Ay,{content:e.tooltip}),hoverOpenDelay:200,interactionKind:"hover",portalClassName:"iconBtnTooltipContainer",position:b.yX.TOP,children:W})]}):W),(()=>{const i=(0,E.jsxs)(M,{borderRadius:e.borderRadius,boxShadow:e.boxShadow,children:[(0,E.jsx)(L,{}),(0,E.jsxs)("span",{className:"error-text",children:[d,"\u2002"]}),"Permission denied"===d&&(0,E.jsx)("a",{href:"https://support.google.com/chrome/answer/2693767",rel:"noreferrer",target:"_blank",children:"Know more"})]}),r=(0,E.jsx)("div",{className:"code-scanner-camera-container "+(p?"mirror-video":""),children:e.isDisabled?(0,E.jsx)(k,{disabled:e.isDisabled,children:(0,E.jsx)(L,{})}):(0,E.jsxs)(E.Fragment,{children:[f&&(0,E.jsx)(l(),{delay:1e3,onError:j,onUpdate:(t,i)=>{if(i){const t=i.text;o(!1),e.onCodeDetected(t)}t&&x().debug(t)},videoConstraints:h},JSON.stringify(h)),(0,E.jsx)(X,{appLayoutType:null===I||void 0===I?void 0:I.type,handleImageMirror:_,onMediaInputChange:B,updateDeviceInputs:D,videoInputs:n})]})}),a=d?i:r,c=(0,E.jsxs)(s(),{className:"code-scanner-content",isOpen:t,onRequestClose:A,overlayClassName:"code-scanner-overlay",children:[d?i:t&&r,(0,E.jsx)("button",{className:"code-scanner-close",onClick:A})]});return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(O,{borderRadius:e.borderRadius,boxSh
184adow:e.boxShadow,disabled:e.isDisabled,scannerLayout:e.scannerLayout}),e.scannerLayout===v.ALWAYS_ON?a:c]})})()]})};var K=o(63259),J=o(50785),z=o(26141),G=o(85235),q=o(94095);const Q=[{sectionName:"Basic",children:[{propertyName:"scannerLayout",label:"Scanner layout",controlType:"ICON_TABS",defaultValue:v.ALWAYS_ON,fullWidth:!0,helpText:'Sets how the code scanner will look and behave. If set to "Always on", the scanner will be visible and scanning all the time. If set to "Click to Scan", the scanner will pop up inside a modal and start scanning when the user clicks on the button.',options:[{label:"Always on",value:v.ALWAYS_ON},{label:"Click to scan",value:v.CLICK_TO_SCAN}],hidden:z.Iv,isJSConvertible:!1,isBindProperty:!1,isTriggerProperty:!1},{propertyName:"label",label:"Text",controlType:"INPUT_TEXT",helpText:"Sets the label of the button",placeholderText:"Scan a QR/Barcode",inputType:"TEXT",isBindProperty:!0,isTriggerProperty:!1,validation:{type:J.b.TEXT},hidden:e=>e.scannerLayout===v.ALWAYS_ON,dependencies:["scannerLayout"]}]},{sectionName:"General",children:[{propertyName:"isVisible",label:"Visible",helpText:"Controls the visibility of the widget",controlType:"SWITCH",isJSConvertible:!0,isBindProperty:!0,isTriggerProperty:!1,validation:{type:J.b.BOOLEAN}},{propertyName:"isDisabled",label:"Disabled",helpText:"Disables input to this widget",controlType:"SWITCH",isJSConvertible:!0,isBindProperty:!0,isTriggerProperty:!1,validation:{type:J.b.BOOLEAN}},{propertyName:"animateLoading",label:"Animate loading",controlType:"SWITCH",helpText:"Controls the loading of the widget",defaultValue:!0,isJSConvertible:!0,isBindProperty:!0,isTriggerProperty:!1,validation:{type:J.b.BOOLEAN}},{helpText:"Show helper text with button on hover",propertyName:"tooltip",label:"Tooltip",controlType:"INPUT_TEXT",placeholderText:"Add Input Field",isBindProperty:!0,isTriggerProperty:!1,validation:{type:J.b.TEXT},hidden:e=>e.scannerLayout===v.ALWAYS_ON,dependencies:["scannerLayout"]},{propertyName:"defaultCamera",label:(0,G.oHS)(G.jZ7),helpText:(0,G.oHS)(G.umB),controlType:"DROP_DOWN",defaultValue:q.AF.BACK,options:[{label:(0,G.oHS)(G.LQ2),value:q.AF.FRONT},{label:(0,G.oHS)(G.fZk),value:q.AF.BACK}],isBindProperty:!0,isTriggerProperty:!1,validation:{type:J.b.TEXT,params:{allowedValues:[q.AF.FRONT,q.AF.BACK],default:q.AF.BACK}}}]},{sectionName:"Events",children:[{helpText:"when a valid code is detected",propertyName:"onCodeDetected",label:"onCodeDetected",controlType:"ACTION_SELECTOR",isJSConvertible:!0,isBindProperty:!0,isTriggerProperty:!0}]}];var Z=o(18267);const ee=[{sectionName:"Icon",children:[{propertyName:"iconName",label:"Select icon",helpText:"Sets the icon to be used for the button",controlType:"ICON_SELECT",isBindProperty:!1,isTriggerProperty:!1,updateHook:(e,t,o)=>{const i=[{propertyPath:t,propertyValue:o}];return e.iconAlign||i.push({propertyPath:"iconAlign",propertyValue:Z.C.LEFT}),i},dependencies:["iconAlign","scannerLayout"],validation:{type:J.b.TEXT},hidden:e=>e.scannerLayout===v.ALWAYS_ON},{propertyName:"iconAlign",label:"Position",helpText:"Sets the icon alignment of the button",controlType:"ICON_TABS",defaultValue:"left",fullWidth:!1,options:[{startIcon:"skip-left-line",value:"left"},{startIcon:"skip-right-line",value:"right"}],isBindProperty:!1,isTriggerProperty:!1,validation:{type:J.b.TEXT,params:{allowedValues:["center","left","right"]}},hidden:e=>e.scannerLayout===v.ALWAYS_ON,dependencies:["scannerLayout"]},{propertyName:"placement",label:"Placement",controlType:"ICON_TABS",fullWidth:!0,helpText:"Sets the space between items",options:[{label:"Start",value:f.dU.START},{label:"Between",value:f.dU.BETWEEN},{label:"Center",value:f.dU.CENTER}],defaultValue:f.dU.CENTER,isJSConvertible:!0,isBindProperty:!0,isTriggerProperty:!1,validation:{type:J.b.TEXT,params:{allowedValues:[f.dU.START,f.dU.BETWEEN,f.dU.CENTER],default:f.dU.CENTER}},hidden:e=>e.scannerLayout===v.ALWAYS_ON,dependencies:["scannerLayout"]}]},{sectionName:"Color",children:[{propertyName:"buttonColor",helpText:"Sets the background color of the button",label:"Button color",controlType:"COLOR_PICKER",isJSConvertible:!0,isBindProperty:!0,isTriggerProperty:!1,validation:{type:J.b.TEXT,params:{regex:/^(?![<|{{]).+/}},hidden:e=>
184e.scannerLayout===v.ALWAYS_ON,dependencies:["scannerLayout"]}]},{sectionName:"Border and shadow",children:[{propertyName:"borderRadius",label:"Border radius",helpText:"Rounds the corners of the icon button's outer border edge",controlType:"BORDER_RADIUS_OPTIONS",isJSConvertible:!0,isBindProperty:!0,isTriggerProperty:!1,validation:{type:J.b.TEXT}},{propertyName:"boxShadow",label:"Box shadow",helpText:"Enables you to cast a drop shadow from the frame of the widget",controlType:"BOX_SHADOW_OPTIONS",isJSConvertible:!0,isBindProperty:!0,isTriggerProperty:!1,validation:{type:J.b.TEXT}}]}];var te=o(43567),oe=o(72698),ie=o(62751),ne=o(29460),re=o(63251);class ae extends n.Ay{constructor(){super(...arguments),this.onCodeDetected=e=>{this.props.updateWidgetMetaProperty("value",e,{triggerPropertyName:"onCodeDetected",dynamicString:this.props.onCodeDetected,event:{type:K.Bx.ON_CODE_DETECTED}})}}static getConfig(){return{name:"Code Scanner",iconSVG:oe.A,thumbnailSVG:ie.A,tags:[re.xT.EXTERNAL],needsMeta:!0,searchTags:["barcode scanner","qr scanner","code detector","barcode reader"]}}static getDefaults(){return{rows:33,label:"Scan a QR/Barcode",columns:25,widgetName:"CodeScanner",isDefaultClickDisabled:!0,scannerLayout:v.ALWAYS_ON,version:1,isRequired:!1,isDisabled:!1,animateLoading:!0,placement:f.dU.CENTER,responsiveBehavior:ne.Fu.Fill,flexVerticalAlignment:ne.NW.Top}}static getAutoLayoutConfig(){return{disabledPropsDefaults:{scannerLayout:v.ALWAYS_ON},widgetSize:[{viewportMinWidth:0,configuration:()=>({minWidth:"280px",minHeight:"300px"})}]}}static getAnvilConfig(){return{isLargeWidget:!1,widgetSize:{maxHeight:{},maxWidth:{},minHeight:{base:"300px"},minWidth:{base:"280px"}}}}static getPropertyPaneContentConfig(){return Q}static getSetterConfig(){return{__setters:{setVisibility:{path:"isVisible",type:"boolean"},setDisable:{path:"isDisabled",type:"boolean"}}}}static getPropertyPaneStyleConfig(){return ee}static getMetaPropertiesMap(){return{value:void 0}}static getAutocompleteDefinitions(){return{"!doc":"Scan a Code","!url":"https://docs.appsmith.com/reference/widgets/code-scanner",isVisible:te.C0.isVisible,isDisabled:"bool",value:"string"}}static getStylesheetConfig(){return{buttonColor:"{{appsmith.theme.colors.primaryColor}}",borderRadius:"{{appsmith.theme.borderRadius.appBorderRadius}}",boxShadow:"none"}}getWidgetView(){return(0,E.jsx)(H,{borderRadius:this.props.borderRadius,boxShadow:this.props.boxShadow,buttonColor:this.props.buttonColor||this.props.accentColor,defaultCamera:this.props.defaultCamera,iconAlign:this.props.iconAlign,iconName:this.props.iconName,isDisabled:this.props.isDisabled,label:this.props.label,onCodeDetected:this.onCodeDetected,placement:this.props.placement,scannerLayout:this.props.scannerLayout,shouldButtonFitContent:this.isAutoLayoutMode,tooltip:this.props.tooltip,widgetId:this.props.widgetId},this.props.widgetId)}}ae.type="CODE_SCANNER_WIDGET";const se=ae}}]); 185//# sourceMappingURL=1717.e487a198.chunk.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.