1"use strict";(self.webpackChunkstreamlit_browser=self.webpackChunkstreamlit_browser||[]).push([[7438],{35739:function(e,t,n){n.d(t,{$:function(){return r},Z:function(){return u}});var r,i=n(47313),o=n(83985),a=n(7962),s=n(75314),l=n(74969),c=n(90960),d=n(46417);!function(e){e.EXTRASMALL="xs",e.SMALL="sm",e.MEDIUM="md",e.LARGE="lg",e.EXTRALARGE="xl"}(r||(r={}));var u=function(e){var t=e.value,n=e.width,u=e.size,g=void 0===u?r.SMALL:u,h=e.overrides,p=(0,o.u)(),f={xs:p.spacing.twoXS,sm:p.spacing.sm,md:p.spacing.lg,lg:p.spacing.xl,xl:p.spacing.twoXL},m=i.useContext(c.E).activeTheme,S=!(0,a.MJ)(m),v={BarContainer:{style:{marginTop:p.spacing.none,marginBottom:p.spacing.none,marginRight:p.spacing.none,marginLeft:p.spacing.none}},Bar:{style:function(e){var t=e.$theme;return{width:n?n.toString():void 0,marginTop:p.spacing.none,marginBottom:p.spacing.none,marginRight:p.spacing.none,marginLeft:p.spacing.none,height:f[g],backgroundColor:t.colors.progressbarTrackFill,borderTopLeftRadius:p.spacing.twoXS,borderTopRightRadius:p.spacing.twoXS,borderBottomLeftRadius:p.spacing.twoXS,borderBottomRightRadius:p.spacing.twoXS}}},BarProgress:{style:function(){return{backgroundColor:S?p.colors.primary:p.colors.blue70,borderTopLeftRadius:p.spacing.twoXS,borderTopRightRadius:p.spacing.twoXS,borderBottomLeftRadius:p.spacing.twoXS,borderBottomRightRadius:p.spacing.twoXS}}}};return(0,d.jsx)(s.Z,{value:t,overrides:(0,l.aO)(v,h)})}},87438:function(e,t,n){n.r(t),n.d(t,{default:function(){return ee}});var r,i=n(93433),o=n(15671),a=n(43144),s=n(60136),l=n(29388),c=n(92653),d=n(31881),u=n.n(d),g=n(16031),h=n.n(g),p=n(47313),f=n(64577),m=n(72185),S=n(23970),v=n(20300),w=n(72708),R=n(55982),x=n(66463),b=n(17453),F=n(46639),C=n(35739),I=n(1413),y=n(47167),E=n(2120);!function(e){e.XSMALL="xsmall",e.SMALL="small",e.MEDIUM="medium",e.LARGE="large"}(r||(r={}));var P=(0,y.Z)("div",{target:"e11drzth9"})((function(){return{position:"relative",overflow:"hidden",width:"100%",objectFit:"contain"}}),""),M=(0,y.Z)("div",{target:"e11drzth8"})((function(e){var t=e.theme,n=e.width;return{backgroundColor:t.colors.secondaryBg,borderRadius:"".concat(t.radii.lg," ").concat(t.radii.lg," 0 0"),width:"100%",height:9*n/16,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}}),""),T=(0,y.Z)("p",{target:"e11drzth7"})((function(e){return{marginTop:e.theme.spacing.sm,textAlign:"center"}}),""),L=(0,y.Z)("img",{target:"e11drzth6"})((function(e){var t=e.theme,n=e.opacity;return{borderRadius:"".concat(t.radii.lg," ").concat(t.radii.lg," 0 0"),objectFit:"contain",opacity:n}}),""),j=(0,y.Z)("a",{target:"e11drzth5"})((function(e){return{color:e.theme.colors.primary,display:"block",textDecoration:"none"}}),""),k=(0,y.Z)("span",{target:"e11drzth4"})((function(){return{display:"flex",alignItems:"center"}}),""),U=(0,y.Z)("div",{target:"e11drzth3"})((function(e){var t=e.theme;return{position:"absolute",top:t.spacing.lg,right:t.spacing.lg,zIndex:1,color:t.colors.fadedText40,mixBlendMode:"difference",opacity:.6}}),""),Z=(0,y.Z)("div",{target:"e11drzth1"})((function(){return{height:"fit-content",width:"100%",position:"absolute",bottom:0}}),""),z=(0,y.Z)("button",{target:"e11drzth0"})((function(e){var t=e.theme;return(0,I.Z)({position:"relative",display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:t.colors.lightenedBg05,border:"1px solid ".concat(t.colors.fadedText10),borderRadius:"0 0 ".concat(t.radii.lg," ").concat(t.radii.lg),"&:hover":{borderColor:t.colors.primary,color:t.colors.primary},"&:active":{color:t.colors.white,borderColor:t.colors.primary,backgroundColor:t.colors.primary},"&:focus:not(:active)":{borderColor:t.colors.primary,color:t.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{color:t.colors.fadedText40},fontWeight:t.fontWeights.normal,padding:"".concat(t.spacing.xs," ").concat(t.spacing.md),margin:0,lineHeight:t.lineHeights.base,color:"inherit",width:"100%",userSelect:"none","&:focus":{outline:"none"},"&:focus-visible":{boxShadow:"0 0 0 0.2rem ".concat((0,E.DZ)(t.colors.primary,.5))}},function(e,t){switch(e){case r.XSMALL:return{padding:"".concat(t.spacing.twoXS," ").concat(t.spacing.sm),fontSize:t.fontSizes.sm};case r.SMALL:return{padding:"".concat(t.spacing.twoXS," ").concat(t.spacing.md)};case r.LARGE:return{padding:"".concat(t.spacing.md," ").concat(t.spacing.md)};default:return{padding:"".concat(t.spacing.xs," ").concat(t.spacing.md)}}}(r.MEDIUM,t))}),""),D=n(46417);var X,O=function(e){var t=e.disabled,n=e.onClick,r=e.children,i=e.progress;return(0,D.jsxs)(z,{disabled:t||!1,onClick:n||function(){},progress:i||null,"data-testid":"stCameraInputButton",children:[r,i&&(0,D.jsx)(Z,{children:(0,D.jsx)(C.Z,{value:i,size:C.$.EXTRASMALL,overrides:{Bar:{style:{borderTopLeftRadius:"0px",borderTopRightRadius:"0px"}},BarProgress:{style:{borderTopLeftRadius:"0px",borderTopRightRadius:"0px"}},BarContainer:{style:{borderTopLeftRadius:"0px",borderTopRightRadius:"0px"}}}})})]})},A=n(29975),B=n(2444),N=n(78701);!function(e){e.USER="user",e.ENVIRONMENT="environment"}(X||(X={}));var _,G=function(e){var t=e.switchFacingMode;return(0,D.jsx)(U,{children:(0,D.jsx)(S.ZP,{content:"Switch camera",placement:S.ug.TOP_RIGHT,children:(0,D.jsx)(B.ZP,{kind:B.nW.MINIMAL,onClick:t,children:(0,D.jsx)(m.ZP,{content:A.Z,size:"twoXL",color:N.Z.white})})})})},V=n(29439),W=n(86101),H=n(83985),$=n(34862),q=n(62790),J=n.n(q),K=n(19746);!function(e){e.PENDING="pending",e.SUCCESS="success",e.ERROR="error"}(_||(_={}));var Q=function(e){var t=e.width;return(0,D.jsxs)(M,{width:t,children:[(0,D.jsx)(m.ZP,{size:"threeXL",color:N.Z.gray60,content:W.n}),(0,D.jsxs)(T,{children:["This app would like to use your camera.",(0,D.jsx)(j,{href:K.U3,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]})]})},Y=function(e){var t=e.handleCapture,n=e.width,r=e.disabled,i=e.clearPhotoInProgress,o=e.setClearPhotoInProgress,a=e.facingMode,s=e.setFacingMode,l=(0,p.useState)(_.PENDING),c=(0,V.Z)(l,2),d=c[0],u=c[1],g=(0,p.useRef)(null),h=(0,p.useState)(n),f=(0,V.Z)(h,2),m=f[0],S=f[1],v=(0,p.useCallback)((0,b.Ds)(1e3,S),[]);(0,p.useEffect)((function(){v(n)}),[n,v]);var w=(0,H.u)();return(0,D.jsxs)(P,{width:m,children:[d===_.SUCCESS||r||i?$.tq&&(0,D.jsx)(G,{switchFacingMode:s}):(0,D.jsx)(Q,{width:m}),(0,D.jsx)(M,{hidden:d!==_.SUCCESS&&!r&&!i,width:m,children:!r&&(0,D.jsx)(J(),{audio:!1,ref:g,screenshotFormat:"image/jpeg",screenshotQuality:1,width:m,height:9*m/16,style:{borderRadius:"".concat(w.radii.lg," ").concat(w.radii.lg," 0 0")},onUserMediaError:function(){u(_.ERROR)},onUserMedia:function(){u(_.SUCCESS),o(!1)},videoConstraints:{width:{ideal:m},facingMode:a}})}),(0,D.jsx)(O,{onClick:function(){if(null!==g.current){var e=g.current.getScreenshot();t(e)}},disabled:d!==_.SUCCESS||r||i,children:"Take Photo"})]})};var ee=function(e){(0,s.Z)(n,e);var t=(0,l.Z)(n);function n(e){var r;return(0,o.Z)(this,n),(r=t.call(this,e)).localFileIdCounter=1,r.RESTORED_FROM_WIDGET_STRING="RESTORED_FROM_WIDGET",r.formClearHelper=new R.Kz,r.getProgress=function(){if(r.state.files.length>0&&"uploading"===r.state.files[r.state.files.length-1].status.type)return r.state.files[r.state.files.length-1].status.progress},r.setClearPhotoInProgress=function(e){r.setState({clearPhotoInProgress:e})},r.setFacingMode=function(){r.setState((function(e){return{facingMode:e.facingMode===X.USER?X.ENVIRONMENT:X.USER}}))},r.handleCapture=function(e){if(null===e)return Promise.resolve();r.setState({imgSrc:e,shutter:!0,minShutterEffectPassed:!1}
1);var t,n;return(t=e,n="camera-input-".concat((new Date).toISOString().replace(/:/g,"_"),".jpg"),fetch(t).then((function(e){return e.arrayBuffer()})).then((function(e){return new File([e],n,{type:"image/jpeg"})}))).then((function(e){return r.uploadFile(e)})).then((function(){return e=150,new Promise((function(t){return setTimeout(t,e)}));var e})).then((function(){r.setState((function(t,n){return{imgSrc:e,shutter:t.shutter,minShutterEffectPassed:!0}}))})).catch((function(e){(0,x.H)(e)}))},r.removeCapture=function(){0!==r.state.files.length&&(r.state.files.forEach((function(e){return r.deleteFile(e.id)})),r.setState({imgSrc:null,clearPhotoInProgress:!0}))},r.componentDidUpdate=function(e){var t=r.props,n=t.element,i=t.widgetMgr;if(e.disabled!==r.props.disabled&&r.props.disabled)return r.reset(),void i.setFileUploaderStateValue(n,new f.xO,{fromUi:!1});if("ready"===r.status){var o=r.createWidgetValue();if(void 0!==o){var a=i.getFileUploaderStateValue(n);h().isEqual(o,a)||i.setFileUploaderStateValue(n,o,{fromUi:!0})}}},r.onFormCleared=function(){r.setState({files:[]},(function(){var e=r.createWidgetValue();null!=e&&(r.setState({imgSrc:null}),r.props.widgetMgr.setFileUploaderStateValue(r.props.element,e,{fromUi:!0}))}))},r.deleteFile=function(e){var t=r.getFile(e);null!=t&&("uploading"===t.status.type&&t.status.cancelToken.cancel(),r.removeFile(e))},r.addFile=function(e){r.setState((function(t){return{files:[].concat((0,i.Z)(t.files),[e])}}))},r.removeFile=function(e){r.setState((function(t){return{files:t.files.filter((function(t){return t.id!==e}))}}))},r.getFile=function(e){return r.state.files.find((function(t){return t.id===e}))},r.updateFile=function(e,t){r.setState((function(n){return{files:n.files.map((function(n){return n.id===e?t:n}))}}))},r.onUploadComplete=function(e,t){r.setState((function(e){return{newestServerFileId:Math.max(e.newestServerFileId,t),shutter:!1}}));var n=r.getFile(e);null!=n&&"uploading"===n.status.type&&r.updateFile(n.id,n.setStatus({type:"uploaded",serverFileId:t}))},r.onUploadProgress=function(e,t){var n=r.getFile(t);if(null!=n&&"uploading"===n.status.type){var i=Math.round(100*e.loaded/e.total);n.status.progress!==i&&r.updateFile(t,n.setStatus({type:"uploading",cancelToken:n.status.cancelToken,progress:i}))}},r.reset=function(){r.setState({files:[],imgSrc:null})},r.uploadFile=function(e){var t=u().CancelToken.source(),n=new F.R(e.name,e.size,r.nextLocalFileId(),{type:"uploading",cancelToken:t,progress:1});r.addFile(n),r.props.uploadClient.uploadFile(r.props.element,e,(function(e){return r.onUploadProgress(e,n.id)}),t.token).then((function(e){return r.onUploadComplete(n.id,e)})).catch((function(e){u().isCancel(e)||r.updateFile(n.id,n.setStatus({type:"error",errorMessage:e?e.toString():"Unknown error"}))}))},r.state=r.initialValue,r}return(0,a.Z)(n,[{key:"initialValue",get:function(){var e=this,t={files:[],newestServerFileId:0,imgSrc:null,shutter:!1,minShutterEffectPassed:!0,clearPhotoInProgress:!1,facingMode:X.USER},n=this.props,r=n.widgetMgr,i=n.element,o=r.getFileUploaderStateValue(i);if(null==o)return t;var a=o.maxFileId,s=o.uploadedFileInfo;return null==a||0===a||null==s?t:{files:s.map((function(t){var n=t.name,r=t.size,i=t.id;return new F.R(n,r,e.nextLocalFileId(),{type:"uploaded",serverFileId:i})})),newestServerFileId:Number(a),imgSrc:0===s.length?"":this.RESTORED_FROM_WIDGET_STRING,shutter:!1,minShutterEffectPassed:!1,clearPhotoInProgress:!1,facingMode:X.USER}}},{key:"componentWillUnmount",value:function(){this.formClearHelper.disconnect()}},{key:"status",get:function(){return this.state.files.some((function(e){return"uploading"===e.status.type}))?"updating":"ready"}},{key:"createWidgetValue",value:function(){if(0!==this.state.newestServerFileId){var e=this.state.files.filter((function(e){return"uploaded"===e.status.type})).map((function(e){var t=e.name,n=e.size,r=e.status;return new f.jM({id:r.serverFileId,name:t,size:n})}));return new f.xO({maxFileId:this.state.newestServerFileId,uploadedFileInfo:e})}}},{key:"render",value:function(){var e,t=this.props,n=t.element,r=t.widgetMgr,i=t.disabled,o=t.width;return this.formClearHelper.manageFormClearListener(r,n.formId,this.onFormCleared),(0,D.jsxs)(P,{width:o,className:"row-widget","data-testid":"stCameraInput",children:[(0,D.jsx)(w.ON,{label:n.label,disabled:i,labelVisibility:(0,b.iF)(null===(e=n.labelVisibility)||void 0===e?void 0:e.value),children:n.help&&(0,D.jsx)(w.dT,{children:(0,D.jsx)(v.ZP,{content:n.help,placement:S.ug.TOP_RIGHT})})}),this.state.imgSrc?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(M,{width:o,children:this.state.imgSrc!==this.RESTORED_FROM_WIDGET_STRING&&(0,D.jsx)(L,{src:this.state.imgSrc,alt:"Snapshot",opacity:this.state.shutter||!this.state.minShutterEffectPassed?"50%":"100%",width:o,height:9*o/16})}),(0,D.jsx)(O,{onClick:this.removeCapture,progress:this.getProgress(),disabled:!!this.getProgress()||i,children:this.getProgress()?"Uploading...":(0,D.jsxs)(k,{children:[(0,D.jsx)(m.ZP,{content:c.X,margin:"0 xs 0 0",size:"sm"})," Clear photo"]})})]}):(0,D.jsx)(Y,{handleCapture:this.handleCapture,width:o,disabled:i,clearPhotoInProgress:this.state.clearPhotoInProgress,setClearPhotoInProgress:this.setClearPhotoInProgress,facingMode:this.state.facingMode,setFacingMode:this.setFacingMode})]})}},{key:"nextLocalFileId",value:function(){return this.localFileIdCounter++}}]),n}(p.PureComponent)},46639:function(e,t,n){n.d(t,{R:function(){return o}});var r=n(15671),i=n(43144),o=function(){function e(t,n,i,o){(0,r.Z)(this,e),this.name=void 0,this.size=void 0,this.status=void 0,this.id=void 0,this.name=t,this.size=n,this.id=i,this.status=o}return(0,i.Z)(e,[{key:"setStatus",value:function(t){return new e(this.name,this.size,this.id,t)}}]),e}()}}]);
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.