1import{r as n,j as e}from"./jsx-runtime.js";import{t as g}from"./gql-tada.js";import{c as _}from"./utils.js";import{A as Y,a as Z,b as ee,c as ae,d as te,e as se,f as ie,g as re,h as le}from"./alert-dialog.js";import{u as L}from"./use-translation.js";import{B as x}from"./button.js";import{X as ne}from"./x.js";import{C as ce}from"./crop-image-field.js";import{D as oe,a as de,b as me,c as ue,d as he,e as xe}from"./dialog.js";import{g as ge}from"./get-base64-from-image-url.js";import{u}from"./index6.js";import{c as je}from"./create-random-string.js";import{A as fe}from"./auth-context.js";import{C as pe}from"./checkbox.js";import{I as ke}from"./input.js";import{R as H,a as l}from"./radio-group.js";import{u as Ce}from"./upload-public-image.js";import{d as be}from"./delete-uploaded-image.js";import{L as ve}from"./loader-circle.js";import{b as Ie}from"./useQuery.js";import{u as P}from"./useMutation.js";function Se(a){const c=L(),[t,i]=n.useState(!1),o=()=>{a.onDelete(),i(!1)};return e.jsxs(Y,{open:t,onOpenChange:i,children:[e.jsx(Z,{asChild:!0,children:e.jsx(x,{variant:"secondary",size:"icon",className:"absolute top-1 right-1 rounded-full",onClick:()=>i(!0),children:e.jsx(ne,{className:"size-4"})})}),e.jsxs(ee,{children:[e.jsxs(ae,{children:[e.jsx(te,{children:c("確èª","Confirmation")}),e.jsx(se,{children:c("ã¹ã¿ã³ããåé¤ãã¾ããï¼","Do you want to delete this stamp?")})]}),e.jsxs(ie,{children:[e.jsx(re,{onClick:()=>i(!1),children:c("ãã£ã³ã»ã«","Cancel")}),e.jsx(le,{onClick:o,children:c("åé¤","Delete")})]})]})]})}function We(a){if(!a.imageUrl)return null;const c=(()=>{switch(a.size){case"small":return"size-8 p-1";case"medium":return"size-12 p-2";case"large":return"size-16 p-3";case"x-large":return"size-24 p-3";case"2x-large":return"size-32 p-3";default:return"size-24 p-2"}})();return e.jsxs("div",{className:"relative",children:[e.jsx("button",{className:_("relative box-border rounded border-2 border-transparent transition duration-500 hover:border-2 hover:border-clear-bright-blue",c,{"cursor-not-allowed opacity-50":a.disabled}),type:"button",onClick:a.disabled?void 0:a.onClick,disabled:a.disabled,children:e.jsx("img",{className:"m-auto",src:a.imageUrl,alt:a.title})}),a.onDelete&&e.jsx(Se,{onDelete:a.onDelete})]})}const Xe=g(`fragment StickerButton on StickerNode @_unmask { 2 id 3 title 4 imageUrl 5 }`);function _e(a){const c=n.useContext(fe),t=L(),[i,o]=n.useState(a.defaultImageBase64??""),[j,f]=n.useState(""),[I,p]=n.useState("CHARACTER"),[S,k]=n.useState(""),[M,G]=n.useState(!1),A=a.open!==void 0,C=A?a.open??!1:M,N=s=>{var m;if(A){(m=a.onOpenChange)==null||m.call(a,s);return}G(s)},[d,b]=n.useState(!1),r=n.useId(),D=`${r}-public-sticker`,w=`${r}-person-check`,y=`${r}-animal-check`,F=`${r}-machine-check`,T=`${r}-background-check`,B=`${r}-object-check`,$=`${r}-happy-check`,R=`${r}-enjoy-check`,U=`${r}-celebration-check`,E=`${r}-sad-check`,O=`${r}-other-check`,{data:v}=Ie(Ae),[V,{loading:Q}]=P(Ne),[q,{loading:J}]=P(De),K=async s=>{const m=await ge(s);o(m)},z=()=>{N(!1),o(""),f(""),p("CHARACTER"),k(""),b(!1)},W=()=>{o("")};n.useEffect(()=>{C&&a.defaultImageBase64&&i===""&&o(a.defaultImageBase64)},[i,C,a.defaultImageBase64]);const X=async()=>{var m;if(i===""){u(t("ç»åã鏿ãã¦ãã ãã","Please select an image"));return}if(c.isLoading||c.isNotLoggedIn){u(t("ãã°ã¤ã³ãã¦ãã ãã","Please log in"));return}if(d&&j===""){u(t("ã¿ã¤ãã«ãå ¥åãã¦ãã ãã","Please enter a title"));return}`${je(30)}`;const s=await Ce(i,(m=v==null?void 0:v.viewer)==null?void 0:m.token);if(s===""){u(t("ç»åã®ã¢ãããã¼ãã«å¤±æãã¾ãã","Failed to upload the image"));return}try{const h=await V({variables:{input:{title:d?j:null,genre:d?I:null,categories:d?[S]:null,imageUrl:s,accessType:d?"PUBLIC":"PRIVATE"}}});if(!h||!h.data){u(t("ã¹ã¿ã³ãã®ä½æã«å¤±æãã¾ãã","Failed to create the sticker"));return}await q({variables:{input:{stickerId:h.data.createSticker.id}}}),a.onAddedSicker&&a.onAddedSicker(),u(t("ã¹ã¿ã³ãã追å ãã¾ãã","Sticker added successfully")),z()}catch(h){h instanceof Error&&u(h.message),await be()}};return e.jsxs(oe,{open:C,onOpenChange:s=>{N(s),s||(o(""),f(""),p("CHARACTER"),k(""),b(!1))},children:[a.children?e.jsx(de,{asChild:!0,children:a.children}):null,e.jsxs(me,{className:"min-h-[40vw] min-w-[88vw] pl-2",children:[e.jsx(ue,{children:e.jsx(he,{children:t("ã¹ã¿ã³ã追å ","Add Sticker")})}),e.jsx(ce,{isHidePreviewImage:i==="",defaultCroppedImage:a.defaultImageBase64,cropWidth:240,cropHeight:240,fileExtension:"webp",onDeleteImage:W,onCrop:K}),e.jsxs("div",{className:"items-center space-x-2",children:[e.jsxs("div",{className:"items-center",children:[e.jsx(pe,{checked:d,onCheckedChange:()=>{b(s=>!s)},id:D}),e.jsx("label",{htmlFor:D,className:"ml-2 font-medium text-sm",children:t("誰ã§ã使ããããã«å ¬éãã","Make public for everyone to use")})]}),d&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"mt-2",children:t("ã¿ã¤ãã«","Title")}),e.jsx(ke,{onChange:s=>{f(s.target.value)},value:j,placeholder:t("ã¿ã¤ãã«","Title")}),e.jsx("p",{children:t("ã¸ã£ã³ã«","Genre")}
5),e.jsxs(H,{value:I,onValueChange:s=>{p(s)},className:"flex items-center space-x-2",children:[e.jsx("div",{className:"items-center space-x-2",children:e.jsxs("label",{htmlFor:w,children:[t("人ç©","Character"),e.jsx(l,{value:"CHARACTER",id:w})]})}),e.jsx("div",{className:"items-center space-x-2",children:e.jsxs("label",{htmlFor:y,children:[t("åç©","Animal"),e.jsx(l,{value:"ANIMAL",id:y})]})}),e.jsx("div",{className:"items-center space-x-2",children:e.jsxs("label",{htmlFor:F,children:[t("æ©æ¢°","Machine"),e.jsx(l,{value:"MACHINE",id:F})]})}),e.jsx("div",{className:"items-center space-x-2",children:e.jsxs("label",{htmlFor:T,children:[t("èæ¯","Background"),e.jsx(l,{value:"BACKGROUND",id:T})]})}),e.jsx("div",{className:"items-center space-x-2",children:e.jsxs("label",{htmlFor:B,children:[t("ç©","Object"),e.jsx(l,{value:"OBJECT",id:B})]})})]}),e.jsx("p",{children:t("ã¿ã°","Tag")}),e.jsxs(H,{value:S.toString(),onValueChange:s=>{k(s)},className:"flex items-center space-x-2",children:[e.jsx("div",{className:"items-center space-x-2",children:e.jsxs("label",{htmlFor:$,children:[t("楽ãã","Fun"),e.jsx(l,{value:"楽ãã",id:$})]})}),e.jsx("div",{className:"items-center space-x-2",children:e.jsxs("label",{htmlFor:R,children:[t("å¬ãã","Happy"),e.jsx(l,{value:"å¬ãã",id:R})]})}),e.jsx("div",{className:"items-center space-x-2",children:e.jsxs("label",{htmlFor:U,children:[t("ãç¥ã","Celebration"),e.jsx(l,{value:"ãç¥ã",id:U})]})}),e.jsx("div",{className:"items-center space-x-2",children:e.jsxs("label",{htmlFor:E,children:[t("æ²ãã","Sad"),e.jsx(l,{value:"æ²ãã",id:E})]})}),e.jsx("div",{className:"items-center space-x-2",children:e.jsxs("label",{htmlFor:O,children:[t("ãã®ä»","Other"),e.jsx(l,{value:"ãã®ä»",id:O})]})})]})]})]}),e.jsxs(xe,{children:[e.jsx(x,{variant:"secondary",className:"m-auto w-full",onClick:z,children:t("ãã£ã³ã»ã«","Cancel")}),Q||J?e.jsx(x,{disabled:!0,className:"m-auto w-full",onClick:()=>{},children:e.jsx(ve,{className:"size-4 animate-spin"})}):e.jsx(x,{disabled:i==="",className:"m-auto w-full",onClick:X,children:t("追å ","Add")})]})]})]})}const Ae=g(`query ViewerToken { 6 viewer { 7 id 8 token 9 } 10 }`),Ne=g(`mutation CreateSticker($input: CreateStickerInput!) { 11 createSticker(input: $input) { 12 id 13 } 14 }`),De=g(`mutation CreateUserSticker($input: CreateUserStickerInput!) { 15 createUserSticker(input: $input) { 16 id 17 } 18 }`);export{_e as A,Xe as S,We as a};
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.